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

For STM32G4 series, the internal sensors are connected to:
- ADC1_IN16: Temperature sensor
- ADC1_IN17: Battery voltage monitoring
- ADC1_IN18: Internal voltage reference
but ADC_CHANNEL_TEMPSENSOR_ADC1, ADC_CHANNEL_VBAT,
ADC_CHANNEL_VREFINT are not defined as 16, 17, 18.

This commit converts channel 16, 17, 18 to ADC_CHANNEL_x in
adc_get_internal_channel().

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
This commit is contained in:
Yuuki NAGAO 2023-07-08 11:04:20 +09:00 committed by Damien George
parent 0ba94a67ba
commit d9764ad140

View File

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