@@ -69,27 +69,22 @@ uint8_t cdc_itf_pending; // keep track of cdc interfaces which need attention to
69
69
70
70
uintptr_t mp_hal_stdio_poll (uintptr_t poll_flags ) {
71
71
uintptr_t ret = 0 ;
72
- #if MICROPY_HW_USB_CDC
73
- ret |= mp_usbd_cdc_poll_interfaces (poll_flags );
74
- #endif
75
72
#if MICROPY_HW_ENABLE_UART_REPL
76
73
if (poll_flags & MP_STREAM_POLL_WR ) {
77
74
ret |= MP_STREAM_POLL_WR ;
78
75
}
79
76
#endif
80
77
#if MICROPY_PY_OS_DUPTERM
81
78
ret |= mp_os_dupterm_poll (poll_flags );
79
+ #elif MICROPY_HW_USB_CDC
80
+ ret |= mp_usbd_cdc_poll_interfaces (poll_flags );
82
81
#endif
83
82
return ret ;
84
83
}
85
84
86
85
// Receive single character
87
86
int mp_hal_stdin_rx_chr (void ) {
88
87
for (;;) {
89
- #if MICROPY_HW_USB_CDC
90
- mp_usbd_cdc_poll_interfaces (0 );
91
- #endif
92
-
93
88
#if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
94
89
flash_cache_commit ();
95
90
#endif
@@ -103,6 +98,8 @@ int mp_hal_stdin_rx_chr(void) {
103
98
if (dupterm_c >= 0 ) {
104
99
return dupterm_c ;
105
100
}
101
+ #elif MICROPY_HW_USB_CDC
102
+ mp_usbd_cdc_poll_interfaces (0 );
106
103
#endif
107
104
MICROPY_EVENT_POLL_HOOK
108
105
}
@@ -119,20 +116,18 @@ mp_uint_t mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
119
116
}
120
117
#endif
121
118
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
-
130
119
#if MICROPY_PY_OS_DUPTERM
131
120
int dupterm_res = mp_os_dupterm_tx_strn (str , len );
132
121
if (dupterm_res >= 0 ) {
133
122
did_write = true;
134
123
ret = MIN ((mp_uint_t )dupterm_res , ret );
135
124
}
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
+ }
136
131
#endif
137
132
138
133
return did_write ? ret : 0 ;
0 commit comments