diff --git a/firmware/config/boards/cypress/config/controllers/algo/engine_configuration_generated_structures.h b/firmware/config/boards/cypress/config/controllers/algo/engine_configuration_generated_structures.h index 091b950f01..9715486375 100644 --- a/firmware/config/boards/cypress/config/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/config/boards/cypress/config/controllers/algo/engine_configuration_generated_structures.h @@ -2374,7 +2374,7 @@ struct engine_configuration_s { /** * offset 1200 */ - etb_function_e etbFunctions[ETB_COUNT]; + dc_function_e etbFunctions[ETB_COUNT]; /** * offset 1202 */ diff --git a/firmware/config/boards/cypress/config/controllers/algo/rusefi_generated.h b/firmware/config/boards/cypress/config/controllers/algo/rusefi_generated.h index 648d722518..89bf7d5821 100644 --- a/firmware/config/boards/cypress/config/controllers/algo/rusefi_generated.h +++ b/firmware/config/boards/cypress/config/controllers/algo/rusefi_generated.h @@ -387,12 +387,12 @@ #define ERROR_BUFFER_SIZE 120 #define ETB_BIAS_CURVE_LENGTH 8 #define ETB_COUNT 2 -#define etb_function_e_auto_enum 0="ETB_None",3="ETB_IdleValve",1="ETB_Throttle1",2="ETB_Throttle2",4="ETB_Wastegate" -#define etb_function_e_ETB_IdleValve 3 -#define etb_function_e_ETB_None 0 -#define etb_function_e_ETB_Throttle1 1 -#define etb_function_e_ETB_Throttle2 2 -#define etb_function_e_ETB_Wastegate 4 +#define dc_function_e_auto_enum 0="DC_None",3="DC_IdleValve",1="DC_Throttle1",2="DC_Throttle2",4="DC_Wastegate" +#define dc_function_e_DC_IdleValve 3 +#define dc_function_e_DC_None 0 +#define dc_function_e_DC_Throttle1 1 +#define dc_function_e_DC_Throttle2 2 +#define dc_function_e_DC_Wastegate 4 #define ETB_HW_MAX_FREQUENCY 3000 #define FLASH_DATA_VERSION 10020 #define FUEL_LEVEL_TABLE_COUNT 8 diff --git a/firmware/config/boards/hellen/hellen-honda-k/board_configuration.cpp b/firmware/config/boards/hellen/hellen-honda-k/board_configuration.cpp index 33674ca63a..a2c4d5a3a2 100644 --- a/firmware/config/boards/hellen/hellen-honda-k/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen-honda-k/board_configuration.cpp @@ -122,8 +122,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->etbFunctions[0] = ETB_None; - engineConfiguration->etbFunctions[1] = ETB_Wastegate; + engineConfiguration->etbFunctions[0] = DC_None; + engineConfiguration->etbFunctions[1] = DC_Wastegate; // Some sensible defaults for other options setCrankOperationMode(); diff --git a/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp b/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp index c36e24ea10..21a18a73f6 100644 --- a/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp @@ -169,7 +169,7 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->etbFunctions[1] = ETB_Wastegate; + engineConfiguration->etbFunctions[1] = DC_Wastegate; // Some sensible defaults for other options setCrankOperationMode(); diff --git a/firmware/config/boards/kinetis/config/controllers/algo/engine_configuration_generated_structures.h b/firmware/config/boards/kinetis/config/controllers/algo/engine_configuration_generated_structures.h index b96230f42a..345cb2c1da 100644 --- a/firmware/config/boards/kinetis/config/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/config/boards/kinetis/config/controllers/algo/engine_configuration_generated_structures.h @@ -2374,7 +2374,7 @@ struct engine_configuration_s { /** * offset 1200 */ - etb_function_e etbFunctions[ETB_COUNT]; + dc_function_e etbFunctions[ETB_COUNT]; /** * offset 1202 */ diff --git a/firmware/config/boards/kinetis/config/controllers/algo/rusefi_generated.h b/firmware/config/boards/kinetis/config/controllers/algo/rusefi_generated.h index 1d1e2d7a84..896eb14f13 100644 --- a/firmware/config/boards/kinetis/config/controllers/algo/rusefi_generated.h +++ b/firmware/config/boards/kinetis/config/controllers/algo/rusefi_generated.h @@ -387,12 +387,12 @@ #define ERROR_BUFFER_SIZE 120 #define ETB_BIAS_CURVE_LENGTH 8 #define ETB_COUNT 2 -#define etb_function_e_auto_enum 0="ETB_None",3="ETB_IdleValve",1="ETB_Throttle1",2="ETB_Throttle2",4="ETB_Wastegate" -#define etb_function_e_ETB_IdleValve 3 -#define etb_function_e_ETB_None 0 -#define etb_function_e_ETB_Throttle1 1 -#define etb_function_e_ETB_Throttle2 2 -#define etb_function_e_ETB_Wastegate 4 +#define dc_function_e_auto_enum 0="DC_None",3="DC_IdleValve",1="DC_Throttle1",2="DC_Throttle2",4="DC_Wastegate" +#define dc_function_e_DC_IdleValve 3 +#define dc_function_e_DC_None 0 +#define dc_function_e_DC_Throttle1 1 +#define dc_function_e_DC_Throttle2 2 +#define dc_function_e_DC_Wastegate 4 #define ETB_HW_MAX_FREQUENCY 3000 #define FLASH_DATA_VERSION 10020 #define FUEL_LEVEL_TABLE_COUNT 8 diff --git a/firmware/config/boards/subaru_eg33/config/controllers/algo/engine_configuration_generated_structures.h b/firmware/config/boards/subaru_eg33/config/controllers/algo/engine_configuration_generated_structures.h index a065bffcbc..4b923db98e 100644 --- a/firmware/config/boards/subaru_eg33/config/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/config/boards/subaru_eg33/config/controllers/algo/engine_configuration_generated_structures.h @@ -2374,7 +2374,7 @@ struct engine_configuration_s { /** * offset 1200 */ - etb_function_e etbFunctions[ETB_COUNT]; + dc_function_e etbFunctions[ETB_COUNT]; /** * offset 1202 */ diff --git a/firmware/config/boards/subaru_eg33/config/controllers/algo/rusefi_generated.h b/firmware/config/boards/subaru_eg33/config/controllers/algo/rusefi_generated.h index 4f0c4d7801..e07f3e4302 100644 --- a/firmware/config/boards/subaru_eg33/config/controllers/algo/rusefi_generated.h +++ b/firmware/config/boards/subaru_eg33/config/controllers/algo/rusefi_generated.h @@ -381,12 +381,12 @@ #define ERROR_BUFFER_SIZE 120 #define ETB_BIAS_CURVE_LENGTH 8 #define ETB_COUNT 2 -#define etb_function_e_auto_enum 0="ETB_None",3="ETB_IdleValve",1="ETB_Throttle1",2="ETB_Throttle2",4="ETB_Wastegate" -#define etb_function_e_ETB_IdleValve 3 -#define etb_function_e_ETB_None 0 -#define etb_function_e_ETB_Throttle1 1 -#define etb_function_e_ETB_Throttle2 2 -#define etb_function_e_ETB_Wastegate 4 +#define dc_function_e_auto_enum 0="DC_None",3="DC_IdleValve",1="DC_Throttle1",2="DC_Throttle2",4="DC_Wastegate" +#define dc_function_e_DC_IdleValve 3 +#define dc_function_e_DC_None 0 +#define dc_function_e_DC_Throttle1 1 +#define dc_function_e_DC_Throttle2 2 +#define dc_function_e_DC_Wastegate 4 #define ETB_HW_MAX_FREQUENCY 3000 #define FLASH_DATA_VERSION 10020 #define FUEL_LEVEL_TABLE_COUNT 8 diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index 2e25dd6211..93cad78070 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -577,8 +577,8 @@ static void mreBoardOldTest() { void proteusDcWastegateTest() { engineConfiguration->isBoostControlEnabled = true; - engineConfiguration->etbFunctions[0] = ETB_Wastegate; - engineConfiguration->etbFunctions[1] = ETB_None; + engineConfiguration->etbFunctions[0] = DC_Wastegate; + engineConfiguration->etbFunctions[1] = DC_None; engineConfiguration->map.sensor.hwChannel = EFI_ADC_NONE; engineConfiguration->tps1_1AdcChannel = EFI_ADC_10; diff --git a/firmware/config/engines/gm_ls_4.cpp b/firmware/config/engines/gm_ls_4.cpp index 09a5949776..7cdf39962e 100644 --- a/firmware/config/engines/gm_ls_4.cpp +++ b/firmware/config/engines/gm_ls_4.cpp @@ -141,7 +141,7 @@ end void setProteusGmLs4() { #if HW_PROTEUS - engineConfiguration->etbFunctions[1] = ETB_None; + engineConfiguration->etbFunctions[1] = DC_None; engineConfiguration->mainRelayPin = PROTEUS_LS_12; setPPSInputs(PROTEUS_IN_ANALOG_VOLT_2, PROTEUS_IN_ANALOG_VOLT_11); diff --git a/firmware/config/engines/test_engine.cpp b/firmware/config/engines/test_engine.cpp index d92ff5fe6b..bb6f4815c6 100644 --- a/firmware/config/engines/test_engine.cpp +++ b/firmware/config/engines/test_engine.cpp @@ -59,7 +59,7 @@ void setTestCrankEngineConfiguration() { void setTestDcWastegateConfiguration() { engineConfiguration->isBoostControlEnabled = 1; - engineConfiguration->etbFunctions[0] = ETB_Wastegate; + engineConfiguration->etbFunctions[0] = DC_Wastegate; setTable(config->boostTableOpenLoop, 50); engineConfiguration->tps1_1AdcChannel = EFI_ADC_1; // PA1 diff --git a/firmware/controllers/actuators/boost_control.cpp b/firmware/controllers/actuators/boost_control.cpp index 4f88a67b03..e02cc251f9 100644 --- a/firmware/controllers/actuators/boost_control.cpp +++ b/firmware/controllers/actuators/boost_control.cpp @@ -226,7 +226,7 @@ void initBoostCtrl() { bool hasAnyEtbWastegate = false; for (size_t i = 0; i < efi::size(engineConfiguration->etbFunctions); i++) { - hasAnyEtbWastegate |= engineConfiguration->etbFunctions[i] == ETB_Wastegate; + hasAnyEtbWastegate |= engineConfiguration->etbFunctions[i] == DC_Wastegate; } // If we have neither a boost PWM pin nor ETB wastegate, nothing more to do diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 41d4af7132..f7cc54b567 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -98,55 +98,55 @@ void setHitachiEtbBiasBins() { copyArray(config->etbBiasValues, hardCodedetbHitachiBiasValues); } -static SensorType functionToPositionSensor(etb_function_e func) { +static SensorType functionToPositionSensor(dc_function_e func) { switch(func) { - case ETB_Throttle1: return SensorType::Tps1; - case ETB_Throttle2: return SensorType::Tps2; - case ETB_IdleValve: return SensorType::IdlePosition; - case ETB_Wastegate: return SensorType::WastegatePosition; + case DC_Throttle1: return SensorType::Tps1; + case DC_Throttle2: return SensorType::Tps2; + case DC_IdleValve: return SensorType::IdlePosition; + case DC_Wastegate: return SensorType::WastegatePosition; default: return SensorType::Invalid; } } -static SensorType functionToTpsSensorPrimary(etb_function_e func) { +static SensorType functionToTpsSensorPrimary(dc_function_e func) { switch(func) { - case ETB_Throttle1: return SensorType::Tps1Primary; + case DC_Throttle1: return SensorType::Tps1Primary; default: return SensorType::Tps2Primary; } } -static SensorType functionToTpsSensorSecondary(etb_function_e func) { +static SensorType functionToTpsSensorSecondary(dc_function_e func) { switch(func) { - case ETB_Throttle1: return SensorType::Tps1Secondary; + case DC_Throttle1: return SensorType::Tps1Secondary; default: return SensorType::Tps2Secondary; } } #if EFI_TUNER_STUDIO -static TsCalMode functionToCalModePriMin(etb_function_e func) { +static TsCalMode functionToCalModePriMin(dc_function_e func) { switch (func) { - case ETB_Throttle1: return TsCalMode::Tps1Min; + case DC_Throttle1: return TsCalMode::Tps1Min; default: return TsCalMode::Tps2Min; } } -static TsCalMode functionToCalModePriMax(etb_function_e func) { +static TsCalMode functionToCalModePriMax(dc_function_e func) { switch (func) { - case ETB_Throttle1: return TsCalMode::Tps1Max; + case DC_Throttle1: return TsCalMode::Tps1Max; default: return TsCalMode::Tps2Max; } } -static TsCalMode functionToCalModeSecMin(etb_function_e func) { +static TsCalMode functionToCalModeSecMin(dc_function_e func) { switch (func) { - case ETB_Throttle1: return TsCalMode::Tps1SecondaryMin; + case DC_Throttle1: return TsCalMode::Tps1SecondaryMin; default: return TsCalMode::Tps2SecondaryMin; } } -static TsCalMode functionToCalModeSecMax(etb_function_e func) { +static TsCalMode functionToCalModeSecMax(dc_function_e func) { switch (func) { - case ETB_Throttle1: return TsCalMode::Tps1SecondaryMax; + case DC_Throttle1: return TsCalMode::Tps1SecondaryMax; default: return TsCalMode::Tps2SecondaryMax; } } @@ -158,8 +158,8 @@ static percent_t directPwmValue = NAN; // this macro clamps both positive and negative percentages from about -100% to 100% #define ETB_PERCENT_TO_DUTY(x) (clampF(-ETB_DUTY_LIMIT, 0.01f * (x), ETB_DUTY_LIMIT)) -bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool hasPedal) { - if (function == ETB_None) { +bool EtbController::init(dc_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool hasPedal) { + if (function == DC_None) { // if not configured, don't init. etbErrorCode = (int8_t)TpsState::None; return false; @@ -251,12 +251,12 @@ void EtbController::setWastegatePosition(percent_t pos) { expected EtbController::getSetpoint() { switch (m_function) { - case ETB_Throttle1: - case ETB_Throttle2: + case DC_Throttle1: + case DC_Throttle2: return getSetpointEtb(); - case ETB_IdleValve: + case DC_IdleValve: return getSetpointIdleValve(); - case ETB_Wastegate: + case DC_Wastegate: return getSetpointWastegate(); default: return unexpected; @@ -361,7 +361,7 @@ expected EtbController::getSetpointEtb() { etbCurrentAdjustedTarget = targetPosition; #if EFI_TUNER_STUDIO - if (m_function == ETB_Throttle1) { + if (m_function == DC_Throttle1) { engine->outputChannels.etbTarget = targetPosition; } #endif // EFI_TUNER_STUDIO @@ -390,8 +390,8 @@ percent_t EtbController2::getThrottleTrim(float rpm, percent_t targetPosition) c expected EtbController::getOpenLoop(percent_t target) { // Don't apply open loop for wastegate/idle valve, only real ETB - if (m_function != ETB_Wastegate - && m_function != ETB_IdleValve) { + if (m_function != DC_Wastegate + && m_function != DC_IdleValve) { etbFeedForward = interpolate2d(target, config->etbBiasBins, config->etbBiasValues); } else { etbFeedForward = 0; @@ -526,7 +526,7 @@ expected EtbController::getClosedLoop(percent_t target, percent_t obs void EtbController::setOutput(expected outputValue) { #if EFI_TUNER_STUDIO // Only report first-throttle stats - if (m_function == ETB_Throttle1) { + if (m_function == DC_Throttle1) { engine->outputChannels.etb1DutyCycle = outputValue.value_or(0); } #endif @@ -560,9 +560,9 @@ bool EtbController::checkStatus() { #if EFI_TUNER_STUDIO // Only debug throttle #1 - if (m_function == ETB_Throttle1) { + if (m_function == DC_Throttle1) { m_pid.postState(engine->outputChannels.etbStatus); - } else if (m_function == ETB_Wastegate) { + } else if (m_function == DC_Wastegate) { m_pid.postState(engine->outputChannels.wastegateDcStatus); } #endif /* EFI_TUNER_STUDIO */ @@ -571,7 +571,7 @@ bool EtbController::checkStatus() { // Update local state about autotune m_isAutotune = Sensor::getOrZero(SensorType::Rpm) == 0 && engine->etbAutoTune - && m_function == ETB_Throttle1; + && m_function == DC_Throttle1; bool shouldCheckSensorFunction = engine->module()->analogSensorsShouldWork(); @@ -679,7 +679,7 @@ void EtbController::checkOutput(percent_t output) { void EtbController::autoCalibrateTps() { // Only auto calibrate throttles - if (m_function == ETB_Throttle1 || m_function == ETB_Throttle2) { + if (m_function == DC_Throttle1 || m_function == DC_Throttle2) { m_isAutocal = true; } } @@ -963,8 +963,8 @@ void setDefaultEtbParameters() { } // Default is to run each throttle off its respective hbridge - engineConfiguration->etbFunctions[0] = ETB_Throttle1; - engineConfiguration->etbFunctions[1] = ETB_Throttle2; + engineConfiguration->etbFunctions[0] = DC_Throttle1; + engineConfiguration->etbFunctions[1] = DC_Throttle2; engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY; @@ -1006,9 +1006,9 @@ void unregisterEtbPins() { // todo: we probably need an implementation here?! } -static pid_s* getEtbPidForFunction(etb_function_e function) { +static pid_s* getEtbPidForFunction(dc_function_e function) { switch (function) { - case ETB_Wastegate: return &engineConfiguration->etbWastegatePid; + case DC_Wastegate: return &engineConfiguration->etbWastegatePid; default: return &engineConfiguration->etb; } } @@ -1028,7 +1028,7 @@ void doInitElectronicThrottle() { // todo: rename etbFunctions to something-without-etb for same reason? for (int i = 0 ; i < ETB_COUNT; i++) { auto func = engineConfiguration->etbFunctions[i]; - if (func == ETB_None) { + if (func == DC_None) { // do not touch HW pins if function not selected, this way Lua can use DC motor hardware pins directly continue; } diff --git a/firmware/controllers/actuators/electronic_throttle.h b/firmware/controllers/actuators/electronic_throttle.h index 04d84e7d97..21dbe58245 100644 --- a/firmware/controllers/actuators/electronic_throttle.h +++ b/firmware/controllers/actuators/electronic_throttle.h @@ -48,7 +48,7 @@ class IEtbController : public ClosedLoopController { public: // Initialize the throttle. // returns true if the throttle was initialized, false otherwise. - virtual bool init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles = true) = 0; + virtual bool init(dc_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles = true) = 0; virtual void reset() = 0; virtual void setIdlePosition(percent_t pos) = 0; virtual void setWastegatePosition(percent_t pos) = 0; diff --git a/firmware/controllers/actuators/electronic_throttle_impl.h b/firmware/controllers/actuators/electronic_throttle_impl.h index 7c5a501ce2..b7105fb2c3 100644 --- a/firmware/controllers/actuators/electronic_throttle_impl.h +++ b/firmware/controllers/actuators/electronic_throttle_impl.h @@ -27,7 +27,7 @@ class EtbController : public IEtbController, public electronic_throttle_s { public: - bool init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) override; + bool init(dc_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) override; void setIdlePosition(percent_t pos) override; void setWastegatePosition(percent_t pos) override; void reset() override; @@ -82,11 +82,11 @@ protected: bool hadTpsError = false; bool hadPpsError = false; - etb_function_e getFunction() const { return m_function; } + dc_function_e getFunction() const { return m_function; } DcMotor* getMotor() { return m_motor; } private: - etb_function_e m_function = ETB_None; + dc_function_e m_function = DC_None; SensorType m_positionSensor = SensorType::Invalid; DcMotor *m_motor = nullptr; Pid m_pid; @@ -99,7 +99,7 @@ private: */ bool checkStatus(); bool isEtbMode() { - return m_function == ETB_Throttle1 || m_function == ETB_Throttle2; + return m_function == DC_Throttle1 || m_function == DC_Throttle2; } ExpAverage m_dutyRocAverage; diff --git a/firmware/controllers/algo/auto_generated_commonenum.cpp b/firmware/controllers/algo/auto_generated_commonenum.cpp index f8a1ec7a2f..4d09b47633 100644 --- a/firmware/controllers/algo/auto_generated_commonenum.cpp +++ b/firmware/controllers/algo/auto_generated_commonenum.cpp @@ -337,18 +337,18 @@ case LM_SPEED_DENSITY: } return NULL; } -const char *getEtb_function_e(etb_function_e value){ +const char *getdc_function_e(dc_function_e value){ switch(value) { -case ETB_IdleValve: - return "ETB_IdleValve"; -case ETB_None: - return "ETB_None"; -case ETB_Throttle1: - return "ETB_Throttle1"; -case ETB_Throttle2: - return "ETB_Throttle2"; -case ETB_Wastegate: - return "ETB_Wastegate"; +case DC_IdleValve: + return "DC_IdleValve"; +case DC_None: + return "DC_None"; +case DC_Throttle1: + return "DC_Throttle1"; +case DC_Throttle2: + return "DC_Throttle2"; +case DC_Wastegate: + return "DC_Wastegate"; } return NULL; } diff --git a/firmware/controllers/algo/auto_generated_commonenum.h b/firmware/controllers/algo/auto_generated_commonenum.h index f8f434da53..78885e9758 100644 --- a/firmware/controllers/algo/auto_generated_commonenum.h +++ b/firmware/controllers/algo/auto_generated_commonenum.h @@ -39,7 +39,7 @@ const char *getCan_vss_nbc_e(can_vss_nbc_e value); const char *getDisplay_mode_e(display_mode_e value); const char *getEgo_sensor_e(ego_sensor_e value); const char *getEngine_load_mode_e(engine_load_mode_e value); -const char *getEtb_function_e(etb_function_e value); +const char *getdc_function_e(dc_function_e value); const char *getGear_e(gear_e value); const char *getGppwm_channel_e(gppwm_channel_e value); const char *getGppwm_compare_mode_e(gppwm_compare_mode_e value); diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 4fc41345b8..67c15796f9 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -602,14 +602,12 @@ typedef enum __attribute__ ((__packed__)) { } load_override_e; typedef enum __attribute__ ((__packed__)) { -// todo: rename to HB_None? - ETB_None = 0, - ETB_Throttle1 = 1, - ETB_Throttle2 = 2, - ETB_IdleValve = 3, - ETB_Wastegate = 4, -// todo: rename to dc_function_e? rename to hbrg_function_e? -} etb_function_e; + DC_None = 0, + DC_Throttle1 = 1, + DC_Throttle2 = 2, + DC_IdleValve = 3, + DC_Wastegate = 4, +} dc_function_e; typedef enum __attribute__ ((__packed__)) { STEPPER_FULL = 0, diff --git a/firmware/controllers/generated/engine_configuration_generated_structures.h b/firmware/controllers/generated/engine_configuration_generated_structures.h index 7c90d643b3..896a7ba0d9 100644 --- a/firmware/controllers/generated/engine_configuration_generated_structures.h +++ b/firmware/controllers/generated/engine_configuration_generated_structures.h @@ -2374,7 +2374,7 @@ struct engine_configuration_s { /** * offset 1200 */ - etb_function_e etbFunctions[ETB_COUNT]; + dc_function_e etbFunctions[ETB_COUNT]; /** * offset 1202 */ diff --git a/firmware/controllers/generated/rusefi_generated.h b/firmware/controllers/generated/rusefi_generated.h index 5b5b3dc62f..acf3672613 100644 --- a/firmware/controllers/generated/rusefi_generated.h +++ b/firmware/controllers/generated/rusefi_generated.h @@ -387,12 +387,12 @@ #define ERROR_BUFFER_SIZE 120 #define ETB_BIAS_CURVE_LENGTH 8 #define ETB_COUNT 2 -#define etb_function_e_auto_enum 0="ETB_None",3="ETB_IdleValve",1="ETB_Throttle1",2="ETB_Throttle2",4="ETB_Wastegate" -#define etb_function_e_ETB_IdleValve 3 -#define etb_function_e_ETB_None 0 -#define etb_function_e_ETB_Throttle1 1 -#define etb_function_e_ETB_Throttle2 2 -#define etb_function_e_ETB_Wastegate 4 +#define dc_function_e_auto_enum 0="DC_None",3="DC_IdleValve",1="DC_Throttle1",2="DC_Throttle2",4="DC_Wastegate" +#define dc_function_e_DC_IdleValve 3 +#define dc_function_e_DC_None 0 +#define dc_function_e_DC_Throttle1 1 +#define dc_function_e_DC_Throttle2 2 +#define dc_function_e_DC_Wastegate 4 #define ETB_HW_MAX_FREQUENCY 3000 #define FLASH_DATA_VERSION 10020 #define FUEL_LEVEL_TABLE_COUNT 8 diff --git a/java_console/ui/src/main/resources/c_sources/boost_control.cpp b/java_console/ui/src/main/resources/c_sources/boost_control.cpp index edba5139b4..4f331f2b2b 100644 --- a/java_console/ui/src/main/resources/c_sources/boost_control.cpp +++ b/java_console/ui/src/main/resources/c_sources/boost_control.cpp @@ -228,7 +228,7 @@ void initBoostCtrl() { bool hasAnyEtbWastegate = false; for (size_t i = 0; i < efi::size(engineConfiguration->etbFunctions); i++) { - hasAnyEtbWastegate |= engineConfiguration->etbFunctions[i] == ETB_Wastegate; + hasAnyEtbWastegate |= engineConfiguration->etbFunctions[i] == DC_Wastegate; } // If we have neither a boost PWM pin nor ETB wastegate, nothing more to do diff --git a/unit_tests/mocks.h b/unit_tests/mocks.h index 26bd955a64..e83abe5471 100644 --- a/unit_tests/mocks.h +++ b/unit_tests/mocks.h @@ -21,7 +21,7 @@ public: // IEtbController mocks MOCK_METHOD(void, reset, (), (override)); MOCK_METHOD(void, update, (), (override)); - MOCK_METHOD(bool, init, (etb_function_e function, DcMotor* motor, pid_s* pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles), (override)); + MOCK_METHOD(bool, init, (dc_function_e function, DcMotor* motor, pid_s* pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles), (override)); MOCK_METHOD(void, setIdlePosition, (percent_t pos), (override)); MOCK_METHOD(void, setWastegatePosition, (percent_t pos), (override)); MOCK_METHOD(void, autoCalibrateTps, (), (override)); diff --git a/unit_tests/tests/actuators/test_etb.cpp b/unit_tests/tests/actuators/test_etb.cpp index 266624e22d..351368664b 100644 --- a/unit_tests/tests/actuators/test_etb.cpp +++ b/unit_tests/tests/actuators/test_etb.cpp @@ -27,8 +27,8 @@ TEST(etb, initializationNoPedal) { engine->etbControllers[i] = &mocks[i]; } - EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, _, _, false)).WillOnce(Return(false)); - EXPECT_CALL(mocks[1], init(ETB_Throttle2, _, _, _, false)).WillOnce(Return(false)); + EXPECT_CALL(mocks[0], init(DC_Throttle1, _, _, _, false)).WillOnce(Return(false)); + EXPECT_CALL(mocks[1], init(DC_Throttle2, _, _, _, false)).WillOnce(Return(false)); // This shouldn't throw, since no throttles are configured, but no pedal is configured either EXPECT_NO_FATAL_ERROR(doInitElectronicThrottle()); @@ -38,16 +38,16 @@ TEST(etb, initializationMissingThrottle) { StrictMock mocks[ETB_COUNT]; EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { - engineConfiguration->etbFunctions[0] = ETB_None; - engineConfiguration->etbFunctions[1] = ETB_None; + engineConfiguration->etbFunctions[0] = DC_None; + engineConfiguration->etbFunctions[1] = DC_None; }); for (int i = 0; i < ETB_COUNT; i++) { engine->etbControllers[i] = &mocks[i]; } - EXPECT_CALL(mocks[0], init(ETB_None, _, _, _, true)).Times(0); - EXPECT_CALL(mocks[1], init(ETB_None, _, _, _, true)).Times(0); + EXPECT_CALL(mocks[0], init(DC_None, _, _, _, true)).Times(0); + EXPECT_CALL(mocks[1], init(DC_None, _, _, _, true)).Times(0); // Must have a sensor configured before init Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); @@ -61,8 +61,8 @@ TEST(etb, initializationSingleThrottle) { StrictMock mocks[ETB_COUNT]; EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { - engineConfiguration->etbFunctions[0] = ETB_Throttle1; - engineConfiguration->etbFunctions[1] = ETB_None; + engineConfiguration->etbFunctions[0] = DC_Throttle1; + engineConfiguration->etbFunctions[1] = DC_None; }); for (int i = 0; i < ETB_COUNT; i++) { @@ -74,10 +74,10 @@ TEST(etb, initializationSingleThrottle) { Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 0); // Expect mock0 to be init as throttle 1, and PID params - EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); + EXPECT_CALL(mocks[0], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); // Expect mock1 to be init as none - EXPECT_CALL(mocks[1], init(ETB_None, _, _, _, true)).Times(0); + EXPECT_CALL(mocks[1], init(DC_None, _, _, _, true)).Times(0); doInitElectronicThrottle(); } @@ -86,8 +86,8 @@ TEST(etb, initializationSingleThrottleInSecondSlot) { StrictMock mocks[ETB_COUNT]; EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { - engineConfiguration->etbFunctions[0] = ETB_None; - engineConfiguration->etbFunctions[1] = ETB_Throttle1; + engineConfiguration->etbFunctions[0] = DC_None; + engineConfiguration->etbFunctions[1] = DC_Throttle1; }); for (int i = 0; i < ETB_COUNT; i++) { @@ -99,10 +99,10 @@ TEST(etb, initializationSingleThrottleInSecondSlot) { Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 0, false); // Expect mock0 to be init as none - EXPECT_CALL(mocks[0], init(ETB_None, _, _, _, true)).Times(0); + EXPECT_CALL(mocks[0], init(DC_None, _, _, _, true)).Times(0); // Expect mock1 to be init as throttle 1, and PID params - EXPECT_CALL(mocks[1], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); + EXPECT_CALL(mocks[1], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); doInitElectronicThrottle(); } @@ -123,14 +123,14 @@ TEST(etb, initializationDualThrottle) { Sensor::setMockValue(SensorType::Tps1, 25.0f, true); Sensor::setMockValue(SensorType::Tps2, 25.0f, true); - engineConfiguration->etbFunctions[0] = ETB_Throttle1; - engineConfiguration->etbFunctions[1] = ETB_Throttle2; + engineConfiguration->etbFunctions[0] = DC_Throttle1; + engineConfiguration->etbFunctions[1] = DC_Throttle2; // Expect mock0 to be init as throttle 1, and PID params - EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); + EXPECT_CALL(mocks[0], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); // Expect mock1 to be init as throttle 2, and PID params - EXPECT_CALL(mocks[1], init(ETB_Throttle2, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); + EXPECT_CALL(mocks[1], init(DC_Throttle2, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); doInitElectronicThrottle(); } @@ -139,8 +139,8 @@ TEST(etb, initializationWastegate) { StrictMock mocks[ETB_COUNT]; EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { - engineConfiguration->etbFunctions[0] = ETB_Wastegate; - engineConfiguration->etbFunctions[1] = ETB_None; + engineConfiguration->etbFunctions[0] = DC_Wastegate; + engineConfiguration->etbFunctions[1] = DC_None; }); for (int i = 0; i < ETB_COUNT; i++) { @@ -148,10 +148,10 @@ TEST(etb, initializationWastegate) { } // Expect mock0 to be init as throttle 1, and PID wastegate params - EXPECT_CALL(mocks[0], init(ETB_Wastegate, _, &engineConfiguration->etbWastegatePid, Ne(nullptr), false)).WillOnce(Return(true)); + EXPECT_CALL(mocks[0], init(DC_Wastegate, _, &engineConfiguration->etbWastegatePid, Ne(nullptr), false)).WillOnce(Return(true)); // Expect mock1 to be init as none - EXPECT_CALL(mocks[1], init(ETB_None, _, _, _, false)).Times(0); + EXPECT_CALL(mocks[1], init(DC_None, _, _, _, false)).Times(0); doInitElectronicThrottle(); } @@ -161,8 +161,8 @@ TEST(etb, initializationNoFunction) { EtbController dut; - // When init called with ETB_None, should ignore the provided params and return false - EXPECT_FALSE(dut.init(ETB_None, &motor, nullptr, nullptr, false)); + // When init called with DC_None, should ignore the provided params and return false + EXPECT_FALSE(dut.init(DC_None, &motor, nullptr, nullptr, false)); // This should no-op, it shouldn't call motor.set(float duty) dut.setOutput(0.5f); @@ -178,7 +178,7 @@ TEST(etb, initializationNotRedundantTps) { Sensor::setMockValue(SensorType::Tps1Primary, 0); Sensor::setMockValue(SensorType::Tps1, 0.0f, false); - EXPECT_FATAL_ERROR(dut.init(ETB_Throttle1, nullptr, nullptr, nullptr, true)); + EXPECT_FATAL_ERROR(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true)); } TEST(etb, initializationNotRedundantPedal) { @@ -191,7 +191,7 @@ TEST(etb, initializationNotRedundantPedal) { Sensor::setMockValue(SensorType::Tps1Primary, 0); Sensor::setMockValue(SensorType::Tps1, 0.0f, true); - EXPECT_FATAL_ERROR(dut.init(ETB_Throttle1, nullptr, nullptr, nullptr, true)); + EXPECT_FATAL_ERROR(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true)); } TEST(etb, initializationNoPrimarySensor) { @@ -205,13 +205,13 @@ TEST(etb, initializationNoPrimarySensor) { // Redundant, but no primary configured Sensor::setMockValue(SensorType::Tps1, 0.0f, true); - EXPECT_FALSE(dut.init(ETB_Throttle1, nullptr, nullptr, nullptr, true)); + EXPECT_FALSE(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true)); // Now configure primary TPS Sensor::setMockValue(SensorType::Tps1Primary, 0); // With primary TPS, should return true (ie, throttle was configured) - EXPECT_TRUE(dut.init(ETB_Throttle1, nullptr, nullptr, nullptr, true)); + EXPECT_TRUE(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true)); } TEST(etb, initializationNoThrottles) { @@ -225,8 +225,8 @@ TEST(etb, initializationNoThrottles) { } // Configure ETB functions, but no pedal - engineConfiguration->etbFunctions[0] = ETB_Throttle1; - engineConfiguration->etbFunctions[1] = ETB_Throttle2; + engineConfiguration->etbFunctions[0] = DC_Throttle1; + engineConfiguration->etbFunctions[1] = DC_Throttle2; // No pedal - don't init ETBs Sensor::resetMockValue(SensorType::AcceleratorPedal); @@ -274,7 +274,7 @@ TEST(etb, testSetpointOnlyPedal) { Sensor::setMockValue(SensorType::Tps1, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); - etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); + etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true); // Check endpoints and midpoint Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); @@ -334,7 +334,7 @@ TEST(etb, setpointSecondThrottleTrim) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController2 etb(throttleTrimTable); - etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); + etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 47, true); EXPECT_EQ(51, etb.getSetpoint().value_or(-1)); @@ -359,7 +359,7 @@ TEST(etb, setpointIdle) { .WillRepeatedly([](float xRpm, float y) { return y; }); - etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); + etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true); // No idle range, should just pass pedal Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); @@ -416,7 +416,7 @@ TEST(etb, setpointRevLimit) { .WillRepeatedly([](float, float) { return 80; }); - etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); + etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true); // Below threshold, should return unadjusted throttle Sensor::setMockValue(SensorType::Rpm, 1000); @@ -447,7 +447,7 @@ TEST(etb, setpointNoPedalMap) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); // Don't pass a pedal map - etb.init(ETB_Throttle1, nullptr, nullptr, nullptr, true); + etb.init(DC_Throttle1, nullptr, nullptr, nullptr, true); EXPECT_EQ(etb.getSetpoint(), unexpected); } @@ -455,7 +455,7 @@ TEST(etb, setpointNoPedalMap) { TEST(etb, setpointIdleValveController) { EtbController etb; - etb.init(ETB_IdleValve, nullptr, nullptr, nullptr, false); + etb.init(DC_IdleValve, nullptr, nullptr, nullptr, false); etb.setIdlePosition(0); EXPECT_FLOAT_EQ(0, etb.getSetpoint().value_or(-1)); @@ -474,7 +474,7 @@ TEST(etb, setpointIdleValveController) { TEST(etb, setpointWastegateController) { EtbController etb; - etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, false); + etb.init(DC_Wastegate, nullptr, nullptr, nullptr, false); etb.setWastegatePosition(0); EXPECT_FLOAT_EQ(0, etb.getSetpoint().value_or(-1)); @@ -506,7 +506,7 @@ TEST(etb, setpointLuaAdder) { .WillRepeatedly([](float, float) { return 50; }); - etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); + etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true); // No adjustment, should be unadjusted etb.setLuaAdjustment(0); @@ -554,28 +554,28 @@ TEST(etb, etbTpsSensor) { // Test first throttle { EtbController etb; - etb.init(ETB_Throttle1, nullptr, nullptr, nullptr, true); + etb.init(DC_Throttle1, nullptr, nullptr, nullptr, true); EXPECT_EQ(etb.observePlant().Value, 25.0f); } // Test second throttle { EtbController etb; - etb.init(ETB_Throttle2, nullptr, nullptr, nullptr, true); + etb.init(DC_Throttle2, nullptr, nullptr, nullptr, true); EXPECT_EQ(etb.observePlant().Value, 75.0f); } // Test wastegate control { EtbController etb; - etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, true); + etb.init(DC_Wastegate, nullptr, nullptr, nullptr, true); EXPECT_EQ(etb.observePlant().Value, 33.0f); } // Test idle valve control { EtbController etb; - etb.init(ETB_IdleValve, nullptr, nullptr, nullptr, true); + etb.init(DC_IdleValve, nullptr, nullptr, nullptr, true); EXPECT_EQ(etb.observePlant().Value, 66.0f); } } @@ -591,7 +591,7 @@ TEST(etb, setOutputInvalid) { StrictMock motor; EtbController etb; - etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); + etb.init(DC_Throttle1, &motor, nullptr, nullptr, true); // Should be disabled in case of unexpected EXPECT_CALL(motor, disable(_)); @@ -609,7 +609,7 @@ TEST(etb, setOutputValid) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); + etb.init(DC_Throttle1, &motor, nullptr, nullptr, true); // Should be enabled and value set EXPECT_CALL(motor, enable()); @@ -629,7 +629,7 @@ TEST(etb, setOutputValid2) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); + etb.init(DC_Throttle1, &motor, nullptr, nullptr, true); // Should be enabled and value set EXPECT_CALL(motor, enable()); @@ -649,7 +649,7 @@ TEST(etb, setOutputOutOfRangeHigh) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); + etb.init(DC_Throttle1, &motor, nullptr, nullptr, true); // Should be enabled and value set EXPECT_CALL(motor, enable()); @@ -669,7 +669,7 @@ TEST(etb, setOutputOutOfRangeLow) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); + etb.init(DC_Throttle1, &motor, nullptr, nullptr, true); // Should be enabled and value set EXPECT_CALL(motor, enable()); @@ -689,7 +689,7 @@ TEST(etb, setOutputPauseControl) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); + etb.init(DC_Throttle1, &motor, nullptr, nullptr, true); // Pause control - should get no output engineConfiguration->pauseEtbControl = true; @@ -710,7 +710,7 @@ TEST(etb, setOutputLimpHome) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); + etb.init(DC_Throttle1, &motor, nullptr, nullptr, true); // Should be disabled when in ETB limp mode EXPECT_CALL(motor, disable(_)); @@ -733,7 +733,7 @@ TEST(etb, closedLoopPid) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.init(ETB_Throttle1, nullptr, &pid, nullptr, true); + etb.init(DC_Throttle1, nullptr, &pid, nullptr, true); // Disable autotune for now Engine e; @@ -774,7 +774,7 @@ TEST(etb, jamDetection) { engineConfiguration->etbJamTimeout = 1; EtbController etb; - etb.init(ETB_Throttle1, nullptr, &pid, nullptr, true); + etb.init(DC_Throttle1, nullptr, &pid, nullptr, true); timeNowUs = 0; @@ -812,7 +812,7 @@ TEST(etb, openLoopThrottle) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); EtbController etb; - etb.init(ETB_Throttle1, nullptr, nullptr, nullptr, true); + etb.init(DC_Throttle1, nullptr, nullptr, nullptr, true); // Map [0, 100] -> [-50, 50] setLinearCurve(config->etbBiasBins, 0, 100); @@ -834,7 +834,7 @@ TEST(etb, openLoopNonThrottle) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); EtbController etb; - etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, false); + etb.init(DC_Wastegate, nullptr, nullptr, nullptr, false); // Map [0, 100] -> [-50, 50] setLinearCurve(config->etbBiasBins, 0, 100);