diff options
Diffstat (limited to 'firmware/usb_serial.c')
-rw-r--r-- | firmware/usb_serial.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/firmware/usb_serial.c b/firmware/usb_serial.c index acf19e3b1a..0c4fb9d896 100644 --- a/firmware/usb_serial.c +++ b/firmware/usb_serial.c @@ -1081,6 +1081,17 @@ int usb_serial_get_byte(void) return fifo_get_byte(&serial_in_fifo); } +int usb_serial_try_get_byte(void) +{ + int r; + if (fifo_empty(&serial_in_fifo)) + r = -1; + else + r = fifo_get_byte(&serial_in_fifo); + usb_serial_handle(); + return r; +} + /* Not used: static int usb_serial_out_full(void) @@ -1097,6 +1108,18 @@ void usb_serial_put_byte(int b) usb_serial_handle(); } +int usb_serial_try_put_byte(int b) +{ + int r = -1; + if (!fifo_full(&serial_out_fifo)) + { + fifo_put_byte(&serial_out_fifo, b); + r = 0; + } + usb_serial_handle(); + return r; +} + void usb_serial_init(void) { fifo_init(&serial_in_fifo); |