adc: fix unit tests

This commit is contained in:
Andrey Gusakov 2024-05-05 18:45:25 +03:00 committed by rusefillc
parent 6b265dd4f8
commit 909a17caef
1 changed files with 3 additions and 5 deletions

View File

@ -10,18 +10,16 @@
#include "rusefi_hw_enums.h"
inline bool isAdcChannelValid(adc_channel_e hwChannel) {
if (hwChannel <= EFI_ADC_NONE) {
return false;
} else if (hwChannel >= EFI_ADC_LAST_CHANNEL) {
/* Compiler will optimize, keep following if as a reminder */
if (hwChannel >= EFI_ADC_TOTAL_CHANNELS) {
/* this should not happen!
* if we have enum out of range somewhere in settings
* that means something goes terribly wrong
* TODO: should we say something?
*/
return false;
} else {
return true;
}
return ((hwChannel > EFI_ADC_NONE) && (hwChannel < EFI_ADC_TOTAL_CHANNELS));
}
#define adcToVoltsDivided(adc) (adcToVolts(adc) * engineConfiguration->analogInputDividerCoefficient)