From 3c7b2771b106a6870ca6b5045f7704f07e0b51c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Thu, 18 Jun 2020 15:46:33 +0200 Subject: [PATCH] drivers: adc: stm32: Fix sequence configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The STM32 driver currently does not support reading a sequence of multiple ADC channels. Only the first channel of the sequence was read and the rest was silently ignored. Fix: Return an error if reading multiple channels is requested. Signed-off-by: Martin Jäger --- drivers/adc/adc_stm32.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/adc/adc_stm32.c b/drivers/adc/adc_stm32.c index 6ef21db2dcf..9fc96bd9c66 100644 --- a/drivers/adc/adc_stm32.c +++ b/drivers/adc/adc_stm32.c @@ -319,6 +319,10 @@ static int start_read(const struct device *dev, } uint32_t channels = sequence->channels; + if (channels > find_lsb_set(channels)) { + LOG_ERR("Only single channel supported"); + return -ENOTSUP; + } data->buffer = sequence->buffer; uint8_t index;