Skip to content

Commit 0ee3da6

Browse files
committed
stm32/usb: Add support for using TinyUSB stack.
Signed-off-by: Andrew Leech <[email protected]>
1 parent 308563d commit 0ee3da6

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

ports/stm32/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ TINYUSB_SRC_C := $(addprefix lib/tinyusb/, \
251251
$(TINYUSB_SRC_C) \
252252
src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
253253
src/portable/synopsys/dwc2/dcd_dwc2.c \
254+
src/portable/synopsys/dwc2/dwc2_common.c \
255+
src/portable/synopsys/dwc2/hcd_dwc2.c \
254256
)
255257

256258
SRC_C += \

ports/stm32/stm32_it.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,12 @@ void OTG_FS_IRQHandler(void) {
370370
#if MICROPY_HW_USB_HS
371371
#if defined(STM32N6)
372372
void USB1_OTG_HS_IRQHandler(void) {
373-
IRQ_ENTER(USB1_OTG_HS_IRQn);
373+
IRQ_ENTER(USB1_OTG_HS_IRQn); IRQ_ENTER(OTG_FS_IRQn);
374+
#if MICROPY_HW_TINYUSB_STACK
375+
tud_int_handler(0);
376+
#else
374377
HAL_PCD_IRQHandler(&pcd_hs_handle);
378+
#endif
375379
IRQ_EXIT(USB1_OTG_HS_IRQn);
376380
}
377381
#else
@@ -432,6 +436,9 @@ static void OTG_CMD_WKUP_Handler(PCD_HandleTypeDef *pcd_handle) {
432436
/* ungate PHY clock */
433437
__HAL_PCD_UNGATE_PHYCLOCK(pcd_handle);
434438
}
439+
#if MICROPY_HW_TINYUSB_STACK
440+
tud_int_handler(0);
441+
#endif
435442

436443
}
437444
#endif

ports/stm32/usbd_conf.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@
3737

3838
#if MICROPY_HW_USB_FS || MICROPY_HW_USB_HS
3939

40-
#if !MICROPY_HW_TINYUSB_STACK
40+
#if BUILDING_MBOOT
41+
// TinyUSB not used in mboot
42+
#undef MICROPY_HW_TINYUSB_STACK
43+
#endif
44+
45+
// These handles are also used in Interrupt / Wakeup handlers.
4146
#if MICROPY_HW_USB_FS
4247
PCD_HandleTypeDef pcd_fs_handle;
4348
#endif
4449
#if MICROPY_HW_USB_HS
4550
PCD_HandleTypeDef pcd_hs_handle;
4651
#endif
47-
#endif
4852

4953
#if defined(STM32G0) || defined(STM32H5)
5054
#define USB_OTG_FS USB_DRD_FS

0 commit comments

Comments
 (0)