Skip to content

Commit 91ee6c5

Browse files
committed
bsp: analog: use register definition instead of serie name
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 974b356 commit 91ee6c5

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

Diff for: libraries/SrcWrapper/src/stm32/analog.cpp

+13-21
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
822822
AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV; /* EOC flag picked-up to indicate conversion end */
823823
#endif
824824
#if !defined(STM32F1xx) && !defined(STM32F2xx) && !defined(STM32F4xx) && \
825-
!defined(STM32F7xx) && !defined(STM32F373xC) && !defined(STM32F378xx)
825+
!defined(STM32F7xx) && !defined(ADC1_V2_5)
826826
AdcHandle.Init.LowPowerAutoWait = DISABLE; /* Auto-delayed conversion feature disabled */
827827
#endif
828828
#if !defined(STM32F1xx) && !defined(STM32F2xx) && !defined(STM32F3xx) && \
@@ -846,11 +846,11 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
846846
AdcHandle.Init.NbrOfDiscConversion = 0; /* Parameter discarded because sequencer is disabled */
847847
#endif
848848
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)
850850
AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; /* Parameter discarded because software trigger chosen */
851851
#endif
852852
#if !defined(STM32F1xx) && !defined(STM32H7xx) && !defined(STM32MP1xx) && \
853-
!defined(STM32F373xC) && !defined(STM32F378xx)
853+
!defined(ADC1_V2_5)
854854
AdcHandle.Init.DMAContinuousRequests = DISABLE; /* DMA one-shot mode selected (not applied to this example) */
855855
#endif
856856
#ifdef ADC_CONVERSIONDATA_DR
@@ -901,13 +901,12 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
901901

902902
AdcChannelConf.Channel = channel; /* Specifies the channel to configure into ADC */
903903

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)
907906
if (!IS_ADC_CHANNEL(&AdcHandle, AdcChannelConf.Channel)) {
908907
#else
909908
if (!IS_ADC_CHANNEL(AdcChannelConf.Channel)) {
910-
#endif /* STM32L4xx || STM32WBxx */
909+
#endif
911910
return 0;
912911
}
913912
#ifdef ADC_SCAN_SEQ_FIXED
@@ -922,17 +921,14 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
922921
AdcChannelConf.SamplingTime = ADC_SAMPLINGTIME_COMMON_1; /* Sampling time value to be set for the selected channel */
923922
#endif
924923
#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)
929925
AdcChannelConf.SingleDiff = ADC_SINGLE_ENDED; /* Single-ended input channel */
930926
AdcChannelConf.OffsetNumber = ADC_OFFSET_NONE; /* No offset subtraction */
931927
#endif
932928
#if !defined(STM32F0xx) && !defined(STM32F1xx) && !defined(STM32F2xx) && \
933929
!defined(STM32G0xx) && !defined(STM32L0xx) && !defined(STM32L1xx) && \
934930
!defined(STM32WBxx) && !defined(STM32WLxx) && \
935-
!defined(STM32F373xC) && !defined(STM32F378xx)
931+
!defined(ADC1_V2_5)
936932
AdcChannelConf.Offset = 0; /* Parameter discarded because offset correction is disabled */
937933
#endif
938934
#if defined (STM32H7xx) || defined(STM32MP1xx)
@@ -946,18 +942,14 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
946942
return 0;
947943
}
948944

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)
953946
/*##-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)
958948
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)
960950
if (HAL_ADCEx_Calibration_Start(&AdcHandle, ADC_SINGLE_ENDED) != HAL_OK)
951+
#else
952+
if (HAL_ADCEx_Calibration_Start(&AdcHandle) != HAL_OK)
961953
#endif
962954
{
963955
/* ADC Calibration Error */

0 commit comments

Comments
 (0)