Skip to content

Commit aed1da9

Browse files
committed
stmhal: L4: Modify usbd_conf.c to support L4 MCU.
Original patch was authored by Tobias Badertscher / @tobbad, but it was reworked to split UART edits from USB edits.
1 parent 5352115 commit aed1da9

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

stmhal/usbd_conf.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
9494
/* Enable USB FS Clocks */
9595
__USB_OTG_FS_CLK_ENABLE();
9696

97+
#if defined (MCU_SERIES_L4)
98+
/* Enable VDDUSB */
99+
if(__HAL_RCC_PWR_IS_CLK_DISABLED())
100+
{
101+
__HAL_RCC_PWR_CLK_ENABLE();
102+
HAL_PWREx_EnableVddUSB();
103+
__HAL_RCC_PWR_CLK_DISABLE();
104+
}
105+
else
106+
{
107+
HAL_PWREx_EnableVddUSB();
108+
}
109+
#endif
110+
97111
/* Set USBFS Interrupt priority */
98112
HAL_NVIC_SetPriority(OTG_FS_IRQn, IRQ_PRI_OTG_FS, IRQ_SUBPRI_OTG_FS);
99113

@@ -296,9 +310,11 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
296310
/* Set USB Current Speed */
297311
switch(hpcd->Init.speed)
298312
{
313+
#if defined(PCD_SPEED_HIGH)
299314
case PCD_SPEED_HIGH:
300315
speed = USBD_SPEED_HIGH;
301316
break;
317+
#endif
302318

303319
case PCD_SPEED_FULL:
304320
speed = USBD_SPEED_FULL;
@@ -399,6 +415,10 @@ if (pdev->id == USB_PHY_FS_ID)
399415
pcd_fs_handle.Init.phy_itface = PCD_PHY_EMBEDDED;
400416
pcd_fs_handle.Init.Sof_enable = 1;
401417
pcd_fs_handle.Init.speed = PCD_SPEED_FULL;
418+
#if defined(MCU_SERIES_L4)
419+
pcd_fs_handle.Init.lpm_enable = DISABLE;
420+
pcd_fs_handle.Init.battery_charging_enable = DISABLE;
421+
#endif
402422
#if !defined(MICROPY_HW_USB_VBUS_DETECT_PIN)
403423
pcd_fs_handle.Init.vbus_sensing_enable = 0; // No VBUS Sensing on USB0
404424
#else

0 commit comments

Comments
 (0)