drivers: adc: stm32 adc disable causing endless loop
Setting Oversampling also applies on stm32L5 but disabling the ADC will cause endless loop except for the stm32L0 serie. Errata applies only on stm32G0 soc series when writing ADC_CFGR1 register. Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
parent
e40998a4e4
commit
acad37196d
1 changed files with 11 additions and 16 deletions
|
@ -409,18 +409,10 @@ static int start_read(const struct device *dev,
|
|||
return err;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_STM32G0X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32G4X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32H7X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32L0X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32L4X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32L5X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WBX) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WLX)
|
||||
#if defined(CONFIG_SOC_SERIES_STM32G0X)
|
||||
/*
|
||||
* Errata: Writing ADC_CFGR1 register while ADEN bit is set
|
||||
* resets RES[1:0] bitfield. We need to disable and enable adc.
|
||||
* On all those stm32 devices it is allowed to write these bits only when ADEN = 0.
|
||||
*/
|
||||
if (LL_ADC_IsEnabled(adc) == 1UL) {
|
||||
LL_ADC_Disable(adc);
|
||||
|
@ -436,6 +428,15 @@ static int start_read(const struct device *dev,
|
|||
LL_ADC_SetResolution(adc, resolution);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SOC_SERIES_STM32L0X
|
||||
/*
|
||||
* setting OVS bits is conditioned to ADC state: ADC must be disabled
|
||||
* or enabled without conversion on going : disable it, it will stop
|
||||
*/
|
||||
LL_ADC_Disable(adc);
|
||||
while (LL_ADC_IsEnabled(adc) == 1UL) {
|
||||
}
|
||||
#endif /* CONFIG_SOC_SERIES_STM32L0X */
|
||||
#if defined(CONFIG_SOC_SERIES_STM32G0X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32G4X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32H7X) || \
|
||||
|
@ -444,13 +445,7 @@ static int start_read(const struct device *dev,
|
|||
defined(CONFIG_SOC_SERIES_STM32L5X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WBX) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WLX)
|
||||
/*
|
||||
* setting OVS bits is conditioned to ADC state: ADC must be disabled
|
||||
* or enabled without conversion on going : disable it, it will stop
|
||||
*/
|
||||
LL_ADC_Disable(adc);
|
||||
while (LL_ADC_IsEnabled(adc) == 1UL) {
|
||||
}
|
||||
|
||||
switch (sequence->oversampling) {
|
||||
case 0:
|
||||
LL_ADC_SetOverSamplingScope(adc, LL_ADC_OVS_DISABLE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue