@@ -33,6 +33,8 @@ static PinName g_current_pin = NC;
3333#ifndef ADC_SAMPLINGTIME
3434#if defined(ADC_SAMPLETIME_8CYCLES_5)
3535#define ADC_SAMPLINGTIME ADC_SAMPLETIME_8CYCLES_5;
36+ #elif defined(ADC_SAMPLETIME_12CYCLES)
37+ #define ADC_SAMPLINGTIME ADC_SAMPLETIME_12CYCLES;
3638#elif defined(ADC_SAMPLETIME_12CYCLES_5)
3739#define ADC_SAMPLINGTIME ADC_SAMPLETIME_12CYCLES_5;
3840#elif defined(ADC_SAMPLETIME_13CYCLES_5)
@@ -60,6 +62,8 @@ static PinName g_current_pin = NC;
6062#define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_384CYCLES
6163#elif defined(ADC_SAMPLETIME_810CYCLES_5)
6264#define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_810CYCLES_5
65+ #elif defined(ADC_SAMPLETIME_814CYCLES)
66+ #define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_814CYCLES
6367#elif defined(ADC_SAMPLETIME_640CYCLES_5)
6468#define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_640CYCLES_5
6569#elif defined(ADC_SAMPLETIME_601CYCLES_5)
@@ -176,6 +180,7 @@ static uint32_t get_adc_channel(PinName pin, uint32_t *bank)
176180 case 23 :
177181 channel = ADC_CHANNEL_23;
178182 break ;
183+ #ifdef ADC_CHANNEL_24
179184 case 24 :
180185 channel = ADC_CHANNEL_24;
181186 break ;
@@ -202,6 +207,7 @@ static uint32_t get_adc_channel(PinName pin, uint32_t *bank)
202207 channel = ADC_CHANNEL_31;
203208 break ;
204209#endif
210+ #endif
205211#endif
206212 default :
207213 channel = 0 ;
@@ -910,7 +916,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
910916#endif /* STM32L4xx || STM32WBxx */
911917 return 0 ;
912918 }
913- #ifdef ADC_SCAN_SEQ_FIXED
919+ #if defined( ADC_SCAN_SEQ_FIXED) && defined(ADC_RANK_CHANNEL_NUMBER)
914920 AdcChannelConf.Rank = ADC_RANK_CHANNEL_NUMBER; /* Enable the rank of the selected channels when not fully configurable */
915921#else
916922 AdcChannelConf.Rank = ADC_REGULAR_RANK_1; /* Specifies the rank in the regular group sequencer */
@@ -954,7 +960,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
954960#if defined(STM32F0xx) || defined(STM32G0xx) || defined(STM32F1xx) || \
955961 defined (STM32WLxx) || defined (STM32F373xC) || defined (STM32F378xx)
956962 if (HAL_ADCEx_Calibration_Start (&AdcHandle) != HAL_OK)
957- #elif defined (STM32H7xx) || defined(STM32MP1xx)
963+ #elif defined (STM32H7xx) || defined(STM32MP1xx) || defined(STM32U5xx)
958964 if (HAL_ADCEx_Calibration_Start (&AdcHandle, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)
959965#else
960966 if (HAL_ADCEx_Calibration_Start (&AdcHandle, ADC_SINGLE_ENDED) != HAL_OK)
@@ -967,7 +973,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
967973
968974 /* ##-3- Start the conversion process ####################*/
969975 if (HAL_ADC_Start (&AdcHandle) != HAL_OK) {
970- /* Start Conversation Error */
976+ /* Start Conversion Error */
971977 return 0 ;
972978 }
973979
0 commit comments