From 2857e9527db6be1183498fb4c6c69fe00e5423c3 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Mon, 27 Mar 2023 03:58:18 -0400 Subject: [PATCH] remove specs_s struct, flatten config (cherry picked from commit f090a97b0b7771dfe02e4b4bb9919d50a6a11ef5) --- .../alphax-2chan/board_configuration.cpp | 4 +-- .../alphax-4chan/board_configuration.cpp | 4 +-- .../alphax-8chan/board_configuration.cpp | 4 +-- .../hellen/harley81/board_configuration.cpp | 4 +-- .../hellen/hellen-nb1/board_configuration.cpp | 4 +-- .../hellen121vag/board_configuration.cpp | 4 +-- .../hellen154hyundai/board_configuration.cpp | 6 ++--- .../board_configuration.cpp | 4 +-- .../hellen/hellen72/board_configuration.cpp | 4 +-- .../hellen/hellen81/board_configuration.cpp | 4 +-- .../hellenNA8_96/board_configuration.cpp | 4 +-- .../microrusefi/board_configuration.cpp | 4 +-- .../boards/proteus/board_configuration.cpp | 4 +-- firmware/config/engines/GY6_139QMB.cpp | 6 ++--- firmware/config/engines/bmw_m73.cpp | 6 ++--- firmware/config/engines/bmw_m73_mre.cpp | 6 ++--- .../config/engines/chevrolet_camaro_4.cpp | 6 ++--- .../config/engines/citroenBerlingoTU3JP.cpp | 6 ++--- firmware/config/engines/dodge_neon.cpp | 6 ++--- firmware/config/engines/dodge_ram.cpp | 6 ++--- .../config/engines/ford_1995_inline_6.cpp | 4 +-- firmware/config/engines/ford_aspire.cpp | 6 ++--- firmware/config/engines/ford_festiva.cpp | 2 +- firmware/config/engines/gm_ls_4.cpp | 6 ++--- firmware/config/engines/honda_600.cpp | 4 +-- firmware/config/engines/honda_k_dbc.cpp | 6 ++--- firmware/config/engines/mazda_miata.cpp | 6 ++--- firmware/config/engines/mazda_miata_na8.cpp | 2 +- firmware/config/engines/mercedes.cpp | 8 +++--- firmware/config/engines/nissan_vq.cpp | 14 +++++----- firmware/config/engines/sachs.cpp | 6 ++--- firmware/config/engines/subaru.cpp | 10 +++---- firmware/config/engines/toyota_jzs147.cpp | 6 ++--- firmware/config/engines/vw.cpp | 26 +++++++++---------- firmware/config/engines/vw_b6.cpp | 4 +-- firmware/console/status_loop.cpp | 2 +- .../controllers/algo/airmass/maf_airmass.cpp | 2 +- .../algo/airmass/speed_density_base.cpp | 4 +-- .../algo/defaults/default_base_engine.cpp | 8 +++--- firmware/controllers/algo/engine2.cpp | 2 +- firmware/controllers/algo/event_registry.h | 2 +- firmware/controllers/algo/fuel_math.cpp | 10 +++---- firmware/controllers/engine_controller.cpp | 4 +-- .../engine_cycle/fuel_schedule.cpp | 8 +++--- .../engine_cycle/high_pressure_fuel_pump.cpp | 2 +- .../engine_cycle/map_averaging.cpp | 8 +++--- firmware/controllers/limp_manager.cpp | 2 +- firmware/controllers/math/speed_density.cpp | 2 +- firmware/controllers/system/efi_gpio.cpp | 4 +-- .../controllers/system/injection_gpio.cpp | 4 +-- firmware/integration/rusefi_config.txt | 8 +++--- unit_tests/engine_test_helper.cpp | 2 +- .../ignition_injection/test_fuel_math.cpp | 20 +++++++------- .../test_ignition_scheduling.cpp | 4 +-- unit_tests/tests/test_hpfp.cpp | 12 ++++----- unit_tests/tests/test_hpfp_integrated.cpp | 2 +- .../tests/trigger/test_trigger_decoder.cpp | 2 +- 57 files changed, 159 insertions(+), 161 deletions(-) diff --git a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp index b598a7f555..d0b62af361 100644 --- a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp @@ -140,8 +140,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp index 347016e4a5..2b9c40ddc7 100644 --- a/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp @@ -180,8 +180,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/hellen/alphax-8chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-8chan/board_configuration.cpp index ad3d51a8b3..c5d8f46c06 100644 --- a/firmware/config/boards/hellen/alphax-8chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-8chan/board_configuration.cpp @@ -183,8 +183,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/hellen/harley81/board_configuration.cpp b/firmware/config/boards/hellen/harley81/board_configuration.cpp index f8ce17ec73..cc763667ad 100644 --- a/firmware/config/boards/hellen/harley81/board_configuration.cpp +++ b/firmware/config/boards/hellen/harley81/board_configuration.cpp @@ -137,8 +137,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 2; - engineConfiguration->specs.firingOrder = FO_1_2; + engineConfiguration->cylindersCount = 2; + engineConfiguration->firingOrder = FO_1_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp b/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp index d00d23528a..cfeac5ffe1 100644 --- a/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp @@ -106,8 +106,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp b/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp index c117c0e21c..6f2703ff2b 100644 --- a/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp @@ -131,8 +131,8 @@ void setBoardDefaultConfiguration() { strcpy(engineConfiguration->engineMake, ENGINE_MAKE_VAG); strcpy(engineConfiguration->engineCode, "base"); - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp b/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp index 9104a4485d..71b1d3734f 100644 --- a/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp @@ -179,9 +179,9 @@ void setBoardDefaultConfiguration() { engineConfiguration->injectorCompensationMode = ICM_FixedRailPressure; - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; - engineConfiguration->specs.displacement = 1.998; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; + engineConfiguration->displacement = 1.998; strcpy(engineConfiguration->engineMake, ENGINE_MAKE_Hyundai); strcpy(engineConfiguration->engineCode, "Theta II"); engineConfiguration->globalTriggerAngleOffset = 90; diff --git a/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp b/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp index febb698cb5..25a40128d2 100644 --- a/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp @@ -107,8 +107,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/hellen/hellen72/board_configuration.cpp b/firmware/config/boards/hellen/hellen72/board_configuration.cpp index 9b1e5dd2f7..7715a2d34b 100644 --- a/firmware/config/boards/hellen/hellen72/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen72/board_configuration.cpp @@ -123,8 +123,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/hellen/hellen81/board_configuration.cpp b/firmware/config/boards/hellen/hellen81/board_configuration.cpp index b7a0435fc3..3340d56eb3 100644 --- a/firmware/config/boards/hellen/hellen81/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen81/board_configuration.cpp @@ -120,8 +120,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp b/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp index 20b28ea0eb..3d227e2106 100644 --- a/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp @@ -109,8 +109,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK diff --git a/firmware/config/boards/microrusefi/board_configuration.cpp b/firmware/config/boards/microrusefi/board_configuration.cpp index 65a33bf2fd..69b897fbc1 100644 --- a/firmware/config/boards/microrusefi/board_configuration.cpp +++ b/firmware/config/boards/microrusefi/board_configuration.cpp @@ -201,8 +201,8 @@ void setBoardDefaultConfiguration() { // Don't enable expansion header SPI by default engineConfiguration->is_enabled_spi_3 = false; - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; diff --git a/firmware/config/boards/proteus/board_configuration.cpp b/firmware/config/boards/proteus/board_configuration.cpp index 8c3db7fcee..8dafdae0d8 100644 --- a/firmware/config/boards/proteus/board_configuration.cpp +++ b/firmware/config/boards/proteus/board_configuration.cpp @@ -171,8 +171,8 @@ void setBoardDefaultConfiguration() { // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->specs.cylindersCount = 8; - engineConfiguration->specs.firingOrder = FO_1_8_7_2_6_5_4_3; + engineConfiguration->cylindersCount = 8; + engineConfiguration->firingOrder = FO_1_8_7_2_6_5_4_3; engineConfiguration->enableSoftwareKnock = true; diff --git a/firmware/config/engines/GY6_139QMB.cpp b/firmware/config/engines/GY6_139QMB.cpp index a801712683..98b0ed05f5 100644 --- a/firmware/config/engines/GY6_139QMB.cpp +++ b/firmware/config/engines/GY6_139QMB.cpp @@ -25,13 +25,13 @@ void setGy6139qmbDefaultEngineConfiguration() { setTargetRpmCurve(2000); engineConfiguration->analogInputDividerCoefficient = 1; engineConfiguration->globalTriggerAngleOffset = 45; - engineConfiguration->specs.displacement = 0.072; // 72cc - engineConfiguration->specs.cylindersCount = 1; + engineConfiguration->displacement = 0.072; // 72cc + engineConfiguration->cylindersCount = 1; setCrankOperationMode(); // this is related to 'setDefaultBaseEngine' having 'skippedWheelOnCam = true' which is a weird fact by itself engineConfiguration->skippedWheelOnCam = false; - engineConfiguration->specs.firingOrder = FO_1; + engineConfiguration->firingOrder = FO_1; /** * We treat the trigger as 8-1 toothed wheel diff --git a/firmware/config/engines/bmw_m73.cpp b/firmware/config/engines/bmw_m73.cpp index baee78d5ce..16401378ad 100644 --- a/firmware/config/engines/bmw_m73.cpp +++ b/firmware/config/engines/bmw_m73.cpp @@ -90,11 +90,11 @@ void m73engine() { // 13641435991 injector engineConfiguration->injector.flow = 180; // cc/min, who knows if this number is real - no good source of info - engineConfiguration->specs.cylindersCount = 12; - engineConfiguration->specs.displacement = 5.4; + engineConfiguration->cylindersCount = 12; + engineConfiguration->displacement = 5.4; strcpy(engineConfiguration->engineMake, ENGINE_MAKE_BMW); strcpy(engineConfiguration->engineCode, "M73"); - engineConfiguration->specs.firingOrder = FO_1_7_5_11_3_9_6_12_2_8_4_10; + engineConfiguration->firingOrder = FO_1_7_5_11_3_9_6_12_2_8_4_10; engineConfiguration->fuelAlgorithm = LM_ALPHA_N; engineConfiguration->canNbcType = CAN_BUS_NBC_NONE; diff --git a/firmware/config/engines/bmw_m73_mre.cpp b/firmware/config/engines/bmw_m73_mre.cpp index 9ca19e5d00..bbf6b47166 100644 --- a/firmware/config/engines/bmw_m73_mre.cpp +++ b/firmware/config/engines/bmw_m73_mre.cpp @@ -72,9 +72,9 @@ void setEngineBMW_M73_microRusEfi() { strcpy(engineConfiguration->vehicleName, "microRusEFIx2"); engineConfiguration->globalTriggerAngleOffset = 90; - engineConfiguration->specs.cylindersCount = 6; - engineConfiguration->specs.displacement = 5.4 / 2; - engineConfiguration->specs.firingOrder = FO_1_5_3_6_2_4; + engineConfiguration->cylindersCount = 6; + engineConfiguration->displacement = 5.4 / 2; + engineConfiguration->firingOrder = FO_1_5_3_6_2_4; engineConfiguration->ignitionMode = IM_ONE_COIL; diff --git a/firmware/config/engines/chevrolet_camaro_4.cpp b/firmware/config/engines/chevrolet_camaro_4.cpp index 45f1b1ce11..08970f4de5 100644 --- a/firmware/config/engines/chevrolet_camaro_4.cpp +++ b/firmware/config/engines/chevrolet_camaro_4.cpp @@ -19,11 +19,11 @@ void setCamaro4() { setAlgorithm(LM_SPEED_DENSITY); - engineConfiguration->specs.displacement = 5.7; - engineConfiguration->specs.cylindersCount = 8; + engineConfiguration->displacement = 5.7; + engineConfiguration->cylindersCount = 8; strcpy(engineConfiguration->engineMake, ENGINE_MAKE_GM); - engineConfiguration->specs.firingOrder = FO_1_8_7_2_6_5_4_3; + engineConfiguration->firingOrder = FO_1_8_7_2_6_5_4_3; engineConfiguration->triggerInputPins[0] = Gpio::A5; engineConfiguration->triggerInputPins[1] = Gpio::C6; diff --git a/firmware/config/engines/citroenBerlingoTU3JP.cpp b/firmware/config/engines/citroenBerlingoTU3JP.cpp index f28c3465bc..c3e68f4afc 100644 --- a/firmware/config/engines/citroenBerlingoTU3JP.cpp +++ b/firmware/config/engines/citroenBerlingoTU3JP.cpp @@ -21,9 +21,9 @@ void setCitroenBerlingoTU3JPConfiguration() { setCrankOperationMode(); engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2; engineConfiguration->globalTriggerAngleOffset = 114; - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.displacement = 1.360; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->displacement = 1.360; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->ignitionMode = IM_WASTED_SPARK; engineConfiguration->injectionMode = IM_BATCH; engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index e3f8daeb86..22090e7446 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -55,7 +55,7 @@ void setDodgeNeon1995EngineConfiguration() { // set ignition_mode 2 engineConfiguration->ignitionMode = IM_WASTED_SPARK; // set_firing_order 2 - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->firingOrder = FO_1_3_4_2; // set global_trigger_offset_angle 497 engineConfiguration->globalTriggerAngleOffset = 497; @@ -115,8 +115,8 @@ void setDodgeNeonNGCEngineConfiguration() { engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_SEQUENTIAL; engineConfiguration->ignitionMode = IM_WASTED_SPARK; - engineConfiguration->specs.displacement = 1.996; - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->displacement = 1.996; + engineConfiguration->cylindersCount = 4; /** * 77C diff --git a/firmware/config/engines/dodge_ram.cpp b/firmware/config/engines/dodge_ram.cpp index cc04a424c9..0305f17a01 100644 --- a/firmware/config/engines/dodge_ram.cpp +++ b/firmware/config/engines/dodge_ram.cpp @@ -20,9 +20,9 @@ void setDodgeRam1996() { engineConfiguration->map.sensor.type = MT_DODGE_NEON_2003; //Base engine setting - engineConfiguration->specs.cylindersCount = 8; - engineConfiguration->specs.firingOrder = FO_1_8_4_3_6_5_7_2; - engineConfiguration->specs.displacement = 5.2; + engineConfiguration->cylindersCount = 8; + engineConfiguration->firingOrder = FO_1_8_4_3_6_5_7_2; + engineConfiguration->displacement = 5.2; // set global_trigger_offset_angle -50 engineConfiguration->globalTriggerAngleOffset = -50; diff --git a/firmware/config/engines/ford_1995_inline_6.cpp b/firmware/config/engines/ford_1995_inline_6.cpp index 5f5b38a52d..fa63ee8b34 100644 --- a/firmware/config/engines/ford_1995_inline_6.cpp +++ b/firmware/config/engines/ford_1995_inline_6.cpp @@ -19,12 +19,12 @@ * @brief Default values for persistent properties */ void setFordInline6() { - engineConfiguration->specs.cylindersCount = 6; + engineConfiguration->cylindersCount = 6; setCamOperationMode(); engineConfiguration->ignitionMode = IM_ONE_COIL; - engineConfiguration->specs.firingOrder = FO_1_5_3_6_2_4; + engineConfiguration->firingOrder = FO_1_5_3_6_2_4; engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_BATCH; engineConfiguration->twoWireBatchInjection = true; diff --git a/firmware/config/engines/ford_aspire.cpp b/firmware/config/engines/ford_aspire.cpp index 44778660bb..b482af7e50 100644 --- a/firmware/config/engines/ford_aspire.cpp +++ b/firmware/config/engines/ford_aspire.cpp @@ -59,12 +59,12 @@ void setFordAspireEngineConfiguration() { // engineConfiguration->ignitionPinMode = OM_INVERTED; - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.displacement = 1.3; + engineConfiguration->cylindersCount = 4; + engineConfiguration->displacement = 1.3; // Denso 195500-2110 engineConfiguration->injector.flow = 119.8; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->globalTriggerAngleOffset = 175; setDefaultAspireMaps(); diff --git a/firmware/config/engines/ford_festiva.cpp b/firmware/config/engines/ford_festiva.cpp index 73bc286593..8db3ffd778 100644 --- a/firmware/config/engines/ford_festiva.cpp +++ b/firmware/config/engines/ford_festiva.cpp @@ -74,7 +74,7 @@ void setFordEscortGt() { setDensoTODO(config); engineConfiguration->globalFuelCorrection = 0.75; - engineConfiguration->specs.displacement = 1.839; + engineConfiguration->displacement = 1.839; setAlgorithm(LM_SPEED_DENSITY); static const uint16_t veRpmBins[] = diff --git a/firmware/config/engines/gm_ls_4.cpp b/firmware/config/engines/gm_ls_4.cpp index 7cdf39962e..54173dc542 100644 --- a/firmware/config/engines/gm_ls_4.cpp +++ b/firmware/config/engines/gm_ls_4.cpp @@ -19,10 +19,10 @@ void setGmLs4() { engineConfiguration->injectorCompensationMode = ICM_FixedRailPressure; engineConfiguration->injector.flow = 440; - engineConfiguration->specs.cylindersCount = 8; + engineConfiguration->cylindersCount = 8; setLeftRightBanksNeedBetterName(); - engineConfiguration->specs.firingOrder = FO_1_8_7_2_6_5_4_3; - engineConfiguration->specs.displacement = 6.2; + engineConfiguration->firingOrder = FO_1_8_7_2_6_5_4_3; + engineConfiguration->displacement = 6.2; engineConfiguration->etbIdleThrottleRange = 15; diff --git a/firmware/config/engines/honda_600.cpp b/firmware/config/engines/honda_600.cpp index 669acbd64d..c7e66a7d19 100644 --- a/firmware/config/engines/honda_600.cpp +++ b/firmware/config/engines/honda_600.cpp @@ -36,10 +36,10 @@ void setHonda600() { // set global_trigger_offset_angle 540 engineConfiguration->globalTriggerAngleOffset = 540; - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->cylindersCount = 4; engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_SEQUENTIAL; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->cranking.rpm = 800; // engineConfiguration->ignitionMode = IM_WASTED_SPARK; //IM_INDIVIDUAL_COILS; diff --git a/firmware/config/engines/honda_k_dbc.cpp b/firmware/config/engines/honda_k_dbc.cpp index c03fbb1804..381e5ec4d8 100644 --- a/firmware/config/engines/honda_k_dbc.cpp +++ b/firmware/config/engines/honda_k_dbc.cpp @@ -12,9 +12,9 @@ #endif // HW_PROTEUS void setHondaK() { - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.displacement = 2.4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->displacement = 2.4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->engineSyncCam = SC_Exhaust_First; engineConfiguration->trigger.type = TT_HONDA_K_CRANK_12_1; int magic = 12; // note that offset and VVT are related diff --git a/firmware/config/engines/mazda_miata.cpp b/firmware/config/engines/mazda_miata.cpp index cce81c5a74..c77cd12ed4 100644 --- a/firmware/config/engines/mazda_miata.cpp +++ b/firmware/config/engines/mazda_miata.cpp @@ -109,8 +109,8 @@ void common079721_2351() { engineConfiguration->engineChartSize = 300; - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->fuelPumpPin = Gpio::Unassigned; // fuel pump is not controlled by ECU on this engine @@ -142,7 +142,7 @@ void common079721_2351() { */ void setFrankensteinMiata1996() { commonMiataNa(); - engineConfiguration->specs.displacement = 1.839; + engineConfiguration->displacement = 1.839; #if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTable(config->ignitionTable, miataNA8_maf_advance_table); diff --git a/firmware/config/engines/mazda_miata_na8.cpp b/firmware/config/engines/mazda_miata_na8.cpp index 3ab5979bf8..cba2a0c7a9 100644 --- a/firmware/config/engines/mazda_miata_na8.cpp +++ b/firmware/config/engines/mazda_miata_na8.cpp @@ -49,7 +49,7 @@ static void commonNA8() { engineConfiguration->ignitionDwellForCrankingMs = 4; engineConfiguration->displayLogicLevelsInEngineSniffer = true; - engineConfiguration->specs.displacement = 1.839; + engineConfiguration->displacement = 1.839; strcpy(engineConfiguration->engineMake, ENGINE_MAKE_MAZDA); strcpy(engineConfiguration->engineCode, "NA8"); diff --git a/firmware/config/engines/mercedes.cpp b/firmware/config/engines/mercedes.cpp index 9b6ebc9edb..daecf95259 100644 --- a/firmware/config/engines/mercedes.cpp +++ b/firmware/config/engines/mercedes.cpp @@ -31,14 +31,14 @@ void setHellenMercedes128_4_cyl() { // is this M104 or M112 or both? void setHellenMercedes128_6_cyl() { common(); - engineConfiguration->specs.cylindersCount = 6; + engineConfiguration->cylindersCount = 6; // 1-4-2-5-3-6 M104 - engineConfiguration->specs.firingOrder = FO_1_4_3_6_2_5; // M112 + engineConfiguration->firingOrder = FO_1_4_3_6_2_5; // M112 } // M113 void setHellenMercedes128_8_cyl() { common(); - engineConfiguration->specs.cylindersCount = 8; - engineConfiguration->specs.firingOrder = FO_1_5_4_2_6_3_7_8; + engineConfiguration->cylindersCount = 8; + engineConfiguration->firingOrder = FO_1_5_4_2_6_3_7_8; } diff --git a/firmware/config/engines/nissan_vq.cpp b/firmware/config/engines/nissan_vq.cpp index 28685e6bb4..93d9319f90 100644 --- a/firmware/config/engines/nissan_vq.cpp +++ b/firmware/config/engines/nissan_vq.cpp @@ -15,9 +15,9 @@ void setHellen121nissanQR() { engineConfiguration->trigger.type = TT_NISSAN_QR25; - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; - engineConfiguration->specs.displacement = 2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; + engineConfiguration->displacement = 2; strcpy(engineConfiguration->engineCode, "QR"); engineConfiguration->camInputs[1 * CAMS_PER_BANK] = Gpio::Unassigned; @@ -35,9 +35,9 @@ static void setNissanVqEngineConfig() { setNissanMAF0031(config); engineConfiguration->trigger.type = TT_NISSAN_VQ35; - engineConfiguration->specs.cylindersCount = 6; - engineConfiguration->specs.firingOrder = FO_1_2_3_4_5_6; - engineConfiguration->specs.displacement = 4; + engineConfiguration->cylindersCount = 6; + engineConfiguration->firingOrder = FO_1_2_3_4_5_6; + engineConfiguration->displacement = 4; strcpy(engineConfiguration->engineCode, "VQ"); engineConfiguration->vvtMode[0] = VVT_NISSAN_VQ; @@ -81,7 +81,7 @@ void setHellen121nissanAltimaN16() { // https://en.wikipedia.org/wiki/Nissan_QG_engine // https://en.wikipedia.org/wiki/N-VCT setHellen121nissanQR(); - engineConfiguration->specs.displacement = 1.8; + engineConfiguration->displacement = 1.8; strcpy(engineConfiguration->engineCode, "N16"); } diff --git a/firmware/config/engines/sachs.cpp b/firmware/config/engines/sachs.cpp index f720c3875f..27bbe5b215 100644 --- a/firmware/config/engines/sachs.cpp +++ b/firmware/config/engines/sachs.cpp @@ -14,11 +14,11 @@ void setSachs() { - engineConfiguration->specs.displacement = 0.1; // 100cc - engineConfiguration->specs.cylindersCount = 1; + engineConfiguration->displacement = 0.1; // 100cc + engineConfiguration->cylindersCount = 1; setTwoStrokeOperationMode(); - engineConfiguration->specs.firingOrder = FO_1; + engineConfiguration->firingOrder = FO_1; engineConfiguration->engineChartSize = 400; setEgoSensor(ES_Innovate_MTX_L); diff --git a/firmware/config/engines/subaru.cpp b/firmware/config/engines/subaru.cpp index e64e053ae4..28a2c266c5 100644 --- a/firmware/config/engines/subaru.cpp +++ b/firmware/config/engines/subaru.cpp @@ -44,11 +44,11 @@ void setSubaruEJ18_MRE() { // engineConfiguration->isDoubleSolenoidIdle = true; - engineConfiguration->specs.displacement = 1.8; + engineConfiguration->displacement = 1.8; strcpy(engineConfiguration->engineMake, ENGINE_MAKE_SUBARU); strcpy(engineConfiguration->engineCode, "EJ18"); - engineConfiguration->specs.firingOrder = FO_1_3_2_4; + engineConfiguration->firingOrder = FO_1_3_2_4; engineConfiguration->injectionMode = IM_SEQUENTIAL; engineConfiguration->ignitionMode = IM_WASTED_SPARK; @@ -71,9 +71,9 @@ void setSubaruEG33Defaults() { engineConfiguration->trigger.type = TT_SUBARU_SVX; - engineConfiguration->specs.cylindersCount = 6; + engineConfiguration->cylindersCount = 6; setLeftRightBanksNeedBetterName(); - engineConfiguration->specs.firingOrder = FO_1_6_3_2_5_4; + engineConfiguration->firingOrder = FO_1_6_3_2_5_4; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; @@ -84,7 +84,7 @@ void setSubaruEG33Defaults() { engineConfiguration->fuelAlgorithm = LM_REAL_MAF; - engineConfiguration->specs.displacement = 3.30; + engineConfiguration->displacement = 3.30; engineConfiguration->injector.flow = 250; engineConfiguration->cranking.baseFuel = 5; // ??? diff --git a/firmware/config/engines/toyota_jzs147.cpp b/firmware/config/engines/toyota_jzs147.cpp index f5bd8bd5d6..6ec21fd6e7 100644 --- a/firmware/config/engines/toyota_jzs147.cpp +++ b/firmware/config/engines/toyota_jzs147.cpp @@ -26,9 +26,9 @@ static void common2jz() { setFrankensoConfiguration(); // default pinout - engineConfiguration->specs.displacement = 3.0; - engineConfiguration->specs.cylindersCount = 6; - engineConfiguration->specs.firingOrder = FO_1_5_3_6_2_4; + engineConfiguration->displacement = 3.0; + engineConfiguration->cylindersCount = 6; + engineConfiguration->firingOrder = FO_1_5_3_6_2_4; // set ignition_mode 1 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; diff --git a/firmware/config/engines/vw.cpp b/firmware/config/engines/vw.cpp index 9b785cf705..56c659a14b 100644 --- a/firmware/config/engines/vw.cpp +++ b/firmware/config/engines/vw.cpp @@ -32,8 +32,8 @@ void setVwAba() { //Base engine setting - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.displacement = 2.0; + engineConfiguration->cylindersCount = 4; + engineConfiguration->displacement = 2.0; engineConfiguration->injector.flow = 320; // 30lb/h // set algorithm 3 setAlgorithm(LM_SPEED_DENSITY); @@ -62,27 +62,27 @@ void setVwAba() { } void setHellen121Vag_5_cyl() { - engineConfiguration->specs.cylindersCount = 5; - engineConfiguration->specs.displacement = 2.5; - engineConfiguration->specs.firingOrder = FO_1_2_4_5_3; + engineConfiguration->cylindersCount = 5; + engineConfiguration->displacement = 2.5; + engineConfiguration->firingOrder = FO_1_2_4_5_3; } void setHellen121Vag_vr6_cyl() { - engineConfiguration->specs.cylindersCount = 6; - engineConfiguration->specs.firingOrder = FO_1_5_3_6_2_4; + engineConfiguration->cylindersCount = 6; + engineConfiguration->firingOrder = FO_1_5_3_6_2_4; } void setHellen121Vag_v6_cyl() { - engineConfiguration->specs.cylindersCount = 6; - engineConfiguration->specs.displacement = 2.7; + engineConfiguration->cylindersCount = 6; + engineConfiguration->displacement = 2.7; engineConfiguration->camInputs[1 * CAMS_PER_BANK] = Gpio::A7; // 87a - engineConfiguration->specs.firingOrder = FO_1_4_3_6_2_5; + engineConfiguration->firingOrder = FO_1_4_3_6_2_5; } void setHellen121Vag_8_cyl() { - engineConfiguration->specs.cylindersCount = 8; - engineConfiguration->specs.displacement = 4.2; - engineConfiguration->specs.firingOrder = FO_1_5_4_8_6_3_7_2; + engineConfiguration->cylindersCount = 8; + engineConfiguration->displacement = 4.2; + engineConfiguration->firingOrder = FO_1_5_4_8_6_3_7_2; } diff --git a/firmware/config/engines/vw_b6.cpp b/firmware/config/engines/vw_b6.cpp index 53935497e5..cfee8e08c6 100644 --- a/firmware/config/engines/vw_b6.cpp +++ b/firmware/config/engines/vw_b6.cpp @@ -28,8 +28,8 @@ static void commonPassatB6() { engineConfiguration->idlePidRpmDeadZone = 500; engineConfiguration->idleMode = IM_AUTO; - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->isPhaseSyncRequiredForIgnition = true; engineConfiguration->disableEtbWhenEngineStopped = true; diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 156eee9dae..13a44ea6bf 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -176,7 +176,7 @@ static void printEngineSnifferPinMappings() { printOutPin(PROTOCOL_WA_CHANNEL_2, engineConfiguration->logicAnalyzerPins[1]); #endif /* EFI_LOGIC_ANALYZER */ - int cylCount = minI(engineConfiguration->specs.cylindersCount, MAX_CYLINDER_COUNT); + int cylCount = minI(engineConfiguration->cylindersCount, MAX_CYLINDER_COUNT); for (int i = 0; i < cylCount; i++) { printOutPin(enginePins.coils[i].getShortName(), engineConfiguration->ignitionPins[i]); printOutPin(enginePins.trailingCoils[i].getShortName(), engineConfiguration->trailingCoilPins[i]); diff --git a/firmware/controllers/algo/airmass/maf_airmass.cpp b/firmware/controllers/algo/airmass/maf_airmass.cpp index 73afe70cec..a8a12c2efa 100644 --- a/firmware/controllers/algo/airmass/maf_airmass.cpp +++ b/firmware/controllers/algo/airmass/maf_airmass.cpp @@ -56,7 +56,7 @@ AirmassResult MafAirmass::getAirmassImpl(float massAirFlow, int rpm) const { // Now we have to divide among cylinders - on a 4 stroke, half of the cylinders happen every revolution // This math is floating point to work properly on engines with odd cylinder count - float halfCylCount = engineConfiguration->specs.cylindersCount / 2.0f; + float halfCylCount = engineConfiguration->cylindersCount / 2.0f; mass_t cylinderAirmass = airPerRevolution / halfCylCount; diff --git a/firmware/controllers/algo/airmass/speed_density_base.cpp b/firmware/controllers/algo/airmass/speed_density_base.cpp index e61d0ec186..0ed6ce9669 100644 --- a/firmware/controllers/algo/airmass/speed_density_base.cpp +++ b/firmware/controllers/algo/airmass/speed_density_base.cpp @@ -24,6 +24,6 @@ mass_t idealGasLaw(float volume, float pressure, float temperature) { } /*static*/ mass_t SpeedDensityBase::getAirmassImpl(float ve, float manifoldPressure, float temperature) { - mass_t cycleAir = ve * idealGasLaw(engineConfiguration->specs.displacement, manifoldPressure, temperature); - return cycleAir / engineConfiguration->specs.cylindersCount; + mass_t cycleAir = ve * idealGasLaw(engineConfiguration->displacement, manifoldPressure, temperature); + return cycleAir / engineConfiguration->cylindersCount; } diff --git a/firmware/controllers/algo/defaults/default_base_engine.cpp b/firmware/controllers/algo/defaults/default_base_engine.cpp index f80962f9b7..eb9df67049 100644 --- a/firmware/controllers/algo/defaults/default_base_engine.cpp +++ b/firmware/controllers/algo/defaults/default_base_engine.cpp @@ -16,7 +16,7 @@ static void setDefaultAlternatorParameters() { /* Cylinder to bank mapping */ void setLeftRightBanksNeedBetterName() { - for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) { + for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { engineConfiguration->cylinderBankSelect[i] = i % 2; } } @@ -37,9 +37,9 @@ static void setDefaultHPFP() { void setDefaultBaseEngine() { // Base Engine Settings - engineConfiguration->specs.cylindersCount = 4; - engineConfiguration->specs.displacement = 2; - engineConfiguration->specs.firingOrder = FO_1_3_4_2; + engineConfiguration->cylindersCount = 4; + engineConfiguration->displacement = 2; + engineConfiguration->firingOrder = FO_1_3_4_2; engineConfiguration->compressionRatio = 9; engineConfiguration->vssFilterReciprocal = VSS_FILTER_MIN; diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index 46973fab94..d1eed2805c 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -184,7 +184,7 @@ void EngineState::periodicFastCallback() { } // Now apply that to per-cylinder fueling and timing - for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) { + for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { uint8_t bankIndex = engineConfiguration->cylinderBankSelect[i]; auto bankTrim =engine->stftCorrection[bankIndex]; auto cylinderTrim = getCylinderFuelTrim(i, rpm, fuelLoad); diff --git a/firmware/controllers/algo/event_registry.h b/firmware/controllers/algo/event_registry.h index e72f404b0f..1e298ed463 100644 --- a/firmware/controllers/algo/event_registry.h +++ b/firmware/controllers/algo/event_registry.h @@ -66,7 +66,7 @@ public: */ int sparkId = 0; /** - * [0, specs.cylindersCount) + * [0, cylindersCount) */ int cylinderIndex = 0; int8_t cylinderNumber = 0; diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 2a4d15dc93..1ce8ba3307 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -186,7 +186,7 @@ static float getBaseFuelMass(int rpm) { engine->engineState.fuelingLoad = airmass.EngineLoadPercent; engine->engineState.ignitionLoad = engine->fuelComputer.getLoadOverride(airmass.EngineLoadPercent, engineConfiguration->ignOverrideMode); - auto gramPerCycle = airmass.CylinderAirmass * engineConfiguration->specs.cylindersCount; + auto gramPerCycle = airmass.CylinderAirmass * engineConfiguration->cylindersCount; auto gramPerMs = rpm == 0 ? 0 : gramPerCycle / getEngineCycleDuration(rpm); // convert g/s -> kg/h @@ -241,7 +241,7 @@ int getNumberOfInjections(injection_mode_e mode) { switch (mode) { case IM_SIMULTANEOUS: case IM_SINGLE_POINT: - return engineConfiguration->specs.cylindersCount; + return engineConfiguration->cylindersCount; case IM_BATCH: return 2; case IM_SEQUENTIAL: @@ -257,7 +257,7 @@ float getInjectionModeDurationMultiplier() { switch (mode) { case IM_SIMULTANEOUS: { - auto cylCount = engineConfiguration->specs.cylindersCount; + auto cylCount = engineConfiguration->cylindersCount; if (cylCount == 0) { // we can end up here during configuration reset @@ -428,8 +428,8 @@ float getCrankingFuel(float baseFuel) { * Should we bother caching 'getStandardAirCharge' result or can we afford to run the math every time we calculate fuel? */ float getStandardAirCharge() { - float totalDisplacement = engineConfiguration->specs.displacement; - float cylDisplacement = totalDisplacement / engineConfiguration->specs.cylindersCount; + float totalDisplacement = engineConfiguration->displacement; + float cylDisplacement = totalDisplacement / engineConfiguration->cylindersCount; // Calculation of 100% VE air mass in g/cyl - 1 cylinder filling at 1.204/L // 101.325kpa, 20C diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 27bb274499..80dcb82613 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -494,8 +494,8 @@ void commonInitEngineController() { // Returns false if there's an obvious problem with the loaded configuration bool validateConfig() { - if (engineConfiguration->specs.cylindersCount > MAX_CYLINDER_COUNT) { - firmwareError(OBD_PCM_Processor_Fault, "Invalid cylinder count: %d", engineConfiguration->specs.cylindersCount); + if (engineConfiguration->cylindersCount > MAX_CYLINDER_COUNT) { + firmwareError(OBD_PCM_Processor_Fault, "Invalid cylinder count: %d", engineConfiguration->cylindersCount); return false; } diff --git a/firmware/controllers/engine_cycle/fuel_schedule.cpp b/firmware/controllers/engine_cycle/fuel_schedule.cpp index 7e3a954841..37dfc47056 100644 --- a/firmware/controllers/engine_cycle/fuel_schedule.cpp +++ b/firmware/controllers/engine_cycle/fuel_schedule.cpp @@ -153,7 +153,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) { injectorIndex = getCylinderId(i) - 1; } else if (mode == IM_BATCH) { // Loop over the first half of the firing order twice - injectorIndex = i % (engineConfiguration->specs.cylindersCount / 2); + injectorIndex = i % (engineConfiguration->cylindersCount / 2); } else { firmwareError(CUSTOM_OBD_UNEXPECTED_INJECTION_MODE, "Unexpected injection mode %d", mode); injectorIndex = 0; @@ -168,7 +168,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) { // Compute the position of this cylinder's twin in the firing order // Each injector gets fired as a primary (the same as sequential), but also // fires the injector 360 degrees later in the firing order. - int secondOrder = (i + (engineConfiguration->specs.cylindersCount / 2)) % engineConfiguration->specs.cylindersCount; + int secondOrder = (i + (engineConfiguration->cylindersCount / 2)) % engineConfiguration->cylindersCount; int secondIndex = getCylinderId(secondOrder) - 1; secondOutput = &enginePins.injectors[secondIndex]; } else { @@ -193,7 +193,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) { } void FuelSchedule::addFuelEvents() { - for (size_t cylinderIndex = 0; cylinderIndex < engineConfiguration->specs.cylindersCount; cylinderIndex++) { + for (size_t cylinderIndex = 0; cylinderIndex < engineConfiguration->cylindersCount; cylinderIndex++) { bool result = addFuelEventsForCylinder(cylinderIndex); if (!result) { @@ -212,7 +212,7 @@ void FuelSchedule::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase, return; } - for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) { + for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { elements[i].onTriggerTooth(rpm, nowNt, currentPhase, nextPhase); } } diff --git a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp index 0324b9467d..1f9cf51cce 100644 --- a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp +++ b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp @@ -70,7 +70,7 @@ angle_t HpfpLobe::findNextLobe() { // As a percent of the full pump stroke float HpfpQuantity::calcFuelPercent(int rpm) { float fuel_requested_cc_per_cycle = - engine->engineState.injectionMass[0] * (1.f / fuelDensity) * engineConfiguration->specs.cylindersCount; + engine->engineState.injectionMass[0] * (1.f / fuelDensity) * engineConfiguration->cylindersCount; float fuel_requested_cc_per_lobe = fuel_requested_cc_per_cycle / engineConfiguration->hpfpCamLobes; return 100.f * fuel_requested_cc_per_lobe / engineConfiguration->hpfpPumpVolume + diff --git a/firmware/controllers/engine_cycle/map_averaging.cpp b/firmware/controllers/engine_cycle/map_averaging.cpp index dce4cf88f1..65720c5733 100644 --- a/firmware/controllers/engine_cycle/map_averaging.cpp +++ b/firmware/controllers/engine_cycle/map_averaging.cpp @@ -175,8 +175,8 @@ void refreshMapAveragingPreCalc() { angle_t offsetAngle = engine->triggerCentral.triggerFormDetails.eventAngles[engineConfiguration->mapAveragingSchedulingAtIndex]; efiAssertVoid(CUSTOM_ERR_MAP_AVG_OFFSET, !cisnan(offsetAngle), "offsetAngle"); - for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) { - angle_t cylinderOffset = getEngineCycle(getEngineRotationState()->getOperationMode()) * i / engineConfiguration->specs.cylindersCount; + for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { + angle_t cylinderOffset = getEngineCycle(getEngineRotationState()->getOperationMode()) * i / engineConfiguration->cylindersCount; efiAssertVoid(CUSTOM_ERR_MAP_CYL_OFFSET, !cisnan(cylinderOffset), "cylinderOffset"); // part of this formula related to specific cylinder offset is never changing - we can // move the loop into start-up calculation and not have this loop as part of periodic calculation @@ -187,7 +187,7 @@ void refreshMapAveragingPreCalc() { } engine->engineState.mapAveragingDuration = interpolate2d(rpm, c->samplingWindowBins, c->samplingWindow); } else { - for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) { + for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { engine->engineState.mapAveragingStart[i] = NAN; } engine->engineState.mapAveragingDuration = NAN; @@ -217,7 +217,7 @@ void mapAveragingTriggerCallback( } // todo: this could be pre-calculated - int samplingCount = engineConfiguration->measureMapOnlyInOneCylinder ? 1 : engineConfiguration->specs.cylindersCount; + int samplingCount = engineConfiguration->measureMapOnlyInOneCylinder ? 1 : engineConfiguration->cylindersCount; for (int i = 0; i < samplingCount; i++) { angle_t samplingStart = engine->engineState.mapAveragingStart[i]; diff --git a/firmware/controllers/limp_manager.cpp b/firmware/controllers/limp_manager.cpp index a77d52a20f..3860788242 100644 --- a/firmware/controllers/limp_manager.cpp +++ b/firmware/controllers/limp_manager.cpp @@ -21,7 +21,7 @@ static bool noFiringUntilVvtSync(vvt_mode_e vvtMode) { // Odd cylinder count engines don't work properly with wasted spark, so wait for full sync (so that sequential works) // See https://github.com/rusefi/rusefi/issues/4195 for the issue to properly support this case - if (engineConfiguration->specs.cylindersCount > 1 && engineConfiguration->specs.cylindersCount % 2 == 1) { + if (engineConfiguration->cylindersCount > 1 && engineConfiguration->cylindersCount % 2 == 1) { return true; } diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index a1d5fb1a6e..4cc099fe97 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -47,7 +47,7 @@ float IFuelComputer::getTChargeCoefficient(int rpm, float tps) { constexpr floatms_t gramsPerMsToKgPerHour = (3600.0f * 1000.0f) / 1000.0f; // We're actually using an 'old' airMass calculated for the previous cycle, but it's ok, we're not having any self-excitaton issues - floatms_t airMassForEngine = sdAirMassInOneCylinder * engineConfiguration->specs.cylindersCount; + floatms_t airMassForEngine = sdAirMassInOneCylinder * engineConfiguration->cylindersCount; // airMass is in grams per 1 cycle for 1 cyl. Convert it to airFlow in kg/h for the engine. // And if the engine is stopped (0 rpm), then airFlow is also zero (avoiding NaN division) floatms_t airFlow = (rpm == 0) ? 0 : airMassForEngine * gramsPerMsToKgPerHour / getEngineCycleDuration(rpm); diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index c4fbcb545b..a7f3c4bcf5 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -270,7 +270,7 @@ void EnginePins::startAuxValves() { void EnginePins::startIgnitionPins() { #if EFI_PROD_CODE - for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) { + for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { NamedOutputPin *trailingOutput = &enginePins.trailingCoils[i]; if (isPinOrModeChanged(trailingCoilPins[i], ignitionPinMode)) { trailingOutput->initPin(trailingOutput->name, engineConfiguration->trailingCoilPins[i], &engineConfiguration->ignitionPinMode); @@ -287,7 +287,7 @@ void EnginePins::startIgnitionPins() { void EnginePins::startInjectionPins() { #if EFI_PROD_CODE // todo: should we move this code closer to the injection logic? - for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) { + for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { NamedOutputPin *output = &enginePins.injectors[i]; if (isPinOrModeChanged(injectionPins[i], injectionPinMode)) { output->initPin(output->name, engineConfiguration->injectionPins[i], diff --git a/firmware/controllers/system/injection_gpio.cpp b/firmware/controllers/system/injection_gpio.cpp index 7d8edf1711..41116254e7 100644 --- a/firmware/controllers/system/injection_gpio.cpp +++ b/firmware/controllers/system/injection_gpio.cpp @@ -13,14 +13,14 @@ extern bool printFuelDebug; void startSimultaneousInjection(void*) { efitick_t nowNt = getTimeNowNt(); - for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) { + for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { enginePins.injectors[i].open(nowNt); } } void endSimultaneousInjectionOnlyTogglePins() { efitick_t nowNt = getTimeNowNt(); - for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) { + for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { enginePins.injectors[i].close(nowNt); } } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 3d9c134da3..89318da691 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -506,8 +506,7 @@ ThermistorConf iat; int hip9011PrescalerAndSDO;value '6' for 8MHz hw osc\nread hip9011 datasheet for details\ntodo split into two bit fields;"integer", 1, 0, 0, 32, 0 float knockBandCustom;We calculate knock band based of cylinderBore\n Use this to override - kHz knock band override;"kHz", 1, 0, 0, 20, 2 -struct_no_prefix specs_s -float displacement;Engine volume/capacity, in litres\nsee also cylindersCount;"L", 1, 0, 0, 1000, 2 +uint16_t autoscale displacement;Engine displacement in litres;"L", 0.001, 0, 0, 65, 3 uint32_t cylindersCount;Number of cylinder the engine has.;"", 1, 0, 1, @@MAX_CYLINDER_COUNT@@, 0 @@ -519,10 +518,9 @@ uint32_t cylindersCount;Number of cylinder the engine has.;"", 1, 0, 1, @@MAX_CY custom firing_order_e 1 bits, U08, @OFFSET@, [0:5], "One Cylinder", "1-3-4-2", "1-2-4-3", "1-3-2-4", "1-5-3-6-2-4", "1-8-4-3-6-5-7-2", "1-2-4-5-3", "1-4-2-5-3-6", "1-2", "1-2-3-4-5-6", "1-2-3", "1-8-7-2-6-5-4-3", "1-5-4-2-6-3-7-8", "1-6-3-2-5-4", "1-10-9-4-3-6-5-8-7_2", "1-7-5-11-3-9-6-12-2-8-4-10", "1-7-4-10-2-8-6-12-3-9-5-11", "1-4-3-2", "1-12-5-8-3-10-6-7-2-11-4-9", "1-2-7-8-4-5-6-3", "1-3-7-2-6-5-4-8", "1-2-3-4-5-6-7-8-9", "INVALID", "1-2-3-4-5-6-7-8-9-10-11-12", "1-3-2", "1-2-3-4-5-6-7-8", "1-5-4-8-6-3-7-2", "1-4-3-6-2-5", "1-8-7-3-6-5-4-2", "1-6-2-4-3-5", "1-6-5-4-3-2", "1-4-5-2-3-6", "fo32", "fo33", "fo34", "fo35", "fo36", "fo37" firing_order_e firingOrder; -end_struct - specs_s specs - float cylinderBore;Cylinder diameter in mm.;"mm", 1, 0, 0, 20000, 2 + +float cylinderBore;Cylinder diameter in mm.;"mm", 1, 0, 0, 20000, 2 #define engine_load_mode_e_enum "Speed Density", "MAF Air Charge", "Alpha-N", "Lua" diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index e64cd61bbd..69b8ae06e4 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -355,7 +355,7 @@ void setupSimpleTestEngineWithMaf(EngineTestHelper *eth, injection_mode_e inject Engine *engine = ð->engine; engineConfiguration->isIgnitionEnabled = false; // let's focus on injection - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->cylindersCount = 4; // a bit of flexibility - the mode may be changed by some tests engineConfiguration->injectionMode = injectionMode; // set cranking mode (it's used by getCurrentInjectionMode()) diff --git a/unit_tests/tests/ignition_injection/test_fuel_math.cpp b/unit_tests/tests/ignition_injection/test_fuel_math.cpp index 6e2ed50c9d..45f2acf885 100644 --- a/unit_tests/tests/ignition_injection/test_fuel_math.cpp +++ b/unit_tests/tests/ignition_injection/test_fuel_math.cpp @@ -13,25 +13,25 @@ TEST(FuelMath, getStandardAirCharge) { EngineTestHelper eth(TEST_ENGINE); // Miata 1839cc 4cyl - engineConfiguration->specs.displacement = 1.839f; - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->displacement = 1.839f; + engineConfiguration->cylindersCount = 4; EXPECT_FLOAT_EQ(0.5535934f, getStandardAirCharge()); // LS 5.3 liter v8 - engineConfiguration->specs.displacement = 5.327f; - engineConfiguration->specs.cylindersCount = 8; + engineConfiguration->displacement = 5.327f; + engineConfiguration->cylindersCount = 8; EXPECT_FLOAT_EQ(0.80179232f, getStandardAirCharge()); // Chainsaw - single cylinder 32cc - engineConfiguration->specs.displacement = 0.032f; - engineConfiguration->specs.cylindersCount = 1; + engineConfiguration->displacement = 0.032f; + engineConfiguration->cylindersCount = 1; EXPECT_FLOAT_EQ(0.038531788f, getStandardAirCharge()); // Leopard 1 47.666 liter v12 - engineConfiguration->specs.displacement = 47.666f; - engineConfiguration->specs.cylindersCount = 12; + engineConfiguration->displacement = 47.666f; + engineConfiguration->cylindersCount = 12; EXPECT_FLOAT_EQ(4.782959f, getStandardAirCharge()); } @@ -39,8 +39,8 @@ TEST(FuelMath, getStandardAirCharge) { TEST(AirmassModes, AlphaNNormal) { EngineTestHelper eth(TEST_ENGINE); // 4 cylinder 4 liter = easy math - engineConfiguration->specs.displacement = 4.0f; - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->displacement = 4.0f; + engineConfiguration->cylindersCount = 4; StrictMock veTable; diff --git a/unit_tests/tests/ignition_injection/test_ignition_scheduling.cpp b/unit_tests/tests/ignition_injection/test_ignition_scheduling.cpp index 304f6bf91b..e662cd6d97 100644 --- a/unit_tests/tests/ignition_injection/test_ignition_scheduling.cpp +++ b/unit_tests/tests/ignition_injection/test_ignition_scheduling.cpp @@ -56,8 +56,8 @@ TEST(ignition, trailingSpark) { .WillRepeatedly(Return(AirmassResult{0.1008f, 50.0f})); setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð); - engineConfiguration->specs.cylindersCount = 1; - engineConfiguration->specs.firingOrder = FO_1; + engineConfiguration->cylindersCount = 1; + engineConfiguration->firingOrder = FO_1; engineConfiguration->isInjectionEnabled = false; engineConfiguration->isIgnitionEnabled = true; diff --git a/unit_tests/tests/test_hpfp.cpp b/unit_tests/tests/test_hpfp.cpp index 6c101aaed8..e1f5853c4b 100755 --- a/unit_tests/tests/test_hpfp.cpp +++ b/unit_tests/tests/test_hpfp.cpp @@ -53,7 +53,7 @@ TEST(HPFP, Lobe) { TEST(HPFP, InjectionReplacementFuel) { EngineTestHelper eth(TEST_ENGINE); - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->cylindersCount = 4; engineConfiguration->hpfpCamLobes = 4; engine->engineState.injectionMass[0] = 0.05 /* cc/cyl */ * fuelDensity; engineConfiguration->hpfpPumpVolume = 0.2; // cc/lobe @@ -71,11 +71,11 @@ TEST(HPFP, InjectionReplacementFuel) { EXPECT_FLOAT_EQ(math.calcFuelPercent(1000), 50 * 1.333333333f); // More cylinders! - engineConfiguration->specs.cylindersCount = 6; + engineConfiguration->cylindersCount = 6; EXPECT_FLOAT_EQ(math.calcFuelPercent(1000), 50 * 2.); // Ooops we maxed out // Compensation testing - engineConfiguration->specs.cylindersCount = + engineConfiguration->cylindersCount = engineConfiguration->hpfpCamLobes; // Make math easier for (int i = 0; i < HPFP_COMPENSATION_SIZE; i++) { // one bin every 1000 RPM @@ -106,7 +106,7 @@ TEST(HPFP, InjectionReplacementFuel) { TEST(HPFP, PI) { EngineTestHelper eth(TEST_ENGINE); - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->cylindersCount = 4; engineConfiguration->hpfpCamLobes = 4; engine->engineState.injectionMass[0] = 0.05 /* cc/cyl */ * fuelDensity; engineConfiguration->hpfpPumpVolume = 0.2; // cc/lobe @@ -163,7 +163,7 @@ TEST(HPFP, PI) { TEST(HPFP, Angle) { EngineTestHelper eth(TEST_ENGINE); - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->cylindersCount = 4; engineConfiguration->hpfpCamLobes = 4; engine->engineState.injectionMass[0] = 0.05 /* cc/cyl */ * fuelDensity; engineConfiguration->hpfpPumpVolume = 0.2; // cc/lobe @@ -209,7 +209,7 @@ TEST(HPFP, Angle) { TEST(HPFP, Schedule) { EngineTestHelper eth(TEST_ENGINE); - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->cylindersCount = 4; engineConfiguration->hpfpCamLobes = 4; engineConfiguration->hpfpPumpVolume = 0.2; // cc/lobe diff --git a/unit_tests/tests/test_hpfp_integrated.cpp b/unit_tests/tests/test_hpfp_integrated.cpp index ee680a0d32..b415d9b6a9 100644 --- a/unit_tests/tests/test_hpfp_integrated.cpp +++ b/unit_tests/tests/test_hpfp_integrated.cpp @@ -12,7 +12,7 @@ TEST(HPFP, IntegratedSchedule) { engineConfiguration->hpfpValvePin = Gpio::A2; // arbitrary }); - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->cylindersCount = 4; engineConfiguration->hpfpCamLobes = 3; engineConfiguration->hpfpPumpVolume = 0.2; // cc/lobe diff --git a/unit_tests/tests/trigger/test_trigger_decoder.cpp b/unit_tests/tests/trigger/test_trigger_decoder.cpp index 508593ff0a..15ec07620d 100644 --- a/unit_tests/tests/trigger/test_trigger_decoder.cpp +++ b/unit_tests/tests/trigger/test_trigger_decoder.cpp @@ -960,7 +960,7 @@ TEST(big, testSparkReverseOrderBug319) { engine->tdcMarkEnabled = false; engineConfiguration->isInjectionEnabled = false; - engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->cylindersCount = 4; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; setConstantDwell(45);