From 009d14fc3e2f485a8f07d70afc66f17659d2068f Mon Sep 17 00:00:00 2001 From: clearchris Date: Tue, 5 Nov 2019 09:08:32 -0600 Subject: stm32: adc for new stm32f0 common code (#2120) Derived from stm32/adc.c and stm32f0/adc.c with additional changes. Tested on Monoprice Mini Delta (malyan) stm32f070xb board. Signed-off-by: Chris Lombardi --- src/stm32/stm32f0.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/stm32/stm32f0.c') diff --git a/src/stm32/stm32f0.c b/src/stm32/stm32f0.c index 26a3512c..f9eabeab 100644 --- a/src/stm32/stm32f0.c +++ b/src/stm32/stm32f0.c @@ -156,6 +156,16 @@ hsi48_setup(void) #endif } +// Enable high speed internal 14Mhz clock for ADC +static void +hsi14_setup(void) +{ + // Enable HSI14 for ADC + RCC->CR2 = RCC_CR2_HSI14ON; + while (!(RCC->CR2 & RCC_CR2_HSI14RDY)) + ; +} + // Main entry point - called from armcm_boot.c:ResetHandler() void armcm_main(void) @@ -179,6 +189,9 @@ armcm_main(void) else pll_setup(); + // Turn on hsi14 oscillator for ADC + hsi14_setup(); + // Support alternate USB pins on stm32f042 #ifdef SYSCFG_CFGR1_PA11_PA12_RMP if (CONFIG_STM32F042_USB_PIN_SWAP) { -- cgit v1.2.3-70-g09d2