@@ -54,35 +54,31 @@ static PinName g_current_pin = NC;
54
54
/* Private_Defines */
55
55
#ifdef HAL_ADC_MODULE_ENABLED
56
56
57
+ #ifndef ADC_SAMPLINGTIME
57
58
#if defined(ADC_SAMPLETIME_8CYCLES_5 )
58
- #define SAMPLINGTIME ADC_SAMPLETIME_8CYCLES_5;
59
+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_8CYCLES_5;
59
60
#elif defined(ADC_SAMPLETIME_12CYCLES_5 )
60
- #define SAMPLINGTIME ADC_SAMPLETIME_12CYCLES_5;
61
+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_12CYCLES_5;
61
62
#elif defined(ADC_SAMPLETIME_13CYCLES_5 )
62
- #define SAMPLINGTIME ADC_SAMPLETIME_13CYCLES_5;
63
+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_13CYCLES_5;
63
64
#elif defined(ADC_SAMPLETIME_15CYCLES )
64
- #define SAMPLINGTIME ADC_SAMPLETIME_15CYCLES;
65
+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_15CYCLES;
65
66
#elif defined(ADC_SAMPLETIME_16CYCLES )
66
- #define SAMPLINGTIME ADC_SAMPLETIME_16CYCLES;
67
+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_16CYCLES;
67
68
#elif defined(ADC_SAMPLETIME_19CYCLES_5 )
68
- #define SAMPLINGTIME ADC_SAMPLETIME_19CYCLES_5;
69
- #else
70
- #error "ADC SAMPLINGTIME could not be defined"
69
+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_19CYCLES_5;
71
70
#endif
71
+ #endif /* !ADC_SAMPLINGTIME */
72
72
73
- #ifndef STM32F1xx
73
+ #ifndef ADC_CLOCK_DIV
74
74
#ifdef ADC_CLOCK_SYNC_PCLK_DIV4
75
75
#define ADC_CLOCK_DIV ADC_CLOCK_SYNC_PCLK_DIV4
76
76
#elif ADC_CLOCK_SYNC_PCLK_DIV2
77
77
#define ADC_CLOCK_DIV ADC_CLOCK_SYNC_PCLK_DIV2
78
78
#elif defined(ADC_CLOCK_ASYNC_DIV1 )
79
79
#define ADC_CLOCK_DIV ADC_CLOCK_ASYNC_DIV1
80
- #elif defined(ADC_CLOCKPRESCALER_PCLK_DIV2 )
81
- #define ADC_CLOCK_DIV ADC_CLOCKPRESCALER_PCLK_DIV2
82
- #else
83
- #error "ADC_CLOCK_DIV could not be defined"
84
80
#endif
85
- #endif /* STM32F1xx */
81
+ #endif /* !ADC_CLOCK_DIV */
86
82
87
83
#ifndef ADC_REGULAR_RANK_1
88
84
#define ADC_REGULAR_RANK_1 1
@@ -570,16 +566,16 @@ uint16_t adc_read_value(PinName pin)
570
566
#endif
571
567
572
568
#if defined(STM32F0xx )
573
- AdcHandle .Init .SamplingTimeCommon = SAMPLINGTIME ;
569
+ AdcHandle .Init .SamplingTimeCommon = ADC_SAMPLINGTIME ;
574
570
#endif
575
571
#if defined(STM32G0xx )
576
- AdcHandle .Init .SamplingTimeCommon1 = SAMPLINGTIME ; /* Set sampling time common to a group of channels. */
577
- AdcHandle .Init .SamplingTimeCommon2 = SAMPLINGTIME ; /* Set sampling time common to a group of channels, second common setting possible.*/
572
+ AdcHandle .Init .SamplingTimeCommon1 = ADC_SAMPLINGTIME ; /* Set sampling time common to a group of channels. */
573
+ AdcHandle .Init .SamplingTimeCommon2 = ADC_SAMPLINGTIME ; /* Set sampling time common to a group of channels, second common setting possible.*/
578
574
AdcHandle .Init .TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH ;
579
575
#endif
580
576
#if defined(STM32L0xx )
581
577
AdcHandle .Init .LowPowerFrequencyMode = DISABLE ; /* To be enabled only if ADC clock < 2.8 MHz */
582
- AdcHandle .Init .SamplingTime = SAMPLINGTIME ;
578
+ AdcHandle .Init .SamplingTime = ADC_SAMPLINGTIME ;
583
579
#endif
584
580
#if !defined(STM32F0xx ) && !defined(STM32F1xx ) && !defined(STM32F2xx ) && \
585
581
!defined(STM32F3xx ) && !defined(STM32F4xx ) && !defined(STM32F7xx ) && \
@@ -619,7 +615,7 @@ uint16_t adc_read_value(PinName pin)
619
615
AdcChannelConf .Rank = ADC_REGULAR_RANK_1 ; /* Specifies the rank in the regular group sequencer */
620
616
#if !defined(STM32L0xx )
621
617
#if !defined(STM32G0xx )
622
- AdcChannelConf .SamplingTime = SAMPLINGTIME ; /* Sampling time value to be set for the selected channel */
618
+ AdcChannelConf .SamplingTime = ADC_SAMPLINGTIME ; /* Sampling time value to be set for the selected channel */
623
619
#else
624
620
AdcChannelConf .SamplingTime = ADC_SAMPLINGTIME_COMMON_1 ; /* Sampling time value to be set for the selected channel */
625
621
#endif
0 commit comments