ADC: debug function valid input check

This commit is contained in:
Andrey Gusakov 2024-05-09 23:00:59 +03:00
parent f8817a8574
commit b1f7492b35
1 changed files with 6 additions and 1 deletions

View File

@ -293,9 +293,14 @@ FastAdcToken AdcDevice::getAdcChannelToken(adc_channel_e hwChannel) {
#endif // EFI_USE_FAST_ADC
static void printAdcValue(int channel) {
/* Do this check before conversion to adc_channel_e that is uint8_t based */
if ((channel < EFI_ADC_NONE) || (channel >= EFI_ADC_TOTAL_CHANNELS)) {
efiPrintf("Invalid ADC channel %d", channel);
return;
}
int value = getAdcValue("print", (adc_channel_e)channel);
float volts = adcToVoltsDivided(value, (adc_channel_e)channel);
efiPrintf("adc voltage : %.2f", volts);
efiPrintf("adc %d voltage : %.3f", channel, volts);
}
static uint32_t slowAdcConversionCount = 0;