aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm32')
-rw-r--r--src/stm32/stm32f4.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/stm32/stm32f4.c b/src/stm32/stm32f4.c
index d0a2f249..dab8d524 100644
--- a/src/stm32/stm32f4.c
+++ b/src/stm32/stm32f4.c
@@ -131,6 +131,28 @@ enable_clock_stm32f446(void)
PWR->CR = (3 << PWR_CR_VOS_Pos) | PWR_CR_ODEN | PWR_CR_ODSWEN;
while (!(PWR->CSR & PWR_CSR_ODSWRDY))
;
+
+ // Enable 48Mhz USB clock
+ if (CONFIG_USBSERIAL) {
+ if (CONFIG_CLOCK_REF_8M) {
+ RCC->PLLSAICFGR = (
+ (4 << RCC_PLLSAICFGR_PLLSAIM_Pos)
+ | (96 << RCC_PLLSAICFGR_PLLSAIN_Pos)
+ | (1 << RCC_PLLSAICFGR_PLLSAIP_Pos)
+ | (4 << RCC_PLLSAICFGR_PLLSAIQ_Pos));
+ } else {
+ RCC->PLLSAICFGR = (
+ (8 << RCC_PLLSAICFGR_PLLSAIM_Pos)
+ | (96 << RCC_PLLSAICFGR_PLLSAIN_Pos)
+ | (1 << RCC_PLLSAICFGR_PLLSAIP_Pos)
+ | (4 << RCC_PLLSAICFGR_PLLSAIQ_Pos));
+ }
+ RCC->CR |= RCC_CR_PLLSAION;
+ while (!(RCC->CR & RCC_CR_PLLSAIRDY))
+ ;
+
+ RCC->DCKCFGR2 = RCC_DCKCFGR2_CK48MSEL;
+ }
#endif
}