stm32/adc: Fix L4 ADC channel numbers.

Use HAL macro to map decimal numbers to channel numbers.  This is needed
since updating L4 HAL v1.17.0 in a0f5b3148a.

Fixes issue #8233.
This commit is contained in:
iabdalkader 2022-01-31 19:12:48 +02:00 committed by Damien George
parent ae5f647a2d
commit e5df4a96fa
1 changed files with 2 additions and 6 deletions

View File

@ -214,11 +214,7 @@ STATIC bool is_adcx_channel(int channel) {
#elif defined(STM32H7)
return __HAL_ADC_IS_CHANNEL_INTERNAL(channel)
|| IS_ADC_CHANNEL(__HAL_ADC_DECIMAL_NB_TO_CHANNEL(channel));
#elif defined(STM32L4)
ADC_HandleTypeDef handle;
handle.Instance = ADCx;
return IS_ADC_CHANNEL(&handle, channel);
#elif defined(STM32G4) || defined(STM32WB)
#elif defined(STM32G4) || defined(STM32L4) || defined(STM32WB)
ADC_HandleTypeDef handle;
handle.Instance = ADCx;
return __HAL_ADC_IS_CHANNEL_INTERNAL(channel)
@ -338,7 +334,7 @@ STATIC void adc_init_single(pyb_obj_adc_t *adc_obj) {
STATIC void adc_config_channel(ADC_HandleTypeDef *adc_handle, uint32_t channel) {
ADC_ChannelConfTypeDef sConfig;
#if defined(STM32G4) || defined(STM32H7) || defined(STM32WB)
#if defined(STM32G4) || defined(STM32H7) || defined(STM32L4) || defined(STM32WB)
sConfig.Rank = ADC_REGULAR_RANK_1;
if (__HAL_ADC_IS_CHANNEL_INTERNAL(channel) == 0) {
channel = __HAL_ADC_DECIMAL_NB_TO_CHANNEL(channel);