Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32L5: enable USBDEVICE #14340

Merged
merged 2 commits into from Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions targets/TARGET_STM/TARGET_STM32L5/system_clock.c
Expand Up @@ -147,7 +147,7 @@ uint8_t SetSysClock_PLL_MSI(void)
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
#if DEVICE_TRNG
#if DEVICE_TRNG || DEVICE_USBDEVICE
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
#else
RCC_OscInitStruct.HSI48State = RCC_HSI48_OFF;
Expand Down Expand Up @@ -176,12 +176,21 @@ uint8_t SetSysClock_PLL_MSI(void)
return 0; // FAIL
}

#if DEVICE_TRNG
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
#if DEVICE_TRNG
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RNG;
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_HSI48;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
#endif
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
return 0; // FAIL
}
#endif
#if DEVICE_USBDEVICE
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
return 0; // FAIL
}
#endif

return 1; // OK
}
Expand Down
2 changes: 2 additions & 0 deletions targets/TARGET_STM/USBPhyHw.h
Expand Up @@ -45,6 +45,8 @@

#if defined(TARGET_STM32F1) || defined(TARGET_STM32F3) || defined(TARGET_STM32WB) || defined(TARGET_STM32G4)
#define USBHAL_IRQn USB_LP_IRQn
#elif defined(TARGET_STM32L5)
#define USBHAL_IRQn USB_FS_IRQn
#else
#define USBHAL_IRQn USB_IRQn
#endif
Expand Down
3 changes: 2 additions & 1 deletion targets/targets.json
Expand Up @@ -3951,7 +3951,8 @@
"FLASH",
"MPU",
"SERIAL_ASYNCH",
"TRNG"
"TRNG",
"USBDEVICE"
]
},
"MCU_STM32L552xE": {
Expand Down