Skip to content

Commit c8ceffb

Browse files
committed
mimxrt/mphalport: Fix building with USB CDC disabled.
This commit fixes the build issues in the MIMXRT 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 7f6bdd7 commit c8ceffb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ports/mimxrt/mphalport.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ ringbuf_t stdin_ringbuf = {stdin_ringbuf_array, sizeof(stdin_ringbuf_array), 0,
4747

4848
uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
4949
uintptr_t ret = 0;
50+
#if MICROPY_HW_USB_CDC
5051
ret |= mp_usbd_cdc_poll_interfaces(poll_flags);
52+
#endif
5153
#if MICROPY_PY_OS_DUPTERM
5254
ret |= mp_os_dupterm_poll(poll_flags);
5355
#endif
@@ -56,7 +58,9 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
5658

5759
int mp_hal_stdin_rx_chr(void) {
5860
for (;;) {
61+
#if MICROPY_HW_USB_CDC
5962
mp_usbd_cdc_poll_interfaces(0);
63+
#endif
6064
int c = ringbuf_get(&stdin_ringbuf);
6165
if (c != -1) {
6266
return c;
@@ -74,11 +78,13 @@ int mp_hal_stdin_rx_chr(void) {
7478
mp_uint_t mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
7579
mp_uint_t ret = len;
7680
bool did_write = false;
81+
#if MICROPY_HW_USB_CDC
7782
mp_uint_t cdc_res = mp_usbd_cdc_tx_strn(str, len);
7883
if (cdc_res > 0) {
7984
did_write = true;
8085
ret = MIN(cdc_res, ret);
8186
}
87+
#endif
8288
#if MICROPY_PY_OS_DUPTERM
8389
int dupterm_res = mp_os_dupterm_tx_strn(str, len);
8490
if (dupterm_res >= 0) {

0 commit comments

Comments
 (0)