diff options
author | Alessandro Gatti <a.gatti@frob.it> | 2025-07-18 16:36:07 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-09-09 10:29:38 +1000 |
commit | 5f3e6b5b5381fd180280b0c852826db079808cce (patch) | |
tree | d7f88dc8261f953c29d824e5e3093eb57c062892 | |
parent | c7c0ad222ee017435ba24eeb82ba90a30dc8ae2b (diff) |
shared/tinyusb: Fix build errors with CDC support disabled.
This commit makes possible building MicroPython with USB CDC support
disabled.
The original code does support such a configuration but missed a few
spots where build errors would arise. These changes fix the remaining
issues, fixing also warnings caused by the changes needed to make the
build succeed.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
-rw-r--r-- | shared/tinyusb/mp_usbd.h | 3 | ||||
-rw-r--r-- | shared/tinyusb/mp_usbd_runtime.c | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/shared/tinyusb/mp_usbd.h b/shared/tinyusb/mp_usbd.h index 5c8f2a609..866ef8503 100644 --- a/shared/tinyusb/mp_usbd.h +++ b/shared/tinyusb/mp_usbd.h @@ -38,13 +38,16 @@ #ifndef NO_QSTR #include "tusb.h" #include "device/dcd.h" +#include "class/cdc/cdc_device.h" #endif // Initialise TinyUSB device. static inline void mp_usbd_init_tud(void) { tusb_init(); + #if MICROPY_HW_USB_CDC tud_cdc_configure_fifo_t cfg = { .rx_persistent = 0, .tx_persistent = 1 }; tud_cdc_configure_fifo(&cfg); + #endif } // Run the TinyUSB device task diff --git a/shared/tinyusb/mp_usbd_runtime.c b/shared/tinyusb/mp_usbd_runtime.c index a1eebeebd..72e011732 100644 --- a/shared/tinyusb/mp_usbd_runtime.c +++ b/shared/tinyusb/mp_usbd_runtime.c @@ -267,9 +267,11 @@ static uint16_t runtime_dev_open(uint8_t rhport, tusb_desc_interface_t const *it } // If TinyUSB built-in drivers are enabled, don't claim any interface in the built-in range + #if USBD_ITF_BUILTIN_MAX > 0 if (mp_usb_device_builtin_enabled(usbd) && itf_desc->bInterfaceNumber < USBD_ITF_BUILTIN_MAX) { return 0; } + #endif // Determine the total descriptor length of the interface(s) we are going to claim uint8_t assoc_itf_count = _runtime_dev_count_itfs(itf_desc); |