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().
This commit is contained in:
parent
a74e4fabeb
commit
2154ee2163
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user