diff --git a/ports/renesas-ra/mphalport.c b/ports/renesas-ra/mphalport.c index 1c62c23dd70b..f379df0e2380 100644 --- a/ports/renesas-ra/mphalport.c +++ b/ports/renesas-ra/mphalport.c @@ -69,9 +69,6 @@ uint8_t cdc_itf_pending; // keep track of cdc interfaces which need attention to uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { uintptr_t ret = 0; - #if MICROPY_HW_USB_CDC - ret |= mp_usbd_cdc_poll_interfaces(poll_flags); - #endif #if MICROPY_HW_ENABLE_UART_REPL if (poll_flags & MP_STREAM_POLL_WR) { ret |= MP_STREAM_POLL_WR; @@ -79,6 +76,8 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { #endif #if MICROPY_PY_OS_DUPTERM ret |= mp_os_dupterm_poll(poll_flags); + #elif MICROPY_HW_USB_CDC + ret |= mp_usbd_cdc_poll_interfaces(poll_flags); #endif return ret; } @@ -86,10 +85,6 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { // Receive single character int mp_hal_stdin_rx_chr(void) { for (;;) { - #if MICROPY_HW_USB_CDC - mp_usbd_cdc_poll_interfaces(0); - #endif - #if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE flash_cache_commit(); #endif @@ -103,6 +98,8 @@ int mp_hal_stdin_rx_chr(void) { if (dupterm_c >= 0) { return dupterm_c; } + #elif MICROPY_HW_USB_CDC + mp_usbd_cdc_poll_interfaces(0); #endif MICROPY_EVENT_POLL_HOOK } @@ -119,20 +116,18 @@ mp_uint_t mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { } #endif - #if MICROPY_HW_USB_CDC - mp_uint_t cdc_res = mp_usbd_cdc_tx_strn(str, len); - if (cdc_res > 0) { - did_write = true; - ret = MIN(cdc_res, ret); - } - #endif - #if MICROPY_PY_OS_DUPTERM int dupterm_res = mp_os_dupterm_tx_strn(str, len); if (dupterm_res >= 0) { did_write = true; ret = MIN((mp_uint_t)dupterm_res, ret); } + #elif MICROPY_HW_USB_CDC + mp_uint_t cdc_res = mp_usbd_cdc_tx_strn(str, len); + if (cdc_res > 0) { + did_write = true; + ret = MIN(cdc_res, ret); + } #endif return did_write ? ret : 0;