Skip to content

Commit dd8cbcd

Browse files
committed
core: USB: add STM32U5xx support
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 9412bf7 commit dd8cbcd

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

cores/arduino/stm32/usb/usbd_conf.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ PCD_HandleTypeDef g_hpcd;
5151
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
5252
{
5353
const PinMap *map = NULL;
54-
#if defined(PWR_CR2_USV)
54+
#if defined(PWR_CR2_USV) || defined(PWR_SVMCR_USV)
5555
/* Enable VDDUSB on Pwrctrl CR2 register*/
5656
HAL_PWREx_EnableVddUSB();
5757
#endif
@@ -136,8 +136,10 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
136136
#ifdef __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_RISING_EDGE
137137
__HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_RISING_EDGE();
138138
#endif
139+
#ifdef __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_IT
139140
__HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_IT();
140-
#if !defined(STM32L4xx)
141+
#endif
142+
#if !defined(STM32L4xx) && !defined(STM32U5xx)
141143
/* Set EXTI Wakeup Interrupt priority */
142144
HAL_NVIC_SetPriority(OTG_FS_WKUP_IRQn, USBD_IRQ_PRIO, USBD_IRQ_SUBPRIO);
143145

variants/STM32U5xx/U575Z(G-I)TxQ_U585ZETxQ/variant_NUCLEO_U575ZI_Q.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ WEAK void SystemClock_Config(void)
175175
RCC_OscInitTypeDef RCC_OscInitStruct = {};
176176
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
177177
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
178+
RCC_CRSInitTypeDef RCC_CRSInitStruct = {};
178179

179180
/** Configure the main internal regulator output voltage
180181
*/
@@ -232,6 +233,19 @@ WEAK void SystemClock_Config(void)
232233
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
233234
Error_Handler();
234235
}
236+
/** Enable the SYSCFG APB clock
237+
*/
238+
__HAL_RCC_CRS_CLK_ENABLE();
239+
/** Configures CRS
240+
*/
241+
RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
242+
RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
243+
RCC_CRSInitStruct.Polarity = RCC_CRS_SYNC_POLARITY_RISING;
244+
RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000, 1000);
245+
RCC_CRSInitStruct.ErrorLimitValue = 34;
246+
RCC_CRSInitStruct.HSI48CalibrationValue = 32;
247+
248+
HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);
235249
}
236250

237251
#ifdef __cplusplus

0 commit comments

Comments
 (0)