@@ -822,7 +822,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
822
822
AdcHandle.Init .EOCSelection = ADC_EOC_SINGLE_CONV; /* EOC flag picked-up to indicate conversion end */
823
823
#endif
824
824
#if !defined(STM32F1xx) && !defined(STM32F2xx) && !defined(STM32F4xx) && \
825
- !defined (STM32F7xx) && !defined (STM32F373xC) && ! defined (STM32F378xx )
825
+ !defined (STM32F7xx) && !defined (ADC1_V2_5 )
826
826
AdcHandle.Init .LowPowerAutoWait = DISABLE; /* Auto-delayed conversion feature disabled */
827
827
#endif
828
828
#if !defined(STM32F1xx) && !defined(STM32F2xx) && !defined(STM32F3xx) && \
@@ -846,11 +846,11 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
846
846
AdcHandle.Init .NbrOfDiscConversion = 0 ; /* Parameter discarded because sequencer is disabled */
847
847
#endif
848
848
AdcHandle.Init .ExternalTrigConv = ADC_SOFTWARE_START; /* Software start to trig the 1st conversion manually, without external event */
849
- #if !defined(STM32F1xx) && !defined(STM32F373xC) && !defined(STM32F378xx )
849
+ #if !defined(STM32F1xx) && !defined(ADC1_V2_5 )
850
850
AdcHandle.Init .ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; /* Parameter discarded because software trigger chosen */
851
851
#endif
852
852
#if !defined(STM32F1xx) && !defined(STM32H7xx) && !defined(STM32MP1xx) && \
853
- !defined (STM32F373xC) && ! defined (STM32F378xx )
853
+ !defined (ADC1_V2_5 )
854
854
AdcHandle.Init .DMAContinuousRequests = DISABLE; /* DMA one-shot mode selected (not applied to this example) */
855
855
#endif
856
856
#ifdef ADC_CONVERSIONDATA_DR
@@ -901,13 +901,12 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
901
901
902
902
AdcChannelConf.Channel = channel; /* Specifies the channel to configure into ADC */
903
903
904
- #if defined(STM32L4xx) || defined(STM32L5xx) || defined(STM32WBxx)
905
- if (!IS_ADC_CHANNEL (&AdcHandle, AdcChannelConf.Channel )) {
906
- #elif defined(STM32G4xx)
904
+ #if defined(STM32G4xx) || defined(STM32L4xx) || defined(STM32L5xx) || \
905
+ defined (STM32WBxx)
907
906
if (!IS_ADC_CHANNEL (&AdcHandle, AdcChannelConf.Channel )) {
908
907
#else
909
908
if (!IS_ADC_CHANNEL (AdcChannelConf.Channel )) {
910
- #endif /* STM32L4xx || STM32WBxx */
909
+ #endif
911
910
return 0 ;
912
911
}
913
912
#ifdef ADC_SCAN_SEQ_FIXED
@@ -922,17 +921,14 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
922
921
AdcChannelConf.SamplingTime = ADC_SAMPLINGTIME_COMMON_1; /* Sampling time value to be set for the selected channel */
923
922
#endif
924
923
#endif
925
- #if !defined(STM32F0xx) && !defined(STM32F1xx) && !defined(STM32F2xx) && \
926
- !defined (STM32F4xx) && !defined (STM32F7xx) && !defined (STM32G0xx) && \
927
- !defined (STM32L0xx) && !defined (STM32L1xx) && !defined (STM32WLxx) && \
928
- !defined (STM32F373xC) && !defined (STM32F378xx)
924
+ #if defined(ADC_DIFFERENTIAL_ENDED) && !defined(ADC1_V2_5)
929
925
AdcChannelConf.SingleDiff = ADC_SINGLE_ENDED; /* Single-ended input channel */
930
926
AdcChannelConf.OffsetNumber = ADC_OFFSET_NONE; /* No offset subtraction */
931
927
#endif
932
928
#if !defined(STM32F0xx) && !defined(STM32F1xx) && !defined(STM32F2xx) && \
933
929
!defined (STM32G0xx) && !defined (STM32L0xx) && !defined (STM32L1xx) && \
934
930
!defined (STM32WBxx) && !defined (STM32WLxx) && \
935
- !defined (STM32F373xC) && ! defined (STM32F378xx )
931
+ !defined (ADC1_V2_5 )
936
932
AdcChannelConf.Offset = 0 ; /* Parameter discarded because offset correction is disabled */
937
933
#endif
938
934
#if defined (STM32H7xx) || defined(STM32MP1xx)
@@ -946,18 +942,14 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
946
942
return 0 ;
947
943
}
948
944
949
- #if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F3xx) || \
950
- defined (STM32G0xx) || defined (STM32G4xx) || defined (STM32H7xx) || \
951
- defined (STM32L0xx) || defined (STM32L4xx) || defined (STM32MP1xx) || \
952
- defined (STM32WBxx) || defined (STM32WLxx)
945
+ #if defined(ADC_CR_ADCAL) || defined(ADC_CR2_RSTCAL)
953
946
/* ##-2.1- Calibrate ADC then Start the conversion process ####################*/
954
- #if defined(STM32F0xx) || defined(STM32G0xx) || defined(STM32F1xx) || \
955
- defined (STM32WLxx) || defined (STM32F373xC) || defined (STM32F378xx)
956
- if (HAL_ADCEx_Calibration_Start (&AdcHandle) != HAL_OK)
957
- #elif defined (STM32H7xx) || defined(STM32MP1xx)
947
+ #if defined(ADC_CALIB_OFFSET)
958
948
if (HAL_ADCEx_Calibration_Start (&AdcHandle, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)
959
- #else
949
+ #elif defined(ADC_SINGLE_ENDED) && !defined(ADC1_V2_5)
960
950
if (HAL_ADCEx_Calibration_Start (&AdcHandle, ADC_SINGLE_ENDED) != HAL_OK)
951
+ #else
952
+ if (HAL_ADCEx_Calibration_Start (&AdcHandle) != HAL_OK)
961
953
#endif
962
954
{
963
955
/* ADC Calibration Error */
0 commit comments