From 9c2b0cd2e3c9bfc96fe23f4a395f8f8115768fea Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 30 Nov 2025 08:25:17 +1100 Subject: [PATCH] stm32/usbd_conf: Fix build for boards with USB disabled. Some boards (eg NUCLEO_G0B1RE and NUCLEO_G474RE) have USB disabled but still configure MICROPY_HW_USB_FS/HS for the cases where USB does get enabled. Such a configuration should not build any of the code in `usbd_conf.c`, nor the USB interrupt handlers. Signed-off-by: Damien George --- ports/stm32/stm32_it.c | 4 ++++ ports/stm32/usbd_conf.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/stm32/stm32_it.c b/ports/stm32/stm32_it.c index 19778020d9..17b9532646 100644 --- a/ports/stm32/stm32_it.c +++ b/ports/stm32/stm32_it.c @@ -301,6 +301,8 @@ void DebugMon_Handler(void) { /* file (startup_stm32f4xx.s). */ /******************************************************************************/ +#if MICROPY_HW_STM_USB_STACK || MICROPY_HW_TINYUSB_STACK + #if defined(STM32G0) #if MICROPY_HW_USB_FS @@ -499,6 +501,8 @@ void OTG_HS_WKUP_IRQHandler(void) { #endif // !defined(STM32L0) +#endif // MICROPY_HW_STM_USB_STACK || MICROPY_HW_TINYUSB_STACK + /** * @brief This function handles PPP interrupt request. * @param None diff --git a/ports/stm32/usbd_conf.c b/ports/stm32/usbd_conf.c index e5ac9311d1..46d7985253 100644 --- a/ports/stm32/usbd_conf.c +++ b/ports/stm32/usbd_conf.c @@ -36,7 +36,7 @@ #include "irq.h" #include "usb.h" -#if MICROPY_HW_USB_FS || MICROPY_HW_USB_HS +#if MICROPY_HW_STM_USB_STACK || MICROPY_HW_TINYUSB_STACK #if BUILDING_MBOOT // TinyUSB not used in mboot