void adc_config(void) { LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1); /* ADC might be in deep sleep, needs to be woken up twice in that case */ LL_ADC_Enable(ADC1); LL_mDelay(1); LL_ADC_Enable(ADC1); LL_mDelay(1); LL_ADC_StartCalibration(ADC1); while (LL_ADC_IsCalibrationOnGoing(ADC1)); LL_ADC_SetSequencersScanMode(ADC1, LL_ADC_SEQ_SCAN_DISABLE); LL_ADC_REG_SetTriggerSource(ADC1, LL_ADC_REG_TRIG_SOFTWARE); LL_ADC_REG_SetSequencerLength(ADC1, LL_ADC_REG_SEQ_SCAN_DISABLE); }
static void adc_stm32_calib(struct device *dev) { struct adc_stm32_cfg *config = (struct adc_stm32_cfg *)dev->config->config_info; ADC_TypeDef *adc = config->base; #if defined(CONFIG_SOC_SERIES_STM32F3X) || \ defined(CONFIG_SOC_SERIES_STM32L4X) LL_ADC_StartCalibration(adc, LL_ADC_SINGLE_ENDED); #elif defined(CONFIG_SOC_SERIES_STM32F0X) || \ defined(CONFIG_SOC_SERIES_STM32L0X) LL_ADC_StartCalibration(adc); #endif while (LL_ADC_IsCalibrationOnGoing(adc)) ; }