Skip to content

Commit bb1685b

Browse files
committed
chore(u3): USB device support
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 181362e commit bb1685b

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

libraries/SrcWrapper/inc/stm32_def.h

+10-3
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,18 @@ __STATIC_INLINE void LL_RTC_SetBinMixBCDU(RTC_TypeDef *RTCx, uint32_t BinMixBcdU
188188
#if !defined(USB) && defined(USB_DRD_FS)
189189
#define USB USB_DRD_FS
190190
#define PinMap_USB PinMap_USB_DRD_FS
191-
#if defined(STM32H5xx) || defined(STM32U0xx) || defined(STM32U5xx)
191+
#if defined(STM32H5xx) || defined(STM32U0xx) ||\
192+
defined(STM32U3xx) || defined(STM32U5xx)
192193
#define USB_BASE USB_DRD_BASE
193194
#if !defined(__HAL_RCC_USB_CLK_ENABLE)
194-
#define __HAL_RCC_USB_CLK_ENABLE __HAL_RCC_USB_FS_CLK_ENABLE
195-
#define __HAL_RCC_USB_CLK_DISABLE __HAL_RCC_USB_FS_CLK_DISABLE
195+
#if defined(__HAL_RCC_USB_FS_CLK_ENABLE)
196+
#define __HAL_RCC_USB_CLK_ENABLE __HAL_RCC_USB_FS_CLK_ENABLE
197+
#define __HAL_RCC_USB_CLK_DISABLE __HAL_RCC_USB_FS_CLK_DISABLE
198+
#endif
199+
#if defined(__HAL_RCC_USB1_CLK_ENABLE)
200+
#define __HAL_RCC_USB_CLK_ENABLE __HAL_RCC_USB1_CLK_ENABLE
201+
#define __HAL_RCC_USB_CLK_DISABLE __HAL_RCC_USB1_CLK_DISABLE
202+
#endif
196203
#endif
197204
#endif
198205
#endif

libraries/USBDevice/inc/usbd_conf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ extern "C" {
8080
#elif defined(STM32U5xx) && !defined(USB_DRD_FS)
8181
#define USB_IRQn OTG_FS_IRQn
8282
#define USB_IRQHandler OTG_FS_IRQHandler
83-
#elif defined(STM32L5xx)
83+
#elif defined(STM32L5xx) || defined(STM32U3xx)
8484
#define USB_IRQn USB_FS_IRQn
8585
#define USB_IRQHandler USB_FS_IRQHandler
8686
#endif

libraries/USBDevice/src/usbd_conf.c

+2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
108108
__HAL_USB_WAKEUP_EXTI_ENABLE_RISING_EDGE();
109109
#endif
110110
#ifdef __HAL_USB_WAKEUP_EXTI_ENABLE_IT
111+
#if !defined(STM32U3xx) // Workaround for STM32U3xx
111112
__HAL_USB_WAKEUP_EXTI_ENABLE_IT();
112113
#endif
114+
#endif
113115
#if defined(USB_WKUP_IRQn)
114116
/* USB Wakeup Interrupt */
115117
HAL_NVIC_EnableIRQ(USB_WKUP_IRQn);

0 commit comments

Comments
 (0)