diff options
| author | Damien George <damien@micropython.org> | 2021-02-22 11:55:12 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-02-04 09:43:43 +1100 |
| commit | e0a0719416d6a936ade8c30314b7e9c90bfbbf23 (patch) | |
| tree | 664c121740ea58d5ff38081f7321a022838d54a8 /ports/stm32/powerctrlboot.c | |
| parent | 9127e6370819b32552caedd0184f206e1b9c9285 (diff) | |
stm32: Add initial support for STM32WL MCUs.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/stm32/powerctrlboot.c')
| -rw-r--r-- | ports/stm32/powerctrlboot.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ports/stm32/powerctrlboot.c b/ports/stm32/powerctrlboot.c index 41b56296e..4ecd83e2c 100644 --- a/ports/stm32/powerctrlboot.c +++ b/ports/stm32/powerctrlboot.c @@ -212,4 +212,41 @@ void SystemClock_Config(void) { powerctrl_config_systick(); } +#elif defined(STM32WL) + +#include "stm32wlxx_ll_utils.h" + +void SystemClock_Config(void) { + // Set flash latency + LL_FLASH_SetLatency(LL_FLASH_LATENCY_2); + while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_2) { + } + + LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); + + // Enable MSI + LL_RCC_MSI_Enable(); + while (!LL_RCC_MSI_IsReady()) { + } + + // Configure MSI + LL_RCC_MSI_EnableRangeSelection(); + LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_11); + LL_RCC_MSI_SetCalibTrimming(0); + + // Select SYSCLK source + LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_MSI); + while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_MSI) { + } + + // Set bus dividers + LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); + LL_RCC_SetAHB3Prescaler(LL_RCC_SYSCLK_DIV_1); + LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); + LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); + + SystemCoreClockUpdate(); + powerctrl_config_systick(); +} + #endif |
