nrf/drivers/usb: Fix MP_STREAM_POLL_RD support on USB CDC.

This gets ipoll working on USB CDC stdin.
This commit is contained in:
Andrew Leech 2022-03-01 21:34:05 +11:00 committed by Damien George
parent dc8b43adc7
commit f92da1adc4
2 changed files with 13 additions and 3 deletions

View File

@ -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();

View File

@ -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))) {