HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode. (#307)

This commit is contained in:
あく
2021-01-20 10:43:12 +03:00
committed by GitHub
parent c8aca9ef48
commit 6c4983c6b6
5 changed files with 95 additions and 14 deletions

View File

@@ -0,0 +1,27 @@
#include <api-hal-clock.h>
#include <stm32wbxx_ll_rcc.h>
void api_hal_clock_switch_to_hsi() {
LL_RCC_HSI_Enable( );
while(!LL_RCC_HSI_IsReady());
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
LL_RCC_SetSMPSClockSource(LL_RCC_SMPS_CLKSOURCE_HSI);
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI);
}
void api_hal_clock_switch_to_pll() {
LL_RCC_HSE_Enable();
LL_RCC_PLL_Enable();
while(!LL_RCC_HSE_IsReady());
while(!LL_RCC_PLL_IsReady());
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
LL_RCC_SetSMPSClockSource(LL_RCC_SMPS_CLKSOURCE_HSE);
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL);
}