stm32/adc: Fix reading internal ADC channels on L4 MCUs.

For STM32L4 series, the internal sensors are connected to:
- ADC1_IN0: Internal voltage reference
- ADC1_IN17: Temperature sensor
- ADC1_IN18: VBAT battery voltage monitoring
but ADC_CHANNEL_VREFINT, ADC_CHANNEL_VBAT, ADC_CHANNEL_TEMPSENSOR are not
defined as 0, 17, 18.

This commit converts channel 0, 17, 18 to ADC_CHANNEL_x in
adc_get_internal_channel().
pull/9999/head
yn386 2022-10-22 16:56:56 +09:00 zatwierdzone przez Damien George
rodzic a74e4fabeb
commit 2154ee2163
1 zmienionych plików z 8 dodań i 0 usunięć

Wyświetl plik

@ -216,6 +216,14 @@ static inline uint32_t adc_get_internal_channel(uint32_t channel) {
if (channel == 16) {
channel = ADC_CHANNEL_TEMPSENSOR;
}
#elif defined(STM32L4)
if (channel == 0) {
channel = ADC_CHANNEL_VREFINT;
} else if (channel == 17) {
channel = ADC_CHANNEL_TEMPSENSOR;
} else if (channel == 18) {
channel = ADC_CHANNEL_VBAT;
}
#endif
return channel;
}