File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -317,7 +317,7 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
317317void HAL_PCD_ResumeCallback (PCD_HandleTypeDef * hpcd )
318318{
319319 if (hpcd -> Init .low_power_enable ) {
320- SystemClock_Config ();
320+ USBD_SystemClockConfigFromResume ();
321321
322322 /* Reset SLEEPDEEP bit of Cortex System Control Register */
323323 SCB -> SCR &= (uint32_t )~((uint32_t )(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk ));
@@ -415,9 +415,8 @@ void USB_H_IRQHandler(void)
415415 /* Reset SLEEPDEEP bit of Cortex System Control Register */
416416 SCB -> SCR &= (uint32_t )~((uint32_t )(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk ));
417417
418- /* Configures system clock after wake-up from STOP: enable HSE, PLL and select
419- PLL as system clock source (HSE and PLL are disabled in STOP mode) */
420- SystemClock_Config ();
418+ /* Configures system clock after wake-up */
419+ USBD_SystemClockConfigFromResume ();
421420
422421 /* ungate PHY clock */
423422 __HAL_PCD_UNGATE_PHYCLOCK ((& g_hpcd ));
Original file line number Diff line number Diff line change @@ -175,4 +175,19 @@ void USBD_CDC_init(void)
175175 CDC_init ();
176176}
177177#endif /* USBD_USE_CDC */
178+
179+ /**
180+ * @brief Configures system clock and system IP clocks after wake-up from USB
181+ * resume callBack
182+ * @note Weaked function which can be redefined by user at the sketch level.
183+ * By default, calls 'SystemClock_Config()'.
184+ * @param None
185+ * @retval None
186+ */
187+ WEAK void USBD_SystemClockConfigFromResume (void )
188+ {
189+ configIPClock ();
190+ SystemClock_Config ();
191+ }
192+
178193#endif /* USBCON */
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ void USBD_reenumerate(void);
2727#ifdef USBD_USE_CDC
2828void USBD_CDC_init (void );
2929#endif
30+
31+ /* Weaked function */
32+ void USBD_SystemClockConfigFromResume (void );
33+
3034#ifdef __cplusplus
3135}
3236#endif
You can’t perform that action at this time.
0 commit comments