Skip to content

Commit 5c7f629

Browse files
committed
samd/mphalport: Fix building with USB CDC disabled.
This commit fixes the build issues in the SAMD port that arise when explicitly disabling USB CDC support. The console code assumed CDC support is always enabled even if it was disabled in mpconfigport.h. These changes make accessing CDC conditional to that support configuration being enabled. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
1 parent b5157bc commit 5c7f629

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ports/samd/mphalport.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ uint64_t mp_hal_ticks_us_64(void) {
120120

121121
uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
122122
uintptr_t ret = 0;
123+
#if MICROPY_HW_USB_CDC
123124
ret |= mp_usbd_cdc_poll_interfaces(poll_flags);
125+
#endif
124126
#if MICROPY_PY_OS_DUPTERM
125127
ret |= mp_os_dupterm_poll(poll_flags);
126128
#endif
@@ -129,8 +131,9 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
129131

130132
int mp_hal_stdin_rx_chr(void) {
131133
for (;;) {
132-
134+
#if MICROPY_HW_USB_CDC
133135
mp_usbd_cdc_poll_interfaces(0);
136+
#endif
134137
int c = ringbuf_get(&stdin_ringbuf);
135138
if (c != -1) {
136139
return c;
@@ -149,11 +152,13 @@ int mp_hal_stdin_rx_chr(void) {
149152
mp_uint_t mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
150153
mp_uint_t ret = len;
151154
bool did_write = false;
155+
#if MICROPY_HW_USB_CDC
152156
mp_uint_t cdc_res = mp_usbd_cdc_tx_strn(str, len);
153157
if (cdc_res > 0) {
154158
did_write = true;
155159
ret = MIN(cdc_res, ret);
156160
}
161+
#endif
157162
#if MICROPY_PY_OS_DUPTERM
158163
int dupterm_res = mp_os_dupterm_tx_strn(str, len);
159164
if (dupterm_res >= 0) {

0 commit comments

Comments
 (0)