2021-05-18 09:23:14 +00:00
|
|
|
#include <api-hal-clock.h>
|
|
|
|
|
|
|
|
#include <stm32wbxx_ll_rcc.h>
|
|
|
|
|
2021-07-15 13:54:11 +00:00
|
|
|
void api_hal_clock_init() {
|
|
|
|
// AHB
|
|
|
|
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMAMUX1);
|
|
|
|
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1);
|
|
|
|
|
|
|
|
// APB
|
|
|
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
|
|
|
|
}
|
|
|
|
|
2021-05-18 09:23:14 +00:00
|
|
|
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);
|
|
|
|
}
|