summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Gatti <a.gatti@frob.it>2025-07-25 12:15:01 +0200
committerDamien George <damien@micropython.org>2025-09-09 10:29:38 +1000
commit3e5ecd0c33ddeaf50e0ff48cf1c91f87c1320170 (patch)
tree38889767841aad154957c0dfb39aa5dc4cb14893
parent1f7952e749d02f74492605ed9a50bd73dd4b4ead (diff)
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>
-rw-r--r--ports/mimxrt/mphalport.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ports/mimxrt/mphalport.c b/ports/mimxrt/mphalport.c
index be5abd95b..c3802be30 100644
--- a/ports/mimxrt/mphalport.c
+++ b/ports/mimxrt/mphalport.c
@@ -47,7 +47,9 @@ ringbuf_t stdin_ringbuf = {stdin_ringbuf_array, sizeof(stdin_ringbuf_array), 0,
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_PY_OS_DUPTERM
ret |= mp_os_dupterm_poll(poll_flags);
#endif
@@ -56,7 +58,9 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
int mp_hal_stdin_rx_chr(void) {
for (;;) {
+ #if MICROPY_HW_USB_CDC
mp_usbd_cdc_poll_interfaces(0);
+ #endif
int c = ringbuf_get(&stdin_ringbuf);
if (c != -1) {
return c;
@@ -74,11 +78,13 @@ int mp_hal_stdin_rx_chr(void) {
mp_uint_t mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
mp_uint_t ret = len;
bool did_write = false;
+ #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) {