@@ -69,27 +69,22 @@ uint8_t cdc_itf_pending; // keep track of cdc interfaces which need attention to
6969
7070uintptr_t mp_hal_stdio_poll (uintptr_t poll_flags ) {
7171 uintptr_t ret = 0 ;
72- #if MICROPY_HW_USB_CDC
73- ret |= mp_usbd_cdc_poll_interfaces (poll_flags );
74- #endif
7572 #if MICROPY_HW_ENABLE_UART_REPL
7673 if (poll_flags & MP_STREAM_POLL_WR ) {
7774 ret |= MP_STREAM_POLL_WR ;
7875 }
7976 #endif
8077 #if MICROPY_PY_OS_DUPTERM
8178 ret |= mp_os_dupterm_poll (poll_flags );
79+ #elif MICROPY_HW_USB_CDC
80+ ret |= mp_usbd_cdc_poll_interfaces (poll_flags );
8281 #endif
8382 return ret ;
8483}
8584
8685// Receive single character
8786int mp_hal_stdin_rx_chr (void ) {
8887 for (;;) {
89- #if MICROPY_HW_USB_CDC
90- mp_usbd_cdc_poll_interfaces (0 );
91- #endif
92-
9388 #if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
9489 flash_cache_commit ();
9590 #endif
@@ -103,6 +98,8 @@ int mp_hal_stdin_rx_chr(void) {
10398 if (dupterm_c >= 0 ) {
10499 return dupterm_c ;
105100 }
101+ #elif MICROPY_HW_USB_CDC
102+ mp_usbd_cdc_poll_interfaces (0 );
106103 #endif
107104 MICROPY_EVENT_POLL_HOOK
108105 }
@@ -119,20 +116,18 @@ mp_uint_t mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
119116 }
120117 #endif
121118
122- #if MICROPY_HW_USB_CDC
123- mp_uint_t cdc_res = mp_usbd_cdc_tx_strn (str , len );
124- if (cdc_res > 0 ) {
125- did_write = true;
126- ret = MIN (cdc_res , ret );
127- }
128- #endif
129-
130119 #if MICROPY_PY_OS_DUPTERM
131120 int dupterm_res = mp_os_dupterm_tx_strn (str , len );
132121 if (dupterm_res >= 0 ) {
133122 did_write = true;
134123 ret = MIN ((mp_uint_t )dupterm_res , ret );
135124 }
125+ #elif MICROPY_HW_USB_CDC
126+ mp_uint_t cdc_res = mp_usbd_cdc_tx_strn (str , len );
127+ if (cdc_res > 0 ) {
128+ did_write = true;
129+ ret = MIN (cdc_res , ret );
130+ }
136131 #endif
137132
138133 return did_write ? ret : 0 ;
0 commit comments