only:going fancy enums

This commit is contained in:
rusefi 2024-07-22 19:47:57 -04:00
parent 4fd2d21144
commit e2bc1cbade
3 changed files with 14 additions and 14 deletions

View File

@ -29,12 +29,12 @@ static uint32_t slowAdcErrorsCount = 0;
static float mcuTemperature;
static adc_channel_mode_e adcHwChannelMode[EFI_ADC_TOTAL_CHANNELS];
static AdcChannelMode adcHwChannelMode[EFI_ADC_TOTAL_CHANNELS];
// todo: move this flag to Engine god object
static int adcDebugReporting = false;
adc_channel_mode_e getAdcMode(adc_channel_e hwChannel) {
AdcChannelMode getAdcMode(adc_channel_e hwChannel) {
return adcHwChannelMode[hwChannel];
}
@ -49,7 +49,7 @@ int getInternalAdcValue(const char *msg, adc_channel_e hwChannel) {
}
#if EFI_USE_FAST_ADC
if (adcHwChannelMode[hwChannel] == ADC_FAST) {
if (adcHwChannelMode[hwChannel] == AdcChannelMode::Fast) {
return fastAdc.getAvgAdcValue(hwChannel);
}
#endif // EFI_USE_FAST_ADC
@ -151,7 +151,7 @@ void addFastAdcChannel(const char*, adc_channel_e hwChannel) {
fastAdc.enableChannel(hwChannel);
#endif
adcHwChannelMode[hwChannel] = ADC_FAST;
adcHwChannelMode[hwChannel] = AdcChannelMode::Fast;
// Nothing to do for slow channels, input is mapped to analog in init_sensors.cpp
}
@ -160,20 +160,20 @@ void removeChannel(const char*, adc_channel_e hwChannel) {
return;
}
#if EFI_USE_FAST_ADC
if (adcHwChannelMode[hwChannel] == ADC_FAST) {
if (adcHwChannelMode[hwChannel] == AdcChannelMode::Fast) {
/* TODO: */
//fastAdc.disableChannel(hwChannel);
}
#endif
adcHwChannelMode[hwChannel] = ADC_OFF;
adcHwChannelMode[hwChannel] = AdcChannelMode::Off;
}
// Weak link a stub so that every board doesn't have to implement this function
__attribute__((weak)) void setAdcChannelOverrides() { }
static void configureInputs() {
memset(adcHwChannelMode, ADC_OFF, sizeof(adcHwChannelMode));
memset(adcHwChannelMode, (int)AdcChannelMode::Off, sizeof(adcHwChannelMode));
/**
* order of analog channels here is totally random and has no meaning

View File

@ -70,13 +70,13 @@ inline bool isAdcChannelOffChip(adc_channel_e hwChannel) {
#if HAL_USE_ADC
typedef enum {
ADC_OFF = 0,
ADC_SLOW = 1,
ADC_FAST = 2,
} adc_channel_mode_e;
enum class AdcChannelMode : char {
Off,
Slow,
Fast
};
adc_channel_mode_e getAdcMode(adc_channel_e hwChannel);
AdcChannelMode getAdcMode(adc_channel_e hwChannel);
void initAdcInputs();
// wait until at least 1 slowADC sampling is complete

View File

@ -186,7 +186,7 @@ void AdcSubscription::PrintInfo() {
"%s ADC%d m=%d %s adc=%.2f/input=%.2fv/divider=%.2f",
name,
channel,
getAdcMode(channel),
(int)getAdcMode(channel),
getPinNameByAdcChannel(name, channel, pinNameBuffer, sizeof(pinNameBuffer)),
mcuVolts, sensorVolts, entry.VoltsPerAdcVolt
);