X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm32f1%2Fao_clock.c;h=899923dc5cfc0f501db1a554f774e4071b7b1b41;hb=ff21e293ee8185b19a30df74ca7a1610625ef465;hp=3fcf33b81177da379087fdbd72c315b83a95162f;hpb=cea7122fc1843b14a179ed9311677f69c10b38eb;p=fw%2Faltos diff --git a/src/stm32f1/ao_clock.c b/src/stm32f1/ao_clock.c index 3fcf33b8..899923dc 100644 --- a/src/stm32f1/ao_clock.c +++ b/src/stm32f1/ao_clock.c @@ -118,6 +118,12 @@ ao_clock_init(void) cfgr |= (AO_RCC_CFGR_PPRE2_DIV << STM_RCC_CFGR_PPRE2); stm_rcc.cfgr = cfgr; + /* ADC Prescaler */ + cfgr = stm_rcc.cfgr; + cfgr &= ~(STM_RCC_CFGR_ADCPRE_MASK << STM_RCC_CFGR_ADCPRE); + cfgr |= (AO_RCC_CFGR_ADCPRE << STM_RCC_CFGR_ADCPRE); + stm_rcc.cfgr = cfgr; + /* Disable the PLL */ stm_rcc.cr &= ~(1UL << STM_RCC_CR_PLLON); while (stm_rcc.cr & (1UL << STM_RCC_CR_PLLRDY)) @@ -175,6 +181,13 @@ ao_clock_init(void) /* Clear reset flags */ stm_rcc.csr |= (1 << STM_RCC_CSR_RMVF); + /* Enable AFIO */ + stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_AFIOEN); + + /* Release PB3, PA15 and PB4 from JTAG use */ + stm_afio.mapr = (stm_afio.mapr & + ~(STM_AFIO_MAPR_SWJ_CFG_MASK << STM_AFIO_MAPR_SWJ_CFG)) | + STM_AFIO_MAPR_SWJ_CFG_SW_DP << STM_AFIO_MAPR_SWJ_CFG; #if DEBUG_THE_CLOCK /* Output SYSCLK on PA8 for measurments */