Commit aed1da91 authored by Damien George's avatar Damien George
Browse files

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.
parent 53521152
...@@ -94,6 +94,20 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) ...@@ -94,6 +94,20 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
/* Enable USB FS Clocks */ /* Enable USB FS Clocks */
__USB_OTG_FS_CLK_ENABLE(); __USB_OTG_FS_CLK_ENABLE();
#if defined (MCU_SERIES_L4)
/* Enable VDDUSB */
if(__HAL_RCC_PWR_IS_CLK_DISABLED())
{
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableVddUSB();
__HAL_RCC_PWR_CLK_DISABLE();
}
else
{
HAL_PWREx_EnableVddUSB();
}
#endif
/* Set USBFS Interrupt priority */ /* Set USBFS Interrupt priority */
HAL_NVIC_SetPriority(OTG_FS_IRQn, IRQ_PRI_OTG_FS, IRQ_SUBPRI_OTG_FS); HAL_NVIC_SetPriority(OTG_FS_IRQn, IRQ_PRI_OTG_FS, IRQ_SUBPRI_OTG_FS);
...@@ -296,9 +310,11 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) ...@@ -296,9 +310,11 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
/* Set USB Current Speed */ /* Set USB Current Speed */
switch(hpcd->Init.speed) switch(hpcd->Init.speed)
{ {
#if defined(PCD_SPEED_HIGH)
case PCD_SPEED_HIGH: case PCD_SPEED_HIGH:
speed = USBD_SPEED_HIGH; speed = USBD_SPEED_HIGH;
break; break;
#endif
case PCD_SPEED_FULL: case PCD_SPEED_FULL:
speed = USBD_SPEED_FULL; speed = USBD_SPEED_FULL;
...@@ -399,6 +415,10 @@ if (pdev->id == USB_PHY_FS_ID) ...@@ -399,6 +415,10 @@ if (pdev->id == USB_PHY_FS_ID)
pcd_fs_handle.Init.phy_itface = PCD_PHY_EMBEDDED; pcd_fs_handle.Init.phy_itface = PCD_PHY_EMBEDDED;
pcd_fs_handle.Init.Sof_enable = 1; pcd_fs_handle.Init.Sof_enable = 1;
pcd_fs_handle.Init.speed = PCD_SPEED_FULL; pcd_fs_handle.Init.speed = PCD_SPEED_FULL;
#if defined(MCU_SERIES_L4)
pcd_fs_handle.Init.lpm_enable = DISABLE;
pcd_fs_handle.Init.battery_charging_enable = DISABLE;
#endif
#if !defined(MICROPY_HW_USB_VBUS_DETECT_PIN) #if !defined(MICROPY_HW_USB_VBUS_DETECT_PIN)
pcd_fs_handle.Init.vbus_sensing_enable = 0; // No VBUS Sensing on USB0 pcd_fs_handle.Init.vbus_sensing_enable = 0; // No VBUS Sensing on USB0
#else #else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment