@@ -54,35 +54,31 @@ static PinName g_current_pin = NC;
5454/* Private_Defines */
5555#ifdef HAL_ADC_MODULE_ENABLED
5656
57+ #ifndef ADC_SAMPLINGTIME
5758#if defined(ADC_SAMPLETIME_8CYCLES_5 )
58- #define SAMPLINGTIME ADC_SAMPLETIME_8CYCLES_5;
59+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_8CYCLES_5;
5960#elif defined(ADC_SAMPLETIME_12CYCLES_5 )
60- #define SAMPLINGTIME ADC_SAMPLETIME_12CYCLES_5;
61+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_12CYCLES_5;
6162#elif defined(ADC_SAMPLETIME_13CYCLES_5 )
62- #define SAMPLINGTIME ADC_SAMPLETIME_13CYCLES_5;
63+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_13CYCLES_5;
6364#elif defined(ADC_SAMPLETIME_15CYCLES )
64- #define SAMPLINGTIME ADC_SAMPLETIME_15CYCLES;
65+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_15CYCLES;
6566#elif defined(ADC_SAMPLETIME_16CYCLES )
66- #define SAMPLINGTIME ADC_SAMPLETIME_16CYCLES;
67+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_16CYCLES;
6768#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;
7170#endif
71+ #endif /* !ADC_SAMPLINGTIME */
7272
73- #ifndef STM32F1xx
73+ #ifndef ADC_CLOCK_DIV
7474#ifdef ADC_CLOCK_SYNC_PCLK_DIV4
7575#define ADC_CLOCK_DIV ADC_CLOCK_SYNC_PCLK_DIV4
7676#elif ADC_CLOCK_SYNC_PCLK_DIV2
7777#define ADC_CLOCK_DIV ADC_CLOCK_SYNC_PCLK_DIV2
7878#elif defined(ADC_CLOCK_ASYNC_DIV1 )
7979#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"
8480#endif
85- #endif /* STM32F1xx */
81+ #endif /* !ADC_CLOCK_DIV */
8682
8783#ifndef ADC_REGULAR_RANK_1
8884#define ADC_REGULAR_RANK_1 1
@@ -570,16 +566,16 @@ uint16_t adc_read_value(PinName pin)
570566#endif
571567
572568#if defined(STM32F0xx )
573- AdcHandle .Init .SamplingTimeCommon = SAMPLINGTIME ;
569+ AdcHandle .Init .SamplingTimeCommon = ADC_SAMPLINGTIME ;
574570#endif
575571#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.*/
578574 AdcHandle .Init .TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH ;
579575#endif
580576#if defined(STM32L0xx )
581577 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 ;
583579#endif
584580#if !defined(STM32F0xx ) && !defined(STM32F1xx ) && !defined(STM32F2xx ) && \
585581 !defined(STM32F3xx ) && !defined(STM32F4xx ) && !defined(STM32F7xx ) && \
@@ -619,7 +615,7 @@ uint16_t adc_read_value(PinName pin)
619615 AdcChannelConf .Rank = ADC_REGULAR_RANK_1 ; /* Specifies the rank in the regular group sequencer */
620616#if !defined(STM32L0xx )
621617#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 */
623619#else
624620 AdcChannelConf .SamplingTime = ADC_SAMPLINGTIME_COMMON_1 ; /* Sampling time value to be set for the selected channel */
625621#endif
0 commit comments