Skip to content

Commit

Permalink
stm32/adc: Fix L4 ADC channel numbers.
Browse files Browse the repository at this point in the history
Use HAL macro to map decimal numbers to channel numbers.  This is needed
since updating L4 HAL v1.17.0 in a0f5b31.

Fixes issue #8233.
  • Loading branch information
iabdalkader authored and dpgeorge committed Feb 3, 2022
1 parent ae5f647 commit e5df4a9
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions ports/stm32/adc.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e5df4a9

Please sign in to comment.