Skip to content

Commit a27e4a1

Browse files
committed
fix(USB): power management
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 39bb12f commit a27e4a1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

cores/arduino/stm32/usb/usbd_conf.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,18 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
5757
pinMode(PIN_UCPD_TCPP, OUTPUT_OPEN_DRAIN);
5858
digitalWriteFast(digitalPinToPinName(PIN_UCPD_TCPP), LOW);
5959
#endif
60-
60+
#if defined(PWR_CR3_USB33DEN) || defined(PWR_USBSCR_USB33DEN)
61+
HAL_PWREx_EnableUSBVoltageDetector();
62+
#endif
63+
#if defined(PWR_CR3_USB33RDY)
64+
while (!LL_PWR_IsActiveFlag_USB());
65+
#elif defined(PWR_VMSR_USB33RDY)
66+
while (!LL_PWR_IsActiveFlag_VDDUSB());
67+
#endif
6168
#if defined(PWR_CR2_USV) || defined(PWR_SVMCR_USV) || defined(PWR_USBSCR_USB33SV)
62-
/* Enable VDDUSB on Pwrctrl CR2 register*/
69+
/* Enable VDDUSB */
6370
HAL_PWREx_EnableVddUSB();
6471
#endif
65-
#ifdef STM32H7xx
66-
if (!LL_PWR_IsActiveFlag_USB()) {
67-
HAL_PWREx_EnableUSBVoltageDetector();
68-
}
69-
#endif
7072
#if defined (USB)
7173
if (hpcd->Instance == USB) {
7274

0 commit comments

Comments
 (0)