summaryrefslogtreecommitdiff
path: root/ports/stm32/main.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-11-27 15:00:32 +1100
committerDamien George <damien@micropython.org>2025-11-29 23:35:20 +1100
commit63c94fe73ed5c52d4d7ccbf4ddcc2a1e3178d21b (patch)
tree6539eae8f252f7318e0c0111423c9a3a39e365bc /ports/stm32/main.c
parentf43810b1cd4142474a99df4e08d51a97eb9af00a (diff)
stm32: Fix init sequence of USB hardware and TinyUSB stack.
This commit fixes the initialization sequence for TinyUSB when enabled on the stm32 port: - Following other ports, `mp_usbd_init()` should be called just after running `boot.py`, to give the user a chance to configure USB. - Hardware initialization (via `pyb_usbd_init()`) should only occur once, the first time TinyUSB is started up. This is achieved by adding a hook to the shared TinyUSB bindings to call `pyb_usbd_init()`, and only do the hardware init if TinyUSB was not already initialized. Also, `pyb_usbd_init()` is renamed `mp_usbd_ll_init()` to make it match with the rest of the stared TinyUSB binding code. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/stm32/main.c')
-rw-r--r--ports/stm32/main.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index 6f7413694..8085a5e25 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -611,14 +611,9 @@ soft_reset:
pyb_can_init0();
#endif
- #if MICROPY_HW_ENABLE_USB
- #if MICROPY_HW_TINYUSB_STACK
- pyb_usbd_init();
- mp_usbd_init();
- #else
+ #if MICROPY_HW_STM_USB_STACK && MICROPY_HW_ENABLE_USB
pyb_usb_init0();
#endif
- #endif
#if MICROPY_PY_MACHINE_I2S
machine_i2s_init0();
@@ -690,6 +685,10 @@ soft_reset:
}
#endif
+ #if MICROPY_HW_TINYUSB_STACK && MICROPY_HW_ENABLE_USBDEV
+ mp_usbd_init();
+ #endif
+
#if MICROPY_HW_HAS_MMA7660
// MMA accel: init and reset
accel_init();