enabled external clock + implemented some weird operating modes using the rotary encoder
This commit is contained in:
@@ -64,11 +64,18 @@ static void __init_default_clocks(void)
|
||||
void __setup_clocks(void)
|
||||
{
|
||||
uint32_t tmp;
|
||||
|
||||
/* TODO: Switch HSE on for better accuracy */
|
||||
|
||||
/* Switch PLL source to HSI OSC */
|
||||
RCC->CFGR &= ~RCC_CFGR_PLLSRC;
|
||||
/* Switch PLL source to HSE OSC */
|
||||
RCC->CFGR |= RCC_CFGR_PLLSRC;
|
||||
|
||||
/* Divide HSE by 2 to match HSI */
|
||||
RCC->CFGR2 = 0x00000001;
|
||||
|
||||
/* Enable HSE and wait for it to become ready */
|
||||
RCC->CR |= RCC_CR_HSEON;
|
||||
|
||||
/* Wait for HSE to be ready */
|
||||
while (!(RCC->CR & RCC_CR_HSERDY));
|
||||
|
||||
/* Set PLL multiplication to 12 (4 MHz * 12 = 48 MHz SysClk) */
|
||||
RCC->CFGR |= RCC_CFGR_PLLMUL_3 | RCC_CFGR_PLLMUL_1;
|
||||
@@ -84,6 +91,9 @@ void __setup_clocks(void)
|
||||
tmp &= ~0x3;
|
||||
tmp |= RCC_CFGR_SW_1;
|
||||
RCC->CFGR = tmp;
|
||||
|
||||
/* Turn off HSI */
|
||||
RCC->CR &= ~RCC_CR_HSEON;
|
||||
}
|
||||
|
||||
void __system_init(void)
|
||||
|
Reference in New Issue
Block a user