From c2e0afdb057ccf4c6440322a1409ec7b94fe16ea Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Fri, 9 Sep 2016 21:35:18 +0000 Subject: [PATCH] stm32: adc-v2: don't try and disable adc powered off As per ref manual, you're not allowed to attempt to disable the ADC if it's not presently enabled. Fixes github issue #654 --- lib/stm32/common/adc_common_v2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/stm32/common/adc_common_v2.c b/lib/stm32/common/adc_common_v2.c index 6d33388b..62e3881a 100644 --- a/lib/stm32/common/adc_common_v2.c +++ b/lib/stm32/common/adc_common_v2.c @@ -106,6 +106,10 @@ void adc_power_on(uint32_t adc) */ void adc_power_off_async(uint32_t adc) { + if (adc_is_power_off(adc)) { + return; + } + uint32_t checks = ADC_CR_ADSTART; uint32_t stops = ADC_CR_ADSTP; #if defined (ADC_CR_JADSTART)