drivers: adc: stm32: Disable ADC before calibration
The STM32 docs state that the ADC may not be calibrated unless the ADC is disabled (ADEN=0). This commit implements this constraint Fixes #40936 Signed-off-by: Pete Dietl <petedietl@gmail.com>
This commit is contained in:
parent
9d71af1e15
commit
bc1b262885
1 changed files with 7 additions and 0 deletions
|
@ -592,7 +592,14 @@ static int start_read(const struct device *dev,
|
||||||
!defined(CONFIG_SOC_SERIES_STM32F1X) && \
|
!defined(CONFIG_SOC_SERIES_STM32F1X) && \
|
||||||
!defined(STM32F3X_ADC_V2_5) && \
|
!defined(STM32F3X_ADC_V2_5) && \
|
||||||
!defined(CONFIG_SOC_SERIES_STM32L1X)
|
!defined(CONFIG_SOC_SERIES_STM32L1X)
|
||||||
|
|
||||||
|
/* we cannot calibrate the ADC while the ADC is enabled */
|
||||||
|
LL_ADC_Disable(adc);
|
||||||
|
while (LL_ADC_IsEnabled(adc) == 1UL) {
|
||||||
|
}
|
||||||
adc_stm32_calib(dev);
|
adc_stm32_calib(dev);
|
||||||
|
/* re-enable ADC after calibration */
|
||||||
|
LL_ADC_Enable(adc);
|
||||||
#else
|
#else
|
||||||
LOG_ERR("Calibration not supported");
|
LOG_ERR("Calibration not supported");
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue