diff options
| author | Sebastian Romero <s.romero@arduino.cc> | 2024-12-04 16:30:56 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-12-16 11:41:40 +1100 |
| commit | 5f2d05d41755990c1e14223475e19c7d204d9db2 (patch) | |
| tree | 218ea7686549ecd86c6118b67e7cf68eb728e6a8 | |
| parent | bdda91fe7414b2ff8d5259a176cc8da8b72a803f (diff) | |
esp32: Enable machine.USBDevice to configure USB at runtime.
This adds support for `machine.USBDevice` to S2 and S3 boards.
Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
| -rw-r--r-- | ports/esp32/esp32_common.cmake | 1 | ||||
| -rw-r--r-- | ports/esp32/main.c | 4 | ||||
| -rw-r--r-- | ports/esp32/mpconfigport.h | 4 |
3 files changed, 9 insertions, 0 deletions
diff --git a/ports/esp32/esp32_common.cmake b/ports/esp32/esp32_common.cmake index 0a6b29983..b6bfcdacc 100644 --- a/ports/esp32/esp32_common.cmake +++ b/ports/esp32/esp32_common.cmake @@ -78,6 +78,7 @@ if(MICROPY_PY_TINYUSB) ${MICROPY_DIR}/shared/tinyusb/mp_usbd.c ${MICROPY_DIR}/shared/tinyusb/mp_usbd_cdc.c ${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c + ${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.c ) list(APPEND MICROPY_INC_TINYUSB diff --git a/ports/esp32/main.c b/ports/esp32/main.c index 18ef9d735..4f0c27ee0 100644 --- a/ports/esp32/main.c +++ b/ports/esp32/main.c @@ -183,6 +183,10 @@ soft_reset_exit: mp_thread_deinit(); #endif + #if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE + mp_usbd_deinit(); + #endif + gc_sweep_all(); // Free any native code pointers that point to iRAM. diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index bf1f5a186..b5b7d63a5 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -215,6 +215,10 @@ #else #define MICROPY_HW_USB_VID (CONFIG_TINYUSB_DESC_CUSTOM_VID) #endif + +#ifndef MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE +#define MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE (1) // Support machine.USBDevice +#endif #endif #ifndef MICROPY_HW_USB_PID |
