From 01320881e7da131045050105086a6f40f453ae87 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Thu, 25 Jan 2018 12:34:03 +0000 Subject: [PATCH] stm32: adc-v2: don't attempt to wait for start. The ADC v2 peripheral doesn't have the same behaviour of starting, where the hardware clears the bit immediately, on v2, it is not cleared until the ADC is stopped, or the end of sequence flag is set. Fixes https://github.com/libopencm3/libopencm3/issues/557 --- lib/stm32/common/adc_common_v2.c | 9 ++++----- lib/stm32/f3/adc.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/stm32/common/adc_common_v2.c b/lib/stm32/common/adc_common_v2.c index dda7aa0c..f8de332d 100644 --- a/lib/stm32/common/adc_common_v2.c +++ b/lib/stm32/common/adc_common_v2.c @@ -375,8 +375,10 @@ void adc_disable_vrefint(void) /** @brief ADC Software Triggered Conversion on Regular Channels * - * This starts conversion on a set of defined regular channels. It is cleared - * by hardware once conversion starts. + * This starts conversion on a set of defined regular channels. + * Depending on the configuration bits EXTEN, a conversion will start + * immediately (software trigger configuration) or once a regular hardware + * trigger event occurs (hardware trigger configuration) * * @param[in] adc ADC block register address base @ref adc_reg_base */ @@ -384,9 +386,6 @@ void adc_start_conversion_regular(uint32_t adc) { /* Start conversion on regular channels. */ ADC_CR(adc) |= ADC_CR_ADSTART; - - /* Wait until the ADC starts the conversion. */ - while (ADC_CR(adc) & ADC_CR_ADSTART); } /**@}*/ diff --git a/lib/stm32/f3/adc.c b/lib/stm32/f3/adc.c index 5715935c..8d6e2e7f 100644 --- a/lib/stm32/f3/adc.c +++ b/lib/stm32/f3/adc.c @@ -401,8 +401,10 @@ void adc_disable_eos_interrupt(uint32_t adc) /*---------------------------------------------------------------------------*/ /** @brief ADC Software Triggered Conversion on Injected Channels * - * This starts conversion on a set of defined injected channels. It is cleared - * by hardware once conversion starts. + * This starts conversion on a set of defined injected channels. + * Depending on the configuration bits JEXTEN, a conversion will start + * immediately (software trigger configuration) or once an injected hardware + * trigger event occurs (hardware trigger configuration). * * @param[in] adc Unsigned int32. ADC block register address base @ref * adc_reg_base @@ -412,9 +414,6 @@ void adc_start_conversion_injected(uint32_t adc) { /* Start conversion on injected channels. */ ADC_CR(adc) |= ADC_CR_JADSTART; - - /* Wait until the ADC starts the conversion. */ - while (ADC_CR(adc) & ADC_CR_JADSTART); }