diff options
| -rw-r--r-- | ports/nrf/drivers/usb/usb_cdc.c | 12 | ||||
| -rw-r--r-- | ports/nrf/mphalport.c | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/ports/nrf/drivers/usb/usb_cdc.c b/ports/nrf/drivers/usb/usb_cdc.c index fa098c98b..a1d411a25 100644 --- a/ports/nrf/drivers/usb/usb_cdc.c +++ b/ports/nrf/drivers/usb/usb_cdc.c @@ -34,6 +34,7 @@ #include "nrfx_power.h" #include "nrfx_uart.h" #include "py/ringbuf.h" +#include "py/stream.h" #ifdef BLUETOOTH_SD #include "nrf_sdm.h" @@ -192,6 +193,17 @@ void usb_cdc_sd_event_handler(uint32_t soc_evt) { } #endif +uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { + uintptr_t ret = 0; + if (poll_flags & MP_STREAM_POLL_RD) { + usb_cdc_loop(); + if (cdc_rx_any()) { + ret |= MP_STREAM_POLL_RD; + } + } + return ret; +} + int mp_hal_stdin_rx_chr(void) { for (;;) { usb_cdc_loop(); diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c index 8ffb25601..1b31ad5ac 100644 --- a/ports/nrf/mphalport.c +++ b/ports/nrf/mphalport.c @@ -172,7 +172,7 @@ void mp_hal_set_interrupt_char(int c) { } #endif -#if !MICROPY_PY_BLE_NUS +#if !MICROPY_PY_BLE_NUS && !MICROPY_HW_USB_CDC uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { uintptr_t ret = 0; if ((poll_flags & MP_STREAM_POLL_RD) && MP_STATE_PORT(board_stdio_uart) != NULL @@ -181,9 +181,7 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { } return ret; } -#endif -#if !MICROPY_PY_BLE_NUS && !MICROPY_HW_USB_CDC int mp_hal_stdin_rx_chr(void) { for (;;) { if (MP_STATE_PORT(board_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(board_stdio_uart))) { |
