diff options
| author | Damien <damien.p.george@gmail.com> | 2013-10-21 10:42:06 +0100 |
|---|---|---|
| committer | Damien <damien.p.george@gmail.com> | 2013-10-21 10:42:06 +0100 |
| commit | f48cf67108121e60560e45ee5f351031fdac7909 (patch) | |
| tree | dacc68f27034e0de30e6fecde1687abb7dcba40a /stm/usb.c | |
| parent | cbb8868f742b168a69dc93210aa559a401374a60 (diff) | |
Implement crude but working REPL for board.
Diffstat (limited to 'stm/usb.c')
| -rw-r--r-- | stm/usb.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -26,15 +26,17 @@ void usb_init() { } void usb_vcp_receive(const char *buf, uint32_t len) { - for (int i = 0; i < len; i++) { - rx_buf[rx_buf_in++] = buf[i]; - if (rx_buf_in >= sizeof(rx_buf)) { - rx_buf_in = 0; - } - if (rx_buf_in == rx_buf_out) { - rx_buf_out = rx_buf_in + 1; - if (rx_buf_out >= sizeof(rx_buf)) { - rx_buf_out = 0; + if (is_enabled) { + for (int i = 0; i < len; i++) { + rx_buf[rx_buf_in++] = buf[i]; + if (rx_buf_in >= sizeof(rx_buf)) { + rx_buf_in = 0; + } + if (rx_buf_in == rx_buf_out) { + rx_buf_out = rx_buf_in + 1; + if (rx_buf_out >= sizeof(rx_buf)) { + rx_buf_out = 0; + } } } } |
