From 373f7c5096b2d8486458ebf64e70686575ec71be Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Wed, 6 Dec 2017 15:06:40 +0100 Subject: [PATCH] Fixed ADC read value Fix #168 Last STM32L4xx HAL Drivers update change ADC init (using LL). Some ADC_ChannelConfTypeDef fields were missing. Mainly SingleDiff. Signed-off-by: Frederic.Pillon --- cores/arduino/stm32/analog.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cores/arduino/stm32/analog.c b/cores/arduino/stm32/analog.c index 82b10ce550..3fc76384ca 100644 --- a/cores/arduino/stm32/analog.c +++ b/cores/arduino/stm32/analog.c @@ -606,6 +606,11 @@ uint16_t adc_read_value(PinName pin) AdcChannelConf.Rank = ADC_REGULAR_RANK_1; /* Specifies the rank in the regular group sequencer */ #ifndef STM32L0xx AdcChannelConf.SamplingTime = SAMPLINGTIME; /* Sampling time value to be set for the selected channel */ +#endif +#if defined (STM32F3xx) || defined (STM32L4xx) + AdcChannelConf.SingleDiff = ADC_SINGLE_ENDED; /* Single-ended input channel */ + AdcChannelConf.OffsetNumber = ADC_OFFSET_NONE; /* No offset subtraction */ + AdcChannelConf.Offset = 0; /* Parameter discarded because offset correction is disabled */ #endif /*##-2- Configure ADC regular channel ######################################*/ if (HAL_ADC_ConfigChannel(&AdcHandle, &AdcChannelConf) != HAL_OK)