Skip to content

Commit ff20cb4

Browse files
committed
chore(h5e-f): usb support
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 4bde71c commit ff20cb4

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎libraries/USBDevice/src/usbd_conf.c‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
152152
#ifdef __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_IT
153153
__HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_IT();
154154
#endif
155-
#if !defined(STM32L4xx) && !defined(STM32U5xx)
155+
#if !defined(STM32H5xx) && !defined(STM32L4xx) && !defined(STM32U5xx)
156156
/* Set EXTI Wakeup Interrupt priority */
157157
HAL_NVIC_SetPriority(OTG_FS_WKUP_IRQn, USBD_IRQ_PRIO, USBD_IRQ_SUBPRIO);
158158

@@ -170,7 +170,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
170170
pin_function(map->pin, map->function);
171171
map++;
172172
}
173-
#ifndef USE_USB_HS_IN_FS
173+
#if !defined(USE_USB_HS_IN_FS) && defined(__HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE)
174174
__HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();
175175
#endif /* USE_USB_HS_IN_FS */
176176
/* Enable USB HS Clocks */
@@ -183,6 +183,16 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
183183
#endif
184184
#ifdef SYSCFG_OTGHSPHYCR_EN
185185
HAL_SYSCFG_EnableOTGPHY(SYSCFG_OTG_HS_PHY_ENABLE);
186+
#endif
187+
#if defined(RCC_AHB2ENR_OTGPHYEN)
188+
/* STM32H5E/F specific PHY initialization */
189+
__HAL_RCC_OTGPHY_CLK_ENABLE();
190+
/* Adjust the disconnect threshold and the squelch threshold */
191+
/* Recommanded values */
192+
HAL_SBS_SetOTGPHYDisconnectThreshold(SBS_OTG_HS_PHY_DISCONNECT_5_9PERCENT);
193+
HAL_SBS_SetOTGPHYSquelchThreshold(SBS_OTG_HS_PHY_SQUELCH_15PERCENT);
194+
/* Enable the OTG_HS PHY */
195+
HAL_PWREx_EnableUSBOTGHSPhy();
186196
#endif
187197
/* Set USB HS Interrupt priority */
188198
HAL_NVIC_SetPriority(OTG_HS_IRQn, USBD_IRQ_PRIO, USBD_IRQ_SUBPRIO);

0 commit comments

Comments
 (0)