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 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 // todo: move this flag to Engine god object
static int adcDebugReporting = false; static int adcDebugReporting = false;
adc_channel_mode_e getAdcMode(adc_channel_e hwChannel) { AdcChannelMode getAdcMode(adc_channel_e hwChannel) {
return adcHwChannelMode[hwChannel]; return adcHwChannelMode[hwChannel];
} }
@ -49,7 +49,7 @@ int getInternalAdcValue(const char *msg, adc_channel_e hwChannel) {
} }
#if EFI_USE_FAST_ADC #if EFI_USE_FAST_ADC
if (adcHwChannelMode[hwChannel] == ADC_FAST) { if (adcHwChannelMode[hwChannel] == AdcChannelMode::Fast) {
return fastAdc.getAvgAdcValue(hwChannel); return fastAdc.getAvgAdcValue(hwChannel);
} }
#endif // EFI_USE_FAST_ADC #endif // EFI_USE_FAST_ADC
@ -151,7 +151,7 @@ void addFastAdcChannel(const char*, adc_channel_e hwChannel) {
fastAdc.enableChannel(hwChannel); fastAdc.enableChannel(hwChannel);
#endif #endif
adcHwChannelMode[hwChannel] = ADC_FAST; adcHwChannelMode[hwChannel] = AdcChannelMode::Fast;
// Nothing to do for slow channels, input is mapped to analog in init_sensors.cpp // 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; return;
} }
#if EFI_USE_FAST_ADC #if EFI_USE_FAST_ADC
if (adcHwChannelMode[hwChannel] == ADC_FAST) { if (adcHwChannelMode[hwChannel] == AdcChannelMode::Fast) {
/* TODO: */ /* TODO: */
//fastAdc.disableChannel(hwChannel); //fastAdc.disableChannel(hwChannel);
} }
#endif #endif
adcHwChannelMode[hwChannel] = ADC_OFF; adcHwChannelMode[hwChannel] = AdcChannelMode::Off;
} }
// Weak link a stub so that every board doesn't have to implement this function // Weak link a stub so that every board doesn't have to implement this function
__attribute__((weak)) void setAdcChannelOverrides() { } __attribute__((weak)) void setAdcChannelOverrides() { }
static void configureInputs() { 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 * 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 #if HAL_USE_ADC
typedef enum { enum class AdcChannelMode : char {
ADC_OFF = 0, Off,
ADC_SLOW = 1, Slow,
ADC_FAST = 2, Fast
} adc_channel_mode_e; };
adc_channel_mode_e getAdcMode(adc_channel_e hwChannel); AdcChannelMode getAdcMode(adc_channel_e hwChannel);
void initAdcInputs(); void initAdcInputs();
// wait until at least 1 slowADC sampling is complete // 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", "%s ADC%d m=%d %s adc=%.2f/input=%.2fv/divider=%.2f",
name, name,
channel, channel,
getAdcMode(channel), (int)getAdcMode(channel),
getPinNameByAdcChannel(name, channel, pinNameBuffer, sizeof(pinNameBuffer)), getPinNameByAdcChannel(name, channel, pinNameBuffer, sizeof(pinNameBuffer)),
mcuVolts, sensorVolts, entry.VoltsPerAdcVolt mcuVolts, sensorVolts, entry.VoltsPerAdcVolt
); );