8000 esp32: Enable machine.USBDevice to configure USB at runtime. · 32bitmicro/micropython@5f2d05d · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f2d05d

Browse files
sebromerodpgeorge
authored andcommitted
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>
1 parent bdda91f commit 5f2d05d

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

ports/esp32/esp32_common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ if(MICROPY_PY_TINYUSB)
7878
${MICROPY_DIR}/shared/tinyusb/mp_usbd.c
7979
${MICROPY_DIR}/shared/tinyusb/mp_usbd_cdc.c
8080
${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c
81+
${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.c
8182
)
8283

8384
list(APPEND MICROPY_INC_TINYUSB

ports/esp32/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ void mp_task(void *pvParameter) {
183183
mp_thread_deinit();
184184
#endif
185185

186+
#if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
187+
mp_usbd_deinit();
188+
#endif
189+
186190
gc_sweep_all();
187191

188192
// Free any native code pointers that point to iRAM.

ports/esp32/mpconfigport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@
215215
#else
216216
#define MICROPY_HW_USB_VID (CONFIG_TINYUSB_DESC_CUSTOM_VID)
217217
#endif
218+
219+
#ifndef MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
220+
#define MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE (1) // Support machine.USBDevice
221+
#endif
218222
#endif
219223

220224
#ifndef MICROPY_HW_USB_PID

0 commit comments

Comments
 (0)
0