Programmatically replace ENGINE() and CONFIG() with engine-> etc (#3565)

git grep -l -w ENGINE | xargs sed -i -r "s/ENGINE\(([]a-zA-Z_0-9.[]+)\)/engine->\1/g"

git grep -l -w CONFIG | xargs sed -i -r "s/([^a-zA-Z_])CONFIG\(([]a-zA-Z_0-9.[]+)\)/\1engineConfiguration->\2/g"
This commit is contained in:
Scott Smith 2021-11-17 00:54:21 -08:00 committed by GitHub
parent 70ad9724c0
commit 823d9a07e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
186 changed files with 1360 additions and 1360 deletions

View File

@ -122,7 +122,7 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->isSdCardEnabled = true;
CONFIG(enableSoftwareKnock) = true;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->boostControlPin = H144_LS_6;
engineConfiguration->acSwitch = H144_IN_D_AUX3;
@ -168,5 +168,5 @@ void setSdCardConfigurationOverrides(void) {
engineConfiguration->spi2misoPin = H_SPI2_MISO;
engineConfiguration->spi2sckPin = H_SPI2_SCK;
engineConfiguration->sdCardCsPin = H_SPI2_CS;
CONFIG(is_enabled_spi_2) = true;
engineConfiguration->is_enabled_spi_2 = true;
}

View File

@ -129,8 +129,8 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->displayLogicLevelsInEngineSniffer = true;
engineConfiguration->isSdCardEnabled = true;
CONFIG(enableSoftwareKnock) = true;
CONFIG(canNbcType) = CAN_BUS_NISSAN_VQ;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->canNbcType = CAN_BUS_NISSAN_VQ;
engineConfiguration->canTxPin = GPIOD_1;
engineConfiguration->canRxPin = GPIOD_0;
@ -146,7 +146,7 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->etbIo[0].directionPin1 = GPIOD_15; // out_pwm7
engineConfiguration->etbIo[0].directionPin2 = GPIOD_14; // out_pwm6
engineConfiguration->etbIo[0].controlPin = GPIOD_13; // ETB_EN out_pwm1
CONFIG(etb_use_two_wires) = true;
engineConfiguration->etb_use_two_wires = true;
// Some sensible defaults for other options
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
@ -159,7 +159,7 @@ void setBoardDefaultConfiguration(void) {
// Bosch VQ40 VR56 VK56 0280158007
engineConfiguration->injector.flow = 296.2;
strcpy(CONFIG(engineMake), ENGINE_MAKE_NISSAN);
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_NISSAN);
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS;
@ -197,5 +197,5 @@ void setSdCardConfigurationOverrides(void) {
// engineConfiguration->spi2misoPin = GPIOB_14;
// engineConfiguration->spi2sckPin = GPIOB_13;
// engineConfiguration->sdCardCsPin = GPIOB_12;
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
}

View File

@ -83,10 +83,10 @@ static void setupDefaultSensorInputs() {
engineConfiguration->throttlePedalPositionAdcChannel = H144_IN_PPS; // 34 In PPS1
engineConfiguration->throttlePedalPositionSecondAdcChannel = H144_IN_AUX2; // 35 In PPS2
CONFIG(throttlePedalUpVoltage) = 0.4;
CONFIG(throttlePedalWOTVoltage) = 2;
CONFIG(throttlePedalSecondaryUpVoltage) = 0.7;
CONFIG(throttlePedalSecondaryWOTVoltage) = 4.1;
engineConfiguration->throttlePedalUpVoltage = 0.4;
engineConfiguration->throttlePedalWOTVoltage = 2;
engineConfiguration->throttlePedalSecondaryUpVoltage = 0.7;
engineConfiguration->throttlePedalSecondaryWOTVoltage = 4.1;
engineConfiguration->mafAdcChannel = EFI_ADC_10;
engineConfiguration->map.sensor.hwChannel = EFI_ADC_11;
@ -139,7 +139,7 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->etbIo[0].directionPin1 = GPIOC_6; // out_pwm2
engineConfiguration->etbIo[0].directionPin2 = GPIOC_7; // out_pwm3
engineConfiguration->etbIo[0].controlPin = GPIOA_8; // ETB_EN out_io12
CONFIG(etb_use_two_wires) = true;
engineConfiguration->etb_use_two_wires = true;
setBoschVAGETB();
@ -151,7 +151,7 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->vvtMode[0] = VVT_BOSCH_QUICK_START;
engineConfiguration->map.sensor.type = MT_BOSCH_2_5;
CONFIG(enableSoftwareKnock) = true;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->fuelPumpPin = H144_OUT_IO3;
engineConfiguration->malfunctionIndicatorPin = GPIOG_4; // 47 - CEL
@ -172,8 +172,8 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
setAlgorithm(LM_SPEED_DENSITY);
strcpy(CONFIG(engineMake), ENGINE_MAKE_VAG);
strcpy(CONFIG(engineCode), "base");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_VAG);
strcpy(engineConfiguration->engineCode, "base");
engineConfiguration->specs.cylindersCount = 4;
engineConfiguration->specs.firingOrder = FO_1_3_4_2;
@ -203,5 +203,5 @@ void setSdCardConfigurationOverrides(void) {
// engineConfiguration->spi2misoPin = GPIOB_14;
// engineConfiguration->spi2sckPin = GPIOB_13;
// engineConfiguration->sdCardCsPin = GPIOB_12;
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
}

View File

@ -132,16 +132,16 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->isSdCardEnabled = true;
CONFIG(enableSoftwareKnock) = true;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->fuelPumpPin = GPIOD_15;
engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED;
engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8
engineConfiguration->mainRelayPin = GPIO_UNASSIGNED;
CONFIG(starterControlPin) = H176_OUT_IO10;
CONFIG(startStopButtonPin) = H176_IN_A16;
CONFIG(startStopButtonMode) = PI_PULLDOWN;
engineConfiguration->starterControlPin = H176_OUT_IO10;
engineConfiguration->startStopButtonPin = H176_IN_A16;
engineConfiguration->startStopButtonMode = PI_PULLDOWN;
// "required" hardware is done - set some reasonable defaults
setupDefaultSensorInputs();
@ -164,10 +164,10 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->etbIo[0].directionPin1 = H176_OUT_PWM2;
engineConfiguration->etbIo[0].directionPin2 = H176_OUT_PWM3;
engineConfiguration->etbIo[0].controlPin = H176_OUT_PWM1; // ETB_EN
CONFIG(etb_use_two_wires) = true;
engineConfiguration->etb_use_two_wires = true;
strcpy(CONFIG(engineMake), ENGINE_MAKE_MERCEDES);
strcpy(CONFIG(engineCode), "");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_MERCEDES);
strcpy(engineConfiguration->engineCode, "");
/**
* Jimmy best tune
@ -197,5 +197,5 @@ void setSdCardConfigurationOverrides(void) {
engineConfiguration->spi2misoPin = H_SPI2_MISO;
engineConfiguration->spi2sckPin = H_SPI2_SCK;
engineConfiguration->sdCardCsPin = H_SPI2_CS;
CONFIG(is_enabled_spi_2) = true;
engineConfiguration->is_enabled_spi_2 = true;
}

View File

@ -74,7 +74,7 @@ static void setupDefaultSensorInputs() {
engineConfiguration->tps1_1AdcChannel = H144_IN_TPS;
engineConfiguration->tps1_2AdcChannel = H144_IN_AUX1;
CONFIG(useETBforIdleControl) = true;
engineConfiguration->useETBforIdleControl = true;
engineConfiguration->throttlePedalUpVoltage = 0.73;
engineConfiguration->throttlePedalWOTVoltage = 4.0;
@ -131,8 +131,8 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->displayLogicLevelsInEngineSniffer = true;
engineConfiguration->isSdCardEnabled = true;
CONFIG(enableSoftwareKnock) = true;
CONFIG(canNbcType) = CAN_BUS_GENESIS_COUPE;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->canNbcType = CAN_BUS_GENESIS_COUPE;
engineConfiguration->canTxPin = H176_CAN_TX;
engineConfiguration->canRxPin = H176_CAN_RX;
@ -150,14 +150,14 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->etbIo[0].directionPin1 = H144_OUT_PWM3;
engineConfiguration->etbIo[0].directionPin2 = H144_OUT_PWM2;
engineConfiguration->etbIo[0].controlPin = H144_OUT_IO12;
CONFIG(etb_use_two_wires) = true;
engineConfiguration->etb_use_two_wires = true;
// wastegate DC motor
engineConfiguration->etbIo[1].directionPin1 = H144_OUT_PWM4;
engineConfiguration->etbIo[1].directionPin2 = H144_OUT_PWM5;
engineConfiguration->etbIo[1].controlPin = H144_OUT_IO13;
CONFIG(etb_use_two_wires) = true;
CONFIG(etbFunctions)[1] = ETB_Wastegate;
engineConfiguration->etb_use_two_wires = true;
engineConfiguration->etbFunctions[1] = ETB_Wastegate;
// Some sensible defaults for other options
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
@ -172,8 +172,8 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->specs.cylindersCount = 4;
engineConfiguration->specs.firingOrder = FO_1_3_4_2;
engineConfiguration->specs.displacement = 1.998;
strcpy(CONFIG(engineMake), ENGINE_MAKE_Hyundai);
strcpy(CONFIG(engineCode), "Theta II");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_Hyundai);
strcpy(engineConfiguration->engineCode, "Theta II");
engineConfiguration->globalTriggerAngleOffset = 90;
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
@ -199,5 +199,5 @@ void setSdCardConfigurationOverrides(void) {
engineConfiguration->spi2misoPin = H_SPI2_MISO;
engineConfiguration->spi2sckPin = H_SPI2_SCK;
engineConfiguration->sdCardCsPin = H_SPI2_CS;
CONFIG(is_enabled_spi_2) = true;
engineConfiguration->is_enabled_spi_2 = true;
}

View File

@ -127,7 +127,7 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->isSdCardEnabled = true;
CONFIG(enableSoftwareKnock) = true;
engineConfiguration->enableSoftwareKnock = true;
// these stm32 pins do not match hellen_meta, is that because hellenNA6 is not using latest MCU version?
engineConfiguration->acRelayPin = GPIOH_15; // 1J - AC Relay
@ -173,5 +173,5 @@ void setSdCardConfigurationOverrides(void) {
// engineConfiguration->spi2misoPin = GPIOB_14;
// engineConfiguration->spi2sckPin = GPIOB_13;
// engineConfiguration->sdCardCsPin = GPIOB_12;
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
}

View File

@ -131,7 +131,7 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->isSdCardEnabled = true;
CONFIG(enableSoftwareKnock) = true;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->acRelayPin = GPIOH_15;
engineConfiguration->acSwitch = GPIOB_0;
@ -184,5 +184,5 @@ void setSdCardConfigurationOverrides(void) {
// engineConfiguration->spi2misoPin = GPIOB_14;
// engineConfiguration->spi2sckPin = GPIOB_13;
// engineConfiguration->sdCardCsPin = GPIOB_12;
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
}

View File

@ -184,5 +184,5 @@ void setSdCardConfigurationOverrides(void) {
// engineConfiguration->spi2misoPin = GPIOB_14;
// engineConfiguration->spi2sckPin = GPIOB_13;
// engineConfiguration->sdCardCsPin = GPIOB_12;
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
}

View File

@ -126,8 +126,8 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->displayLogicLevelsInEngineSniffer = true;
engineConfiguration->isSdCardEnabled = true;
CONFIG(enableSoftwareKnock) = true;
CONFIG(canNbcType) = CAN_BUS_NISSAN_VQ;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->canNbcType = CAN_BUS_NISSAN_VQ;
engineConfiguration->canTxPin = GPIOD_1;
engineConfiguration->canRxPin = GPIOD_0;
@ -144,7 +144,7 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->etbIo[0].directionPin1 = GPIOD_15; // out_pwm7
engineConfiguration->etbIo[0].directionPin2 = GPIOD_14; // out_pwm6
engineConfiguration->etbIo[0].controlPin = GPIOD_13; // ETB_EN out_pwm1
CONFIG(etb_use_two_wires) = true;
engineConfiguration->etb_use_two_wires = true;
// Some sensible defaults for other options
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
@ -157,7 +157,7 @@ void setBoardDefaultConfiguration(void) {
// Bosch VQ40 VR56 VK56 0280158007
engineConfiguration->injector.flow = 296.2;
strcpy(CONFIG(engineMake), ENGINE_MAKE_NISSAN);
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_NISSAN);
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS;
@ -195,5 +195,5 @@ void setSdCardConfigurationOverrides(void) {
// engineConfiguration->spi2misoPin = GPIOB_14;
// engineConfiguration->spi2sckPin = GPIOB_13;
// engineConfiguration->sdCardCsPin = GPIOB_12;
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
}

View File

@ -84,7 +84,7 @@ static void setupTle8888() {
// on microRusEFI SPI3 is exposed on PC10/PC11 and there is interest to use SD card there
// PB3/PB4 could be either SPI1 or SP3, let's use not SPI3 to address the contention
// Enable spi1
CONFIG(is_enabled_spi_1) = true;
engineConfiguration->is_enabled_spi_1 = true;
// Wire up spi1
engineConfiguration->spi1mosiPin = GPIOB_5;
@ -169,7 +169,7 @@ void setBoardConfigOverrides(void) {
engineConfiguration->canRxPin = GPIOB_12;
// SPI for SD card
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3;
engineConfiguration->sdCardCsPin = GPIOB_9;

View File

@ -23,7 +23,7 @@ static void setPrometheusDefaults() {
//engineConfiguration->useOnlyRisingEdgeForTrigger = true;
setAlgorithm(LM_SPEED_DENSITY);
CONFIG(useCicPidForIdle) = true;
engineConfiguration->useCicPidForIdle = true;
engineConfiguration->specs.cylindersCount = 4;
engineConfiguration->specs.firingOrder = FO_1_3_4_2;
@ -211,7 +211,7 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->is_enabled_spi_1 = true;
engineConfiguration->is_enabled_spi_2 = false;
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
engineConfiguration->spi1mosiPin = GPIOB_5;
engineConfiguration->spi1MosiMode = PO_DEFAULT; // PAL_STM32_OTYPE_PUSHPULL

View File

@ -55,9 +55,9 @@ void setSdCardConfigurationOverrides(void) {
static void setLedPins() {
// PE3 is error LED, configured in board.mk
CONFIG(communicationLedPin) = GPIOE_4;
CONFIG(runningLedPin) = GPIOE_5;
CONFIG(warningLedPin) = GPIOE_6;
engineConfiguration->communicationLedPin = GPIOE_4;
engineConfiguration->runningLedPin = GPIOE_5;
engineConfiguration->warningLedPin = GPIOE_6;
}
static void setupVbatt() {
@ -193,16 +193,16 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->specs.cylindersCount = 8;
engineConfiguration->specs.firingOrder = FO_1_8_7_2_6_5_4_3;
CONFIG(enableSoftwareKnock) = true;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS;
engineConfiguration->injectionMode = IM_SIMULTANEOUS;
#if HW_PROTEUS & EFI_PROD_CODE
CONFIG(mainRelayPin) = PROTEUS_LS_13;
CONFIG(fanPin) = PROTEUS_LS_15;
CONFIG(fuelPumpPin) = PROTEUS_LS_16;
engineConfiguration->mainRelayPin = PROTEUS_LS_13;
engineConfiguration->fanPin = PROTEUS_LS_15;
engineConfiguration->fuelPumpPin = PROTEUS_LS_16;
#endif // HW_PROTEUS
// If we're running as hardware CI, borrow a few extra pins for that

View File

@ -36,7 +36,7 @@
// This shows a SPI connected TLE8888.
static void setupTle8888() {
// Enable the SPI channel and set up the SPI pins
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
engineConfiguration->spi3mosiPin = GPIOB_5;
engineConfiguration->spi3misoPin = GPIOB_4;
engineConfiguration->spi3sckPin = GPIOB_3;

View File

@ -90,11 +90,11 @@ void m73engine() {
engineConfiguration->specs.cylindersCount = 12;
engineConfiguration->specs.displacement = 5.4;
strcpy(CONFIG(engineMake), ENGINE_MAKE_BMW);
strcpy(CONFIG(engineCode), "M73");
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;
CONFIG(isFasterEngineSpinUpEnabled) = true;
CONFIG(fuelAlgorithm) = LM_ALPHA_N;
engineConfiguration->isFasterEngineSpinUpEnabled = true;
engineConfiguration->fuelAlgorithm = LM_ALPHA_N;
engineConfiguration->vvtMode[0] = VVT_FIRST_HALF;
@ -176,7 +176,7 @@ GPIOA_6
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = GPIOC_8;
engineConfiguration->etbIo[0].directionPin2 = GPIOC_9;
CONFIG(etb_use_two_wires) = true;
engineConfiguration->etb_use_two_wires = true;
// PWM pin
engineConfiguration->etbIo[1].controlPin = GPIO_UNASSIGNED;
@ -184,8 +184,8 @@ GPIOA_6
engineConfiguration->etbIo[1].directionPin1 = GPIOB_9;
engineConfiguration->etbIo[1].directionPin2 = GPIOB_8;
CONFIG(tps2Min) = CONFIG(tpsMin);
CONFIG(tps2Max) = CONFIG(tpsMax);
engineConfiguration->tps2Min = engineConfiguration->tpsMin;
engineConfiguration->tps2Max = engineConfiguration->tpsMax;
engineConfiguration->injectionPins[0] = GPIO_UNASSIGNED;
@ -249,7 +249,7 @@ void setEngineBMW_M73_Proteus() {
// set_analog_input_pin pps pa4
engineConfiguration->throttlePedalPositionAdcChannel = PROTEUS_IN_ANALOG_VOLT_9;
strcpy(CONFIG(vehicleName), "Using Proteus");
strcpy(engineConfiguration->vehicleName, "Using Proteus");
// set_trigger_input_pin 0 PE7
// GPIOE_7: "VR 1"
@ -269,13 +269,13 @@ void setEngineBMW_M73_Proteus() {
// GPIOE_0: "Lowside 14"
CONFIG(starterControlPin) = GPIOE_0;
engineConfiguration->starterControlPin = GPIOE_0;
// GPIOE_12: "Digital 3"
CONFIG(startStopButtonPin) = GPIOE_12;
CONFIG(startStopButtonMode) = PI_PULLUP;
engineConfiguration->startStopButtonPin = GPIOE_12;
engineConfiguration->startStopButtonMode = PI_PULLUP;
setProteusHitachiEtbDefaults();
CONFIG(useETBforIdleControl) = true;
engineConfiguration->useETBforIdleControl = true;
}
#endif // HW_PROTEUS

View File

@ -69,9 +69,9 @@ void setEngineBMW_M73_microRusEfi() {
// 13641435991 injector
engineConfiguration->injector.flow = 180; // cc/min, who knows if this number is real - no good source of info
CONFIG(isFasterEngineSpinUpEnabled) = true;
engineConfiguration->isFasterEngineSpinUpEnabled = true;
strcpy(CONFIG(vehicleName), "microRusEFIx2");
strcpy(engineConfiguration->vehicleName, "microRusEFIx2");
engineConfiguration->globalTriggerAngleOffset = 90;
engineConfiguration->specs.cylindersCount = 6;
@ -87,28 +87,28 @@ void setEngineBMW_M73_microRusEfi() {
// TODO LUA setFsio(7, GPIOC_8, "0");
CONFIG(debugMode) = DBG_ELECTRONIC_THROTTLE_PID;
engineConfiguration->debugMode = DBG_ELECTRONIC_THROTTLE_PID;
engineConfiguration->etb.pFactor = 2.00;
engineConfiguration->etb.iFactor = 0.35;
// set debug_mode 37
// 22 - AN Temp 4, orange wire
CONFIG(startStopButtonPin) = GPIOA_3;
engineConfiguration->startStopButtonPin = GPIOA_3;
#if (BOARD_TLE8888_COUNT > 0)
// "43 - GP Out 4"
CONFIG(starterControlPin) = TLE8888_PIN_24;
engineConfiguration->starterControlPin = TLE8888_PIN_24;
#endif /* BOARD_TLE8888_COUNT */
engineConfiguration->canNbcType = CAN_BUS_NBC_NONE;
// set_analog_input_pin pps PA7
// EFI_ADC_7: "31 - AN volt 3" - PA7
CONFIG(throttlePedalPositionAdcChannel) = EFI_ADC_7;
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_7;
engineConfiguration->canReadEnabled = true;
engineConfiguration->canWriteEnabled = true;
CONFIG(enableVerboseCanTx) = true;
engineConfiguration->enableVerboseCanTx = true;
// do I have VR wires flipped?
@ -117,7 +117,7 @@ void setEngineBMW_M73_microRusEfi() {
// this large engine seems to crank at around only 150 RPM? And happily idle at 400RPM?
engineConfiguration->cranking.rpm = 280;
CONFIG(crankingTimingAngle) = 30;
engineConfiguration->crankingTimingAngle = 30;
// I am too lazy to add MAP sensor
engineConfiguration->fuelAlgorithm = LM_ALPHA_N;
@ -126,8 +126,8 @@ void setEngineBMW_M73_microRusEfi() {
engineConfiguration->cranking.baseFuel = 15;
//set tps_min 891
CONFIG(tpsMin) = 891;
engineConfiguration->tpsMin = 891;
//set tps_max 177
CONFIG(tpsMax) = 177;
engineConfiguration->tpsMax = 177;
}

View File

@ -21,7 +21,7 @@ void setCamaro4() {
engineConfiguration->specs.displacement = 5.7;
engineConfiguration->specs.cylindersCount = 8;
strcpy(CONFIG(engineMake), ENGINE_MAKE_GM);
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_GM);
engineConfiguration->specs.firingOrder = FO_1_8_7_2_6_5_4_3;
engineConfiguration->triggerInputPins[0] = GPIOA_5;

View File

@ -267,9 +267,9 @@ void setEtbTestConfiguration() {
/**
* remember that some H-bridges require 5v control lines, not just 3v logic outputs we have on stm32
*/
CONFIG(etbIo[0].directionPin1) = GPIOC_7; // Frankenso high-side in order to get 5v control
CONFIG(etbIo[0].directionPin2) = GPIOC_9;
CONFIG(etbIo[0].controlPin) = GPIOE_14;
engineConfiguration->etbIo[0].directionPin1 = GPIOC_7; // Frankenso high-side in order to get 5v control
engineConfiguration->etbIo[0].directionPin2 = GPIOC_9;
engineConfiguration->etbIo[0].controlPin = GPIOE_14;
#if EFI_ELECTRONIC_THROTTLE_BODY
setBoschVNH2SP30Curve();
@ -284,8 +284,8 @@ void setEtbTestConfiguration() {
// turning off other PWMs to simplify debugging
engineConfiguration->triggerSimulatorFrequency = 0;
engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED;
CONFIG(idle).stepperStepPin = GPIO_UNASSIGNED;
CONFIG(idle).stepperDirectionPin = GPIO_UNASSIGNED;
engineConfiguration->idle.stepperStepPin = GPIO_UNASSIGNED;
engineConfiguration->idle.stepperDirectionPin = GPIO_UNASSIGNED;
engineConfiguration->useStepperIdle = true;
// no analog dividers - all sensors with 3v supply, naked discovery bench setup
@ -349,11 +349,11 @@ void setTle8888TestConfiguration() {
#if EFI_FSIO
// todo lua setFsio(14, GPIOF_13, "1");
#endif /* EFI_FSIO */
CONFIG(etbIo[0].directionPin1) = GPIOF_15;
CONFIG(etbIo[0].directionPin2) = GPIOF_14;
CONFIG(etbIo[0].disablePin) = GPIOF_12;
engineConfiguration->etbIo[0].directionPin1 = GPIOF_15;
engineConfiguration->etbIo[0].directionPin2 = GPIOF_14;
engineConfiguration->etbIo[0].disablePin = GPIOF_12;
#endif /* STM32_HAS_GPIOF */
CONFIG(etb_use_two_wires) = true;
engineConfiguration->etb_use_two_wires = true;
engineConfiguration->isHip9011Enabled = false;
// ETB #2
@ -365,9 +365,9 @@ void setTle8888TestConfiguration() {
#if EFI_FSIO
// todo lua setFsio(15, GPIOE_6, "1");
#endif
CONFIG(etbIo[0].directionPin1) = GPIOE_2;
CONFIG(etbIo[0].directionPin2) = GPIOE_4;
CONFIG(etbIo[0].disablePin) = GPIOE_5;
engineConfiguration->etbIo[0].directionPin1 = GPIOE_2;
engineConfiguration->etbIo[0].directionPin2 = GPIOE_4;
engineConfiguration->etbIo[0].disablePin = GPIOE_5;
engineConfiguration->tps1_1AdcChannel = EFI_ADC_3; // PA3
@ -525,8 +525,8 @@ void proteusBoardTest() {
engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL;
engineConfiguration->mainRelayPin = GPIO_UNASSIGNED;
CONFIG(fanPin) = GPIO_UNASSIGNED;
CONFIG(fuelPumpPin) = GPIO_UNASSIGNED;
engineConfiguration->fanPin = GPIO_UNASSIGNED;
engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED;
#if EFI_PROD_CODE
engineConfiguration->injectionPins[0] = PROTEUS_LS_1;
@ -692,16 +692,16 @@ void mreBoardNewTest() {
void setBoschHDEV_5_injectors() {
// This is the configuration for bosch HDEV 5 injectors
// all times in microseconds/us
CONFIG(mc33_hvolt) = 65;
CONFIG(mc33_i_boost) = 13000;
CONFIG(mc33_i_peak) = 9400;
CONFIG(mc33_i_hold) = 3700;
CONFIG(mc33_t_max_boost) = 470;
CONFIG(mc33_t_peak_off) = 10;
CONFIG(mc33_t_peak_tot) = 700;
CONFIG(mc33_t_bypass) = 15;
CONFIG(mc33_t_hold_off) = 60;
CONFIG(mc33_t_hold_tot) = 10000;
engineConfiguration->mc33_hvolt = 65;
engineConfiguration->mc33_i_boost = 13000;
engineConfiguration->mc33_i_peak = 9400;
engineConfiguration->mc33_i_hold = 3700;
engineConfiguration->mc33_t_max_boost = 470;
engineConfiguration->mc33_t_peak_off = 10;
engineConfiguration->mc33_t_peak_tot = 700;
engineConfiguration->mc33_t_bypass = 15;
engineConfiguration->mc33_t_hold_off = 60;
engineConfiguration->mc33_t_hold_tot = 10000;
}
/**
@ -727,9 +727,9 @@ void setRotary() {
engineConfiguration->trigger.type = TT_36_2_2_2;
setOperationMode(engineConfiguration, TWO_STROKE);
strcpy(CONFIG(engineMake), ENGINE_MAKE_MAZDA);
strcpy(CONFIG(engineCode), "13B");
strcpy(CONFIG(vehicleName), "test");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_MAZDA);
strcpy(engineConfiguration->engineCode, "13B");
strcpy(engineConfiguration->vehicleName, "test");
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; // injector in default pinout
@ -753,9 +753,9 @@ void setTest33816EngineConfiguration() {
// default spi3sckPin PB3
CONFIG(triggerSimulatorPins[0]) = GPIO_UNASSIGNED;
CONFIG(triggerSimulatorPins[1]) = GPIO_UNASSIGNED;
CONFIG(triggerSimulatorPins[2]) = GPIO_UNASSIGNED;
engineConfiguration->triggerSimulatorPins[0] = GPIO_UNASSIGNED;
engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED;
engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED;
engineConfiguration->injectionPins[0] = GPIOB_9; // #1
engineConfiguration->injectionPins[1] = GPIOE_2; // #2
@ -764,30 +764,30 @@ void setTest33816EngineConfiguration() {
// blue
CONFIG(mc33816_cs) = GPIOD_7;
engineConfiguration->mc33816_cs = GPIOD_7;
// green
CONFIG(mc33816_rstb) = GPIOD_4;
engineConfiguration->mc33816_rstb = GPIOD_4;
// yellow
CONFIG(mc33816_driven) = GPIOD_6;
engineConfiguration->mc33816_driven = GPIOD_6;
CONFIG(mc33816_flag0) = GPIOD_3;
engineConfiguration->mc33816_flag0 = GPIOD_3;
// enable_spi 3
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
// Wire up spi3
engineConfiguration->spi3mosiPin = GPIOB_5;
engineConfiguration->spi3misoPin = GPIOB_4;
engineConfiguration->spi3sckPin = GPIOB_3;
CONFIG(isSdCardEnabled) = false;
engineConfiguration->isSdCardEnabled = false;
CONFIG(mc33816spiDevice) = SPI_DEVICE_3;
engineConfiguration->mc33816spiDevice = SPI_DEVICE_3;
setBoschHDEV_5_injectors();
}
void setHellen72etb() {
CONFIG(etbIo[0].directionPin1) = GPIOC_6;
CONFIG(etbIo[0].directionPin2) = GPIOC_7;
engineConfiguration->etbIo[0].directionPin1 = GPIOC_6;
engineConfiguration->etbIo[0].directionPin2 = GPIOC_7;
engineConfiguration->etb_use_two_wires = true;
}
@ -860,11 +860,11 @@ void proteusLuaDemo() {
engineConfiguration->luaOutputPins[1] = GPIOD_10;
engineConfiguration->luaOutputPins[2] = GPIOD_11;
setLinearCurve(CONFIG(scriptCurve2Bins), 0, 8000, 1);
setLinearCurve(CONFIG(scriptCurve2), 0, 100, 1);
setLinearCurve(engineConfiguration->scriptCurve2Bins, 0, 8000, 1);
setLinearCurve(engineConfiguration->scriptCurve2, 0, 100, 1);
copyArray(CONFIG(scriptCurve3Bins), defaultBiasBins);
copyArray(CONFIG(scriptCurve3), defaultBiasValues);
copyArray(engineConfiguration->scriptCurve3Bins, defaultBiasBins);
copyArray(engineConfiguration->scriptCurve3, defaultBiasValues);
engineConfiguration->auxAnalogInputs[0] = PROTEUS_IN_ANALOG_VOLT_10;
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;

View File

@ -35,14 +35,14 @@ void setProteusHondaElement2003() {
engineConfiguration->injectorCompensationMode = ICM_FixedRailPressure;
engineConfiguration->fuelReferencePressure = 350; // TODO: what is real value?!
strcpy(CONFIG(engineMake), ENGINE_MAKE_HONDA);
strcpy(CONFIG(engineCode), "K24");
strcpy(CONFIG(vehicleName), "test");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_HONDA);
strcpy(engineConfiguration->engineCode, "K24");
strcpy(engineConfiguration->vehicleName, "test");
gppwm_channel *vtsControl = &engineConfiguration->gppwm[0];
vtsControl->pwmFrequency = 0;
strcpy(CONFIG(gpPwmNote[0]), "VTS");
strcpy(engineConfiguration->gpPwmNote[0], "VTS");
engineConfiguration->tpsMin = 100;
engineConfiguration->tpsMax = 830;
@ -80,12 +80,12 @@ void setProteusHondaElement2003() {
engineConfiguration->clt.adcChannel = PROTEUS_IN_ANALOG_TEMP_2;
engineConfiguration->tps1_1AdcChannel = PROTEUS_IN_ANALOG_VOLT_3;
engineConfiguration->map.sensor.hwChannel = PROTEUS_IN_ANALOG_VOLT_6;
CONFIG(fanPin) = GPIO_UNASSIGNED;
engineConfiguration->fanPin = GPIO_UNASSIGNED;
CONFIG(mainRelayPin) = PROTEUS_LS_9;
CONFIG(fuelPumpPin) = PROTEUS_LS_11;
// CONFIG(fanPin) = PROTEUS_LS_15;
engineConfiguration->mainRelayPin = PROTEUS_LS_9;
engineConfiguration->fuelPumpPin = PROTEUS_LS_11;
// engineConfiguration->fanPin = PROTEUS_LS_15;
#endif // HW_PROTEUS
}

View File

@ -165,7 +165,7 @@ static void miataNAcommonEngineSettings() {
engineConfiguration->enableFan1WithAc = true;
engineConfiguration->enableFan2WithAc = true;
CONFIG(tachPulsePerRev) = 2;
engineConfiguration->tachPulsePerRev = 2;
engineConfiguration->debugMode = DBG_TRIGGER_COUNTERS;
@ -236,8 +236,8 @@ static void miataNAcommonEngineSettings() {
config->crankingFuelBins[7] = 90;
engineConfiguration->specs.displacement = 1.6;
strcpy(CONFIG(engineMake), ENGINE_MAKE_MAZDA);
strcpy(CONFIG(engineCode), "NA6");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_MAZDA);
strcpy(engineConfiguration->engineCode, "NA6");
// my car was originally a manual so proper TPS
engineConfiguration->tpsMin = 93; // convert 12to10 bit (ADC/4)
@ -421,8 +421,8 @@ void setMiata94_MAP_MRE() {
engineConfiguration->injectionMode = IM_SEQUENTIAL;
engineConfiguration->specs.displacement = 1.8;
strcpy(CONFIG(engineMake), ENGINE_MAKE_MAZDA);
strcpy(CONFIG(engineCode), "94");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_MAZDA);
strcpy(engineConfiguration->engineCode, "94");
engineConfiguration->map.sensor.type = MT_MPX4250;
@ -430,7 +430,7 @@ void setMiata94_MAP_MRE() {
void setHellenNA94() {
miataNAcommonEngineSettings();
strcpy(CONFIG(engineCode), "94");
strcpy(engineConfiguration->engineCode, "94");
/**
* http://miataturbo.wikidot.com/fuel-injectors
* 94-97 Tan - #195500-2180

View File

@ -34,8 +34,8 @@ void setMazdaMiataNA8Configuration() {
engineConfiguration->injector.flow = 265;
engineConfiguration->specs.displacement = 1.839;
strcpy(CONFIG(engineMake), ENGINE_MAKE_MAZDA);
strcpy(CONFIG(engineCode), "NA8");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_MAZDA);
strcpy(engineConfiguration->engineCode, "NA8");
engineConfiguration->vbattDividerCoeff = 9.75;// ((float) (8.2 + 33)) / 8.2 * 2;

View File

@ -258,7 +258,7 @@ static void setCommonMazdaNB() {
engineConfiguration->idle.solenoidFrequency = 300;
CONFIG(isAlternatorControlEnabled) = true;
engineConfiguration->isAlternatorControlEnabled = true;
// enable altdebug
engineConfiguration->targetVBatt = 13.8;
engineConfiguration->alternatorControl.offset = 40;
@ -287,7 +287,7 @@ static void setCommonMazdaNB() {
setOperationMode(engineConfiguration, FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR);
engineConfiguration->specs.displacement = 1.839;
engineConfiguration->cylinderBore = 83;
strcpy(CONFIG(engineMake), ENGINE_MAKE_MAZDA);
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_MAZDA);
setCommonNTCSensor(&engineConfiguration->clt, 2700);
setCommonNTCSensor(&engineConfiguration->iat, 2700);
@ -325,11 +325,11 @@ static void setCommonMazdaNB() {
static void setMazdaMiataEngineNB1Defaults() {
setCommonMazdaNB();
strcpy(CONFIG(engineCode), "NB1");
strcpy(engineConfiguration->engineCode, "NB1");
}
static void setMazdaMiataEngineNB2Defaults() {
strcpy(CONFIG(engineCode), "NB2");
strcpy(engineConfiguration->engineCode, "NB2");
engineConfiguration->map.sensor.type = MT_GM_3_BAR;
setEgoSensor(ES_Innovate_MTX_L);
@ -364,7 +364,7 @@ static void setMazdaMiataEngineNB2Defaults() {
// CONFIG(debugTriggerSync) = GPIOD_3;
// engineConfiguration->debugTriggerSync = GPIOD_3;
// engineConfiguration->debugMode = DBG_IDLE_CONTROL;
engineConfiguration->debugMode = DBG_TRIGGER_COUNTERS;
@ -480,7 +480,7 @@ void setMazdaMiata2003EngineConfiguration() {
// TLE7209 two-wire ETB control
// PWM
CONFIG(etb_use_two_wires) = true;
engineConfiguration->etb_use_two_wires = true;
engineConfiguration->etbIo[0].controlPin = GPIO_UNASSIGNED;
@ -576,9 +576,9 @@ static void setMiataNB2_MRE_common() {
engineConfiguration->alternatorControlPin = GPIOD_6;
// GPIOD_7: "14 - GP Out 5" - selected to +12v
engineConfiguration->tachOutputPin = GPIOD_7; // tachometer
CONFIG(tachPulsePerRev) = 2;
engineConfiguration->tachPulsePerRev = 2;
CONFIG(isSdCardEnabled) = true;
engineConfiguration->isSdCardEnabled = true;
engineConfiguration->ignitionDwellForCrankingMs = 8;
@ -627,7 +627,7 @@ static void setMiataNB2_MRE_common() {
void setMiataNB2_MRE_ETB() {
setMiataNB2_MRE_common();
CONFIG(useETBforIdleControl) = true;
engineConfiguration->useETBforIdleControl = true;
#if EFI_FSIO
// enable ETB
@ -642,7 +642,7 @@ void setMiataNB2_MRE_ETB() {
engineConfiguration->idleRpmPid.dFactor = 5;
engineConfiguration->idleRpmPid.periodMs = 10;
CONFIG(useETBforIdleControl) = true;
engineConfiguration->useETBforIdleControl = true;
engineConfiguration->throttlePedalUpVoltage = 1;
// WAT? that's an interesting value, how come it's above 5v?
engineConfiguration->throttlePedalWOTVoltage = 5.47;
@ -703,10 +703,10 @@ void setMiataNB2_Proteus_TCU() {
// "Digital 1" green
engineConfiguration->tcuUpshiftButtonPin = GPIOC_6;
CONFIG(tcuUpshiftButtonPinMode) = PI_PULLUP;
engineConfiguration->tcuUpshiftButtonPinMode = PI_PULLUP;
// "Digital 6" white
engineConfiguration->tcuDownshiftButtonPin = GPIOE_15;
CONFIG(tcuDownshiftButtonPinMode) = PI_PULLUP;
engineConfiguration->tcuDownshiftButtonPinMode = PI_PULLUP;
// R
config->tcuSolenoidTable[0][0] = 1;
@ -766,7 +766,7 @@ void setMiataNB2_ProteusEngineConfiguration() {
engineConfiguration->injectionPinMode = OM_DEFAULT;
CONFIG(enableSoftwareKnock) = true;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->malfunctionIndicatorPin = PROTEUS_LS_10;
@ -791,7 +791,7 @@ void setMiataNB2_ProteusEngineConfiguration() {
engineConfiguration->fanPin = GPIOB_7;
CONFIG(mainRelayPin) = GPIOG_12;
engineConfiguration->mainRelayPin = GPIOG_12;
#endif // EFI_PROD_CODE
@ -807,7 +807,7 @@ void setHellenNB1() {
void setMiataNB2_Hellen72() {
setMazdaMiataEngineNB2Defaults();
strcpy(CONFIG(vehicleName), "H72 test");
strcpy(engineConfiguration->vehicleName, "H72 test");
// set tps_min 90

View File

@ -135,20 +135,20 @@ void vag_18_Turbo() {
// todo lua setFsioExt (3, GPIOE_0, "0.15 90 coolant 120 min max 90 - 30 / 0.8 * +", 25);
#endif
// is this needed? engineConfiguration->vvtOutputFrequency[3] = 25;
CONFIG(etb_use_two_wires) = true;
engineConfiguration->etb_use_two_wires = true;
#if defined(STM32_HAS_GPIOF) && STM32_HAS_GPIOF
CONFIG(etbIo[0].directionPin1) = GPIOF_15;
CONFIG(etbIo[0].directionPin2) = GPIOF_14;
CONFIG(etbIo[0].disablePin) = GPIOF_12;
engineConfiguration->etbIo[0].directionPin1 = GPIOF_15;
engineConfiguration->etbIo[0].directionPin2 = GPIOF_14;
engineConfiguration->etbIo[0].disablePin = GPIOF_12;
#endif /* STM32_HAS_GPIOF */
engineConfiguration->isHip9011Enabled = false;
#if EFI_FSIO
// todo lua setFsio (15, GPIOE_6, "1");
#endif
CONFIG(etbIo[1].directionPin1) = GPIOE_2;
CONFIG(etbIo[1].directionPin2) = GPIOE_4;
CONFIG(etbIo[1].disablePin) = GPIOE_5;
engineConfiguration->etbIo[1].directionPin1 = GPIOE_2;
engineConfiguration->etbIo[1].directionPin2 = GPIOE_4;
engineConfiguration->etbIo[1].disablePin = GPIOE_5;
engineConfiguration->etb.pFactor = 1.07;
engineConfiguration->etb.iFactor = 0.18;

View File

@ -13,7 +13,7 @@ void setHellen121nissanQR() {
engineConfiguration->specs.cylindersCount = 4;
engineConfiguration->specs.firingOrder = FO_1_3_4_2;
engineConfiguration->specs.displacement = 2;
strcpy(CONFIG(engineCode), "QR");
strcpy(engineConfiguration->engineCode, "QR");
engineConfiguration->camInputs[1 * CAMS_PER_BANK] = GPIO_UNASSIGNED;
@ -32,7 +32,7 @@ void setHellen121nissanVQ() {
engineConfiguration->specs.cylindersCount = 6;
engineConfiguration->specs.firingOrder = FO_1_2_3_4_5_6;
engineConfiguration->specs.displacement = 4;
strcpy(CONFIG(engineCode), "VQ");
strcpy(engineConfiguration->engineCode, "VQ");
engineConfiguration->vvtMode[0] = VVT_NISSAN_VQ;
@ -48,6 +48,6 @@ void setHellen121nissanAltimaN16() {
// https://en.wikipedia.org/wiki/N-VCT
setHellen121nissanQR();
engineConfiguration->specs.displacement = 1.8;
strcpy(CONFIG(engineCode), "N16");
strcpy(engineConfiguration->engineCode, "N16");
}

View File

@ -41,11 +41,11 @@ void setSubaruEJ18_MRE() {
engineConfiguration->trigger.type = TT_SUBARU_7_WITHOUT_6;
// CONFIG(isDoubleSolenoidIdle) = true;
// engineConfiguration->isDoubleSolenoidIdle = true;
engineConfiguration->specs.displacement = 1.8;
strcpy(CONFIG(engineMake), ENGINE_MAKE_SUBARU);
strcpy(CONFIG(engineCode), "EJ18");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_SUBARU);
strcpy(engineConfiguration->engineCode, "EJ18");
engineConfiguration->specs.firingOrder = FO_1_3_2_4;
engineConfiguration->injectionMode = IM_SEQUENTIAL;

View File

@ -119,9 +119,9 @@ void setToyota_2jz_vics() {
engineConfiguration->twoWireBatchIgnition = true;
engineConfiguration->twoWireBatchInjection = true;
strcpy(CONFIG(engineMake), ENGINE_MAKE_TOYOTA);
strcpy(CONFIG(engineCode), "2JZ");
strcpy(CONFIG(vehicleName), "VVT example");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_TOYOTA);
strcpy(engineConfiguration->engineCode, "2JZ");
strcpy(engineConfiguration->vehicleName, "VVT example");
engineConfiguration->debugMode = DBG_VVT;

View File

@ -59,7 +59,7 @@ void setVwAba() {
setFuelTablesLoadBin(20, mapRange);
setTimingLoadBin(20, mapRange);
CONFIG(isSdCardEnabled) = false;
engineConfiguration->isSdCardEnabled = false;
engineConfiguration->tpsMin = 740;
engineConfiguration->tpsMax = 135;
}

View File

@ -35,8 +35,8 @@ void setVwPassatB6() {
//setting "flat" 0.2 ms injector's lag time
setArrayValues(engineConfiguration->injector.battLagCorr, 0.2);
strcpy(CONFIG(engineMake), ENGINE_MAKE_VAG);
strcpy(CONFIG(engineCode), "BPY");
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_VAG);
strcpy(engineConfiguration->engineCode, "BPY");
engineConfiguration->verboseVVTDecoding = true;
@ -65,9 +65,9 @@ void setVwPassatB6() {
// todo: what's the proper calibration of this Bosch sensor? is it really 200psi?
engineConfiguration->lowPressureFuel.value2 = PSI2KPA(200);
CONFIG(isSdCardEnabled) = false;
engineConfiguration->isSdCardEnabled = false;
CONFIG(mc33816spiDevice) = SPI_DEVICE_3;
engineConfiguration->mc33816spiDevice = SPI_DEVICE_3;
setBoschHDEV_5_injectors();
// RED
engineConfiguration->spi3mosiPin = GPIOC_12;
@ -76,17 +76,17 @@ void setVwPassatB6() {
// BROWN
engineConfiguration->spi3sckPin = GPIOC_10;
engineConfiguration->sdCardCsPin = GPIO_UNASSIGNED;
CONFIG(is_enabled_spi_3) = true;
engineConfiguration->is_enabled_spi_3 = true;
// J8 orange
CONFIG(mc33816_cs) = GPIOB_8;
engineConfiguration->mc33816_cs = GPIOB_8;
// J8 Grey
CONFIG(mc33816_rstb) = GPIOA_15;
engineConfiguration->mc33816_rstb = GPIOA_15;
// J8 Dark BLUE
CONFIG(mc33816_driven) = GPIOB_9;
engineConfiguration->mc33816_driven = GPIOB_9;
// J9 violet
CONFIG(mc33816_flag0) = GPIOC_13;
engineConfiguration->mc33816_flag0 = GPIOC_13;
// J10 Dark BLUE
engineConfiguration->injectionPins[0] = GPIOE_6;
@ -136,7 +136,7 @@ void setVwPassatB6() {
engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED;
engineConfiguration->fanPin = GPIO_UNASSIGNED;
CONFIG(useETBforIdleControl) = true;
engineConfiguration->useETBforIdleControl = true;
engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL;
#endif /* BOARD_TLE8888_COUNT */
}

View File

@ -54,7 +54,7 @@ static void runCommands() {
chThdSleepMilliseconds(1000); // safety
// Store current serial port speed - we're going to change it
int savedSerialSpeed = CONFIG(tunerStudioSerialSpeed);
int savedSerialSpeed = engineConfiguration->tunerStudioSerialSpeed;
int prevBaudIdx = -1, baudIdx = -1, baudListIdx = 0;
int cmdIdx = 0;
@ -78,9 +78,9 @@ static void runCommands() {
chThdSleepMilliseconds(10); // safety
// change the port speed
CONFIG(tunerStudioSerialSpeed) = restoreAndExit ? savedSerialSpeed : baudRates[baudIdx];
engineConfiguration->tunerStudioSerialSpeed = restoreAndExit ? savedSerialSpeed : baudRates[baudIdx];
tsChannel->start(CONFIG(tunerStudioSerialSpeed));
tsChannel->start(engineConfiguration->tunerStudioSerialSpeed);
chThdSleepMilliseconds(10); // safety
prevBaudIdx = baudIdx;
@ -164,7 +164,7 @@ void bluetoothStart(SerialTsChannelBase *btChan, bluetooth_module_e moduleType,
tsChannel = btChan;
// if a binary protocol uses USB, we cannot init the bluetooth module!
if (!CONFIG(useSerialPort)) {
if (!engineConfiguration->useSerialPort) {
efiPrintf("Failed! Serial Port connection is disabled!");
return;
}

View File

@ -113,7 +113,7 @@ void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp) {
}
// Don't log at significant engine speed
if (engine->rpmCalculator.getRpm() > CONFIG(engineSnifferRpmThreshold)) {
if (engine->rpmCalculator.getRpm() > engineConfiguration->engineSnifferRpmThreshold) {
return;
}

View File

@ -22,8 +22,8 @@ class CanTsChannel : public TsChannelBase {
static CANConfig tsCanConfig = { CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP, CAN_BTR_500 };
void CanTsChannel::start() {
efiSetPadMode("ts can rx", GPIOG_13/*CONFIG(canRxPin)*/, PAL_MODE_ALTERNATE(TS_CAN_AF)); // CAN2_RX2_0
efiSetPadMode("ts can tx", GPIOG_14/*CONFIG(canTxPin)*/, PAL_MODE_ALTERNATE(TS_CAN_AF)); // CAN2_TX2_0
efiSetPadMode("ts can rx", GPIOG_13/*engineConfiguration->canRxPin*/, PAL_MODE_ALTERNATE(TS_CAN_AF)); // CAN2_RX2_0
efiSetPadMode("ts can tx", GPIOG_14/*engineConfiguration->canTxPin*/, PAL_MODE_ALTERNATE(TS_CAN_AF)); // CAN2_TX2_0
canStart(&TS_CAN_DEVICE, &tsCanConfig);
canInit(&TS_CAN_DEVICE);

View File

@ -131,7 +131,7 @@ void printTsStats(void) {
efiPrintf("TS RX on %s", hwPortname(engineConfiguration->binarySerialRxPin));
efiPrintf("TS TX on %s @%d", hwPortname(engineConfiguration->binarySerialTxPin),
CONFIG(tunerStudioSerialSpeed));
engineConfiguration->tunerStudioSerialSpeed);
}
#endif /* EFI_PROD_CODE */
@ -139,7 +139,7 @@ void printTsStats(void) {
}
static void setTsSpeed(int value) {
CONFIG(tunerStudioSerialSpeed) = value;
engineConfiguration->tunerStudioSerialSpeed = value;
printTsStats();
}

View File

@ -31,7 +31,7 @@
efiSetPadMode("Primary Channel TX", EFI_CONSOLE_TX_BRAIN_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF));
#endif /* EFI_PROD_CODE */
primaryChannel.start(CONFIG(uartConsoleSerialSpeed));
primaryChannel.start(engineConfiguration->uartConsoleSerialSpeed);
return &primaryChannel;
}
@ -60,7 +60,7 @@
efiSetPadMode("Secondary Channel TX", engineConfiguration->binarySerialTxPin, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
#endif /* EFI_PROD_CODE */
secondaryChannel.start(CONFIG(uartConsoleSerialSpeed));
secondaryChannel.start(engineConfiguration->uartConsoleSerialSpeed);
return &secondaryChannel;
}

View File

@ -201,24 +201,24 @@ void printOverallStatus(efitimesec_t nowSeconds) {
int seconds = getTimeNowSeconds();
printCurrentState(&logger, seconds, getEngine_type_e(engineConfiguration->engineType), FIRMWARE_ID);
#if EFI_PROD_CODE
printOutPin(PROTOCOL_CRANK1, CONFIG(triggerInputPins)[0]);
printOutPin(PROTOCOL_CRANK2, CONFIG(triggerInputPins)[1]);
printOutPin(PROTOCOL_CRANK1, engineConfiguration->triggerInputPins[0]);
printOutPin(PROTOCOL_CRANK2, engineConfiguration->triggerInputPins[1]);
for (int i = 0;i<CAM_INPUTS_COUNT;i++) {
extern const char *vvtNames[];
printOutPin(vvtNames[i], engineConfiguration->camInputs[i]);
}
printOutPin(PROTOCOL_HIP_NAME, CONFIG(hip9011IntHoldPin));
printOutPin(PROTOCOL_TACH_NAME, CONFIG(tachOutputPin));
printOutPin(PROTOCOL_HIP_NAME, engineConfiguration->hip9011IntHoldPin);
printOutPin(PROTOCOL_TACH_NAME, engineConfiguration->tachOutputPin);
#if EFI_LOGIC_ANALYZER
printOutPin(PROTOCOL_WA_CHANNEL_1, CONFIG(logicAnalyzerPins)[0]);
printOutPin(PROTOCOL_WA_CHANNEL_2, CONFIG(logicAnalyzerPins)[1]);
printOutPin(PROTOCOL_WA_CHANNEL_1, engineConfiguration->logicAnalyzerPins[0]);
printOutPin(PROTOCOL_WA_CHANNEL_2, engineConfiguration->logicAnalyzerPins[1]);
#endif /* EFI_LOGIC_ANALYZER */
int cylCount = minI(CONFIG(specs.cylindersCount), MAX_CYLINDER_COUNT);
int cylCount = minI(engineConfiguration->specs.cylindersCount, MAX_CYLINDER_COUNT);
for (int i = 0; i < cylCount; i++) {
printOutPin(enginePins.coils[i].getShortName(), CONFIG(ignitionPins)[i]);
printOutPin(enginePins.trailingCoils[i].getShortName(), CONFIG(trailingCoilPins)[i]);
printOutPin(enginePins.injectors[i].getShortName(), CONFIG(injectionPins)[i]);
printOutPin(enginePins.coils[i].getShortName(), engineConfiguration->ignitionPins[i]);
printOutPin(enginePins.trailingCoils[i].getShortName(), engineConfiguration->trailingCoilPins[i]);
printOutPin(enginePins.injectors[i].getShortName(), engineConfiguration->injectionPins[i]);
}
for (int i = 0; i < AUX_DIGITAL_VALVE_COUNT;i++) {
printOutPin(enginePins.auxValve[i].getShortName(), engineConfiguration->auxValves[i]);
@ -296,7 +296,7 @@ static void showFuelInfo2(float rpm, float engineLoad) {
#if EFI_ENGINE_CONTROL
efiPrintf("base cranking fuel %.2f", engineConfiguration->cranking.baseFuel);
efiPrintf("cranking fuel: %.2f", ENGINE(engineState.cranking.fuel));
efiPrintf("cranking fuel: %.2f", engine->engineState.cranking.fuel);
if (!engine->rpmCalculator.isStopped()) {
float iatCorrection = engine->engineState.running.intakeTemperatureCoefficient;
@ -495,11 +495,11 @@ static void updateThrottles() {
static void updateLambda() {
float lambdaValue = Sensor::getOrZero(SensorType::Lambda1);
tsOutputChannels.lambda = lambdaValue;
tsOutputChannels.airFuelRatio = lambdaValue * ENGINE(engineState.stoichiometricRatio);
tsOutputChannels.airFuelRatio = lambdaValue * engine->engineState.stoichiometricRatio;
float lambda2Value = Sensor::getOrZero(SensorType::Lambda2);
tsOutputChannels.lambda2 = lambda2Value;
tsOutputChannels.airFuelRatio2 = lambda2Value * ENGINE(engineState.stoichiometricRatio);
tsOutputChannels.airFuelRatio2 = lambda2Value * engine->engineState.stoichiometricRatio;
}
static void updateFuelSensors() {
@ -565,7 +565,7 @@ static void updateMiscSensors() {
#endif /* HAL_USE_ADC */
// tCharge depends on the previous state, so we should use the stored value.
tsOutputChannels.tCharge = ENGINE(engineState.sd.tCharge);
tsOutputChannels.tCharge = engine->engineState.sd.tCharge;
}
static void updateSensors(int rpm) {
@ -582,28 +582,28 @@ static void updateSensors(int rpm) {
static void updateFuelCorrections() {
tsOutputChannels.baroCorrection = engine->engineState.baroCorrection;
tsOutputChannels.iatCorrection = ENGINE(engineState.running.intakeTemperatureCoefficient);
tsOutputChannels.cltCorrection = ENGINE(engineState.running.coolantTemperatureCoefficient);
tsOutputChannels.iatCorrection = engine->engineState.running.intakeTemperatureCoefficient;
tsOutputChannels.cltCorrection = engine->engineState.running.coolantTemperatureCoefficient;
tsOutputChannels.fuelTrim[0] = 100.0f * (ENGINE(stftCorrection)[0] - 1.0f);
tsOutputChannels.fuelTrim[1] = 100.0f * (ENGINE(stftCorrection)[1] - 1.0f);
tsOutputChannels.fuelTrim[0] = 100.0f * (engine->stftCorrection[0] - 1.0f);
tsOutputChannels.fuelTrim[1] = 100.0f * (engine->stftCorrection[1] - 1.0f);
tsOutputChannels.injectorLagMs = ENGINE(engineState.running.injectorLag);
tsOutputChannels.injectorLagMs = engine->engineState.running.injectorLag;
}
static void updateFuelLoads() {
tsOutputChannels.fuelingLoad = getFuelingLoad();
tsOutputChannels.ignitionLoad = getIgnitionLoad();
tsOutputChannels.veTableYAxis = ENGINE(engineState.currentVeLoad);
tsOutputChannels.afrTableYAxis = ENGINE(engineState.currentAfrLoad);
tsOutputChannels.veTableYAxis = engine->engineState.currentVeLoad;
tsOutputChannels.afrTableYAxis = engine->engineState.currentAfrLoad;
}
static void updateFuelResults() {
tsOutputChannels.chargeAirMass = engine->engineState.sd.airMassInOneCylinder;
tsOutputChannels.fuelBase = engine->engineState.baseFuel * 1000; // Convert grams to mg
tsOutputChannels.fuelRunning = ENGINE(engineState.running.fuel);
tsOutputChannels.actualLastInjection = ENGINE(actualLastInjection)[0];
tsOutputChannels.fuelRunning = engine->engineState.running.fuel;
tsOutputChannels.actualLastInjection = engine->actualLastInjection[0];
tsOutputChannels.fuelFlowRate = engine->engineState.fuelConsumption.getConsumptionGramPerSecond();
tsOutputChannels.totalFuelConsumption = engine->engineState.fuelConsumption.getConsumedGrams();
@ -614,17 +614,17 @@ static void updateFuelInfo() {
updateFuelLoads();
updateFuelResults();
const auto& wallFuel = ENGINE(injectionEvents.elements[0].wallFuel);
const auto& wallFuel = engine->injectionEvents.elements[0].wallFuel;
tsOutputChannels.wallFuelAmount = wallFuel.getWallFuel();
tsOutputChannels.wallFuelCorrection = wallFuel.wallFuelCorrection;
tsOutputChannels.injectionOffset = engine->engineState.injectionOffset;
tsOutputChannels.veValue = engine->engineState.currentVe;
tsOutputChannels.currentTargetAfr = ENGINE(engineState.targetAFR);
tsOutputChannels.targetLambda = ENGINE(engineState.targetLambda);
tsOutputChannels.currentTargetAfr = engine->engineState.targetAFR;
tsOutputChannels.targetLambda = engine->engineState.targetLambda;
tsOutputChannels.crankingFuelMass = ENGINE(engineState.cranking.fuel);
tsOutputChannels.crankingFuelMass = engine->engineState.cranking.fuel;
}
static void updateIgnition(int rpm) {
@ -632,11 +632,11 @@ static void updateIgnition(int rpm) {
// that's weird logic. also seems broken for two stroke?
tsOutputChannels.ignitionAdvance = timing > FOUR_STROKE_CYCLE_DURATION / 2 ? timing - FOUR_STROKE_CYCLE_DURATION : timing;
// 60
tsOutputChannels.sparkDwell = ENGINE(engineState.sparkDwell);
tsOutputChannels.sparkDwell = engine->engineState.sparkDwell;
tsOutputChannels.coilDutyCycle = getCoilDutyCycle(rpm);
tsOutputChannels.knockRetard = ENGINE(knockController).getKnockRetard();
tsOutputChannels.knockRetard = engine->knockController.getKnockRetard();
}
static void updateFlags() {
@ -644,8 +644,8 @@ static void updateFlags() {
tsOutputChannels.isFanOn = enginePins.fanRelay.getLogicValue();
tsOutputChannels.isFan2On = enginePins.fanRelay2.getLogicValue();
tsOutputChannels.isO2HeaterOn = enginePins.o2heater.getLogicValue();
tsOutputChannels.isIgnitionEnabledIndicator = ENGINE(limpManager).allowIgnition();
tsOutputChannels.isInjectionEnabledIndicator = ENGINE(limpManager).allowInjection();
tsOutputChannels.isIgnitionEnabledIndicator = engine->limpManager.allowIgnition();
tsOutputChannels.isInjectionEnabledIndicator = engine->limpManager.allowInjection();
tsOutputChannels.isCylinderCleanupActivated = engine->isCylinderCleanupMode;
#if EFI_LAUNCH_CONTROL

View File

@ -18,7 +18,7 @@ bool AcState::getAcState() {
return false;
}
auto maxRpm = CONFIG(maxAcRpm);
auto maxRpm = engineConfiguration->maxAcRpm;
engineTooFast = maxRpm != 0 && maxRpmDeadband.gt(rpm, maxRpm);
if (engineTooFast) {
return false;
@ -33,20 +33,20 @@ bool AcState::getAcState() {
}
// Engine too hot, disable
auto maxClt = CONFIG(maxAcClt);
auto maxClt = engineConfiguration->maxAcClt;
engineTooHot = (maxClt != 0) && maxCltDeadband.gt(clt.Value, maxClt);
if (engineTooHot) {
return false;
}
// TPS too high, disable
auto maxTps = CONFIG(maxAcTps);
auto maxTps = engineConfiguration->maxAcTps;
tpsTooHigh = maxTps != 0 && maxTpsDeadband.gt(Sensor::getOrZero(SensorType::Tps1), maxTps);
if (tpsTooHigh) {
return false;
}
acButtonState = ENGINE(acSwitchState);
acButtonState = engine->acSwitchState;
// All conditions allow AC, simply pass thru switch
return acButtonState;
}

View File

@ -59,7 +59,7 @@ class AlternatorController : public PeriodicTimerController {
// todo: migrate this to FSIO
bool alternatorShouldBeEnabledAtCurrentRpm = GET_RPM() > engineConfiguration->cranking.rpm;
if (!CONFIG(isAlternatorControlEnabled) || !alternatorShouldBeEnabledAtCurrentRpm) {
if (!engineConfiguration->isAlternatorControlEnabled || !alternatorShouldBeEnabledAtCurrentRpm) {
// we need to avoid accumulating iTerm while engine is not running
pidReset();
@ -72,7 +72,7 @@ class AlternatorController : public PeriodicTimerController {
auto vBatt = Sensor::get(SensorType::BatteryVoltage);
float targetVoltage = engineConfiguration->targetVBatt;
if (CONFIG(onOffAlternatorLogic)) {
if (engineConfiguration->onOffAlternatorLogic) {
if (!vBatt) {
// Somehow battery voltage isn't valid, disable alternator control
enginePins.alternatorPin.setValue(false);
@ -97,7 +97,7 @@ class AlternatorController : public PeriodicTimerController {
alternatorControl.setSimplePwmDutyCycle(0);
} else {
currentAltDuty = alternatorPid.getOutput(targetVoltage, vBatt.Value);
if (CONFIG(isVerboseAlternator)) {
if (engineConfiguration->isVerboseAlternator) {
efiPrintf("alt duty: %.2f/vbatt=%.2f/p=%.2f/i=%.2f/d=%.2f int=%.2f", currentAltDuty, vBatt.Value,
alternatorPid.getP(), alternatorPid.getI(), alternatorPid.getD(), alternatorPid.getIntegration());
}
@ -111,7 +111,7 @@ static AlternatorController instance;
void showAltInfo(void) {
efiPrintf("alt=%s @%s t=%dms", boolToString(engineConfiguration->isAlternatorControlEnabled),
hwPortname(CONFIG(alternatorControlPin)),
hwPortname(engineConfiguration->alternatorControlPin),
engineConfiguration->alternatorControl.periodMs);
efiPrintf("p=%.2f/i=%.2f/d=%.2f offset=%.2f", engineConfiguration->alternatorControl.pFactor,
0, 0, engineConfiguration->alternatorControl.offset); // todo: i & d
@ -132,10 +132,10 @@ void onConfigurationChangeAlternatorCallback(engine_configuration_s *previousCon
void initAlternatorCtrl() {
addConsoleAction("altinfo", showAltInfo);
if (!isBrainPinValid(CONFIG(alternatorControlPin)))
if (!isBrainPinValid(engineConfiguration->alternatorControlPin))
return;
if (!CONFIG(onOffAlternatorLogic)) {
if (!engineConfiguration->onOffAlternatorLogic) {
startSimplePwm(&alternatorControl,
"Alternator control",
&engine->executor,

View File

@ -106,7 +106,7 @@ percent_t BoostController::getClosedLoopImpl(float target, float manifoldPressur
return 0;
}
if (manifoldPressure < CONFIG(minimumBoostClosedLoopMap)) {
if (manifoldPressure < engineConfiguration->minimumBoostClosedLoopMap) {
// We're below the CL threshold, inhibit CL for now
m_pid.reset();
return 0;
@ -129,7 +129,7 @@ expected<percent_t> BoostController::getClosedLoop(float target, float manifoldP
}
void BoostController::setOutput(expected<float> output) {
percent_t percent = output.value_or(CONFIG(boostControlSafeDutyCycle));
percent_t percent = output.value_or(engineConfiguration->boostControlSafeDutyCycle);
#if EFI_TUNER_STUDIO
if (engineConfiguration->debugMode == DBG_BOOST) {
@ -183,15 +183,15 @@ void setDefaultBoostParameters() {
}
// Defaults for ETB-style wastegate actuator
CONFIG(etbWastegatePid).pFactor = 1;
CONFIG(etbWastegatePid).minValue = -60;
CONFIG(etbWastegatePid).maxValue = 60;
engineConfiguration->etbWastegatePid.pFactor = 1;
engineConfiguration->etbWastegatePid.minValue = -60;
engineConfiguration->etbWastegatePid.maxValue = 60;
}
void startBoostPin() {
#if !EFI_UNIT_TEST
// Only init if a pin is set, no need to start PWM without a pin
if (!isBrainPinValid(CONFIG(boostControlPin))) {
if (!isBrainPinValid(engineConfiguration->boostControlPin)) {
return;
}
@ -213,18 +213,18 @@ void onConfigurationChangeBoostCallback(engine_configuration_s *previousConfigur
void initBoostCtrl() {
// todo: why do we have 'isBoostControlEnabled' setting exactly?
// 'initAuxPid' is an example of a subsystem without explicit enable
if (!CONFIG(isBoostControlEnabled)) {
if (!engineConfiguration->isBoostControlEnabled) {
return;
}
bool hasAnyEtbWastegate = false;
for (size_t i = 0; i < efi::size(CONFIG(etbFunctions)); i++) {
hasAnyEtbWastegate |= CONFIG(etbFunctions)[i] == ETB_Wastegate;
for (size_t i = 0; i < efi::size(engineConfiguration->etbFunctions); i++) {
hasAnyEtbWastegate |= engineConfiguration->etbFunctions[i] == ETB_Wastegate;
}
// If we have neither a boost PWM pin nor ETB wastegate, nothing more to do
if (!isBrainPinValid(CONFIG(boostControlPin)) && !hasAnyEtbWastegate) {
if (!isBrainPinValid(engineConfiguration->boostControlPin) && !hasAnyEtbWastegate) {
return;
}

View File

@ -123,9 +123,9 @@ DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires) {
io.directionPin1,
io.directionPin2,
io.disablePin,
CONFIG(stepperDcInvertedPins),
&ENGINE(executor),
CONFIG(etbFreq)
engineConfiguration->stepperDcInvertedPins,
&engine->executor,
engineConfiguration->etbFreq
);
return &hw.dcMotor;

View File

@ -304,10 +304,10 @@ expected<percent_t> EtbController::getSetpointEtb() const {
percent_t etbIdlePosition = clampF(
0,
CONFIG(useETBforIdleControl) ? m_idlePosition : 0,
engineConfiguration->useETBforIdleControl ? m_idlePosition : 0,
100
);
percent_t etbIdleAddition = 0.01f * CONFIG(etbIdleThrottleRange) * etbIdlePosition;
percent_t etbIdleAddition = 0.01f * engineConfiguration->etbIdleThrottleRange * etbIdlePosition;
// Interpolate so that the idle adder just "compresses" the throttle's range upward.
// [0, 100] -> [idle, 100]
@ -316,9 +316,9 @@ expected<percent_t> EtbController::getSetpointEtb() const {
percent_t targetPosition = interpolateClamped(0, etbIdleAddition, 100, 100, targetFromTable);
// Lastly, apply ETB rev limiter
auto etbRpmLimit = CONFIG(etbRevLimitStart);
auto etbRpmLimit = engineConfiguration->etbRevLimitStart;
if (etbRpmLimit != 0) {
auto fullyLimitedRpm = etbRpmLimit + CONFIG(etbRevLimitRange);
auto fullyLimitedRpm = etbRpmLimit + engineConfiguration->etbRevLimitRange;
// Linearly taper throttle to closed from the limit across the range
targetPosition = interpolateClamped(etbRpmLimit, targetPosition, fullyLimitedRpm, 0, rpm);
}
@ -330,7 +330,7 @@ expected<percent_t> EtbController::getSetpointEtb() const {
#endif // EFI_TUNER_STUDIO
// Keep the throttle just barely off the lower stop, and less than the user-configured maximum
float maxPosition = CONFIG(etbMaximumPosition);
float maxPosition = engineConfiguration->etbMaximumPosition;
if (maxPosition < 70) {
maxPosition = 100;
@ -482,7 +482,7 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t obs
float errorIntegral = m_errorAccumulator.accumulate(target - observation);
#if EFI_TUNER_STUDIO
if (m_function == ETB_Throttle1 && CONFIG(debugMode) == DBG_ETB_LOGIC) {
if (m_function == ETB_Throttle1 && engineConfiguration->debugMode == DBG_ETB_LOGIC) {
tsOutputChannels.debugFloatField3 = errorIntegral;
}
#endif // EFI_TUNER_STUDIO
@ -490,7 +490,7 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t obs
// Allow up to 10 percent-seconds of error
if (errorIntegral > 10.0f) {
// TODO: figure out how to handle uncalibrated ETB
//ENGINE(limpManager).etbProblem();
//engine->limpManager.etbProblem();
}
// Normal case - use PID to compute closed loop part
@ -509,7 +509,7 @@ void EtbController::setOutput(expected<percent_t> outputValue) {
if (!m_motor) return;
// If ETB is allowed, output is valid, and we aren't paused, output to motor.
if (ENGINE(limpManager).allowElectronicThrottle()
if (engine->limpManager.allowElectronicThrottle()
&& outputValue
&& !engineConfiguration->pauseEtbControl) {
m_motor->enable();
@ -545,7 +545,7 @@ void EtbController::update() {
return;
}
if (CONFIG(disableEtbWhenEngineStopped)) {
if (engineConfiguration->disableEtbWhenEngineStopped) {
if (engine->triggerCentral.getTimeSinceTriggerEvent(getTimeNowNt()) > 1) {
// If engine is stopped and so configured, skip the ETB update entirely
// This is quieter and pulls less power than leaving it on all the time
@ -687,16 +687,16 @@ static void showEthInfo() {
efiPrintf("etbControlPin=%s duty=%.2f freq=%d",
hwPortname(CONFIG(etbIo[0].controlPin)),
hwPortname(engineConfiguration->etbIo[0].controlPin),
currentEtbDuty,
engineConfiguration->etbFreq);
for (int i = 0; i < ETB_COUNT; i++) {
efiPrintf("ETB%d", i);
efiPrintf(" dir1=%s", hwPortname(CONFIG(etbIo[i].directionPin1)));
efiPrintf(" dir2=%s", hwPortname(CONFIG(etbIo[i].directionPin2)));
efiPrintf(" control=%s", hwPortname(CONFIG(etbIo[i].controlPin)));
efiPrintf(" disable=%s", hwPortname(CONFIG(etbIo[i].disablePin)));
efiPrintf(" dir1=%s", hwPortname(engineConfiguration->etbIo[i].directionPin1));
efiPrintf(" dir2=%s", hwPortname(engineConfiguration->etbIo[i].directionPin2));
efiPrintf(" control=%s", hwPortname(engineConfiguration->etbIo[i].controlPin));
efiPrintf(" disable=%s", hwPortname(engineConfiguration->etbIo[i].disablePin));
showDcMotorInfo(i);
}
@ -829,12 +829,12 @@ void setBoschVAGETB() {
}
void setBoschVNH2SP30Curve() {
copyArray(CONFIG(etbBiasBins), boschBiasBins);
copyArray(CONFIG(etbBiasValues), boschBiasValues);
copyArray(engineConfiguration->etbBiasBins, boschBiasBins);
copyArray(engineConfiguration->etbBiasValues, boschBiasValues);
}
void setDefaultEtbParameters() {
CONFIG(etbIdleThrottleRange) = 5;
engineConfiguration->etbIdleThrottleRange = 5;
setLinearCurve(config->pedalToTpsPedalBins, /*from*/0, /*to*/100, 1);
setLinearCurve(config->pedalToTpsRpmBins, /*from*/0, /*to*/8000 / RPM_1_BYTE_PACKING_MULT, 1);
@ -901,8 +901,8 @@ static const float defaultBiasValues[] = {
};
void setDefaultEtbBiasCurve() {
copyArray(CONFIG(etbBiasBins), defaultBiasBins);
copyArray(CONFIG(etbBiasValues), defaultBiasValues);
copyArray(engineConfiguration->etbBiasBins, defaultBiasBins);
copyArray(engineConfiguration->etbBiasValues, defaultBiasValues);
}
void unregisterEtbPins() {
@ -911,8 +911,8 @@ void unregisterEtbPins() {
static pid_s* getEtbPidForFunction(etb_function_e function) {
switch (function) {
case ETB_Wastegate: return &CONFIG(etbWastegatePid);
default: return &CONFIG(etb);
case ETB_Wastegate: return &engineConfiguration->etbWastegatePid;
default: return &engineConfiguration->etb;
}
}
@ -938,12 +938,12 @@ void doInitElectronicThrottle() {
// todo: technical debt: we still have DC motor code initialization in ETB-specific file while DC motors are used not just as ETB
// todo: rename etbFunctions to something-without-etb for same reason?
for (int i = 0 ; i < ETB_COUNT; i++) {
auto func = CONFIG(etbFunctions[i]);
auto func = engineConfiguration->etbFunctions[i];
if (func == ETB_None) {
// do not touch HW pins if function not selected, this way Lua can use DC motor hardware pins directly
continue;
}
auto motor = initDcMotor(engineConfiguration->etbIo[i], i, CONFIG(etb_use_two_wires));
auto motor = initDcMotor(engineConfiguration->etbIo[i], i, engineConfiguration->etb_use_two_wires);
// If this motor is actually set up, init the etb
if (motor)
@ -1050,10 +1050,10 @@ void setHitachiEtbCalibration() {
engineConfiguration->etb.maxValue = 100.0;
// Nissan 60mm throttle
CONFIG(tpsMin) = CONFIG(tps2Min) = 113;
CONFIG(tpsMax) = CONFIG(tps2Max) = 846;
CONFIG(tps1SecondaryMin) = CONFIG(tps2SecondaryMin) = 897;
CONFIG(tps1SecondaryMax) = CONFIG(tps2SecondaryMax) = 161;
engineConfiguration->tpsMin = engineConfiguration->tps2Min = 113;
engineConfiguration->tpsMax = engineConfiguration->tps2Max = 846;
engineConfiguration->tps1SecondaryMin = engineConfiguration->tps2SecondaryMin = 897;
engineConfiguration->tps1SecondaryMax = engineConfiguration->tps2SecondaryMax = 161;
}
void setProteusHitachiEtbDefaults() {

View File

@ -7,8 +7,8 @@
static void fanControl(bool acActive, OutputPin& pin, int8_t fanOnTemp, int8_t fanOffTemp, bool enableWithAc, bool disableWhenStopped) {
auto [cltValid, clt] = Sensor::get(SensorType::Clt);
bool isCranking = ENGINE(rpmCalculator).isCranking();
bool isRunning = ENGINE(rpmCalculator).isRunning();
bool isCranking = engine->rpmCalculator.isCranking();
bool isRunning = engine->rpmCalculator.isRunning();
if (isCranking) {
// Inhibit while cranking
@ -39,6 +39,6 @@ void updateFans(bool acActive) {
}
#endif
fanControl(acActive, enginePins.fanRelay, CONFIG(fanOnTemperature), CONFIG(fanOffTemperature), CONFIG(enableFan1WithAc), CONFIG(disableFan1WhenStopped));
fanControl(acActive, enginePins.fanRelay2, CONFIG(fan2OnTemperature), CONFIG(fan2OffTemperature), CONFIG(enableFan2WithAc), CONFIG(disableFan2WhenStopped));
fanControl(acActive, enginePins.fanRelay, engineConfiguration->fanOnTemperature, engineConfiguration->fanOffTemperature, engineConfiguration->enableFan1WithAc, engineConfiguration->disableFan1WhenStopped);
fanControl(acActive, enginePins.fanRelay2, engineConfiguration->fan2OnTemperature, engineConfiguration->fan2OffTemperature, engineConfiguration->enableFan2WithAc, engineConfiguration->disableFan2WhenStopped);
}

View File

@ -21,7 +21,7 @@ static gppwm_Map3D_t* tables[] = {
void initGpPwm() {
for (size_t i = 0; i < efi::size(channels); i++) {
auto& cfg = CONFIG(gppwm)[i];
auto& cfg = engineConfiguration->gppwm[i];
// If no pin, don't enable this channel.
if (!isBrainPinValid(cfg.pin)) {
@ -54,7 +54,7 @@ void updateGppwm() {
float result = channels[i].update();
#ifdef EFI_TUNER_STUDIO
if (CONFIG(debugMode) == DBG_GPPWM) {
if (engineConfiguration->debugMode == DBG_GPPWM) {
scaled_channel<float>* debugFloats = &tsOutputChannels.debugFloatField1;
debugFloats[i] = result;
}

View File

@ -32,12 +32,12 @@ void applyIACposition(percent_t position) {
*/
float duty = PERCENT_TO_DUTY(position);
if (CONFIG(useETBforIdleControl)) {
if (engineConfiguration->useETBforIdleControl) {
#if EFI_ELECTRONIC_THROTTLE_BODY
setEtbIdlePosition(position);
#endif // EFI_ELECTRONIC_THROTTLE_BODY
#if ! EFI_UNIT_TEST
} else if (CONFIG(useStepperIdle)) {
} else if (engineConfiguration->useStepperIdle) {
iacMotor.setTargetPosition(duty * engineConfiguration->idleStepperTotalSteps);
#endif /* EFI_UNIT_TEST */
} else {
@ -48,7 +48,7 @@ void applyIACposition(percent_t position) {
return;
}
if (!CONFIG(isDoubleSolenoidIdle)) {
if (!engineConfiguration->isDoubleSolenoidIdle) {
idleSolenoidOpen.setSimplePwmDutyCycle(duty);
} else {
/* use 0.01..0.99 range */
@ -78,7 +78,7 @@ bool isIdleHardwareRestartNeeded() {
}
bool isIdleMotorBusy() {
if (!CONFIG(useStepperIdle)) {
if (!engineConfiguration->useStepperIdle) {
// todo: check other motor types?
return false;
}
@ -86,10 +86,10 @@ bool isIdleMotorBusy() {
}
void initIdleHardware() {
if (CONFIG(useStepperIdle)) {
if (engineConfiguration->useStepperIdle) {
StepperHw* hw;
if (CONFIG(useHbridgesToDriveIdleStepper)) {
if (engineConfiguration->useHbridgesToDriveIdleStepper) {
auto motorA = initDcMotor(engineConfiguration->stepperDcIo[0], 2, /*useTwoWires*/ true);
auto motorB = initDcMotor(engineConfiguration->stepperDcIo[1], 3, /*useTwoWires*/ true);
@ -97,26 +97,26 @@ void initIdleHardware() {
iacHbridgeHw.initialize(
motorA,
motorB,
CONFIG(idleStepperReactionTime)
engineConfiguration->idleStepperReactionTime
);
}
hw = &iacHbridgeHw;
} else {
iacStepperHw.initialize(
CONFIG(idle).stepperStepPin,
CONFIG(idle).stepperDirectionPin,
CONFIG(stepperDirectionPinMode),
CONFIG(idleStepperReactionTime),
CONFIG(stepperEnablePin),
CONFIG(stepperEnablePinMode)
engineConfiguration->idle.stepperStepPin,
engineConfiguration->idle.stepperDirectionPin,
engineConfiguration->stepperDirectionPinMode,
engineConfiguration->idleStepperReactionTime,
engineConfiguration->stepperEnablePin,
engineConfiguration->stepperEnablePinMode
);
hw = &iacStepperHw;
}
iacMotor.initialize(hw, CONFIG(idleStepperTotalSteps));
} else if (engineConfiguration->useETBforIdleControl || !isBrainPinValid(CONFIG(idle).solenoidPin)) {
iacMotor.initialize(hw, engineConfiguration->idleStepperTotalSteps);
} else if (engineConfiguration->useETBforIdleControl || !isBrainPinValid(engineConfiguration->idle.solenoidPin)) {
// here we do nothing for ETB idle and for no idle
} else {
// we are here for single or double solenoid idle
@ -128,10 +128,10 @@ void initIdleHardware() {
startSimplePwm(&idleSolenoidOpen, "Idle Valve Open",
&engine->executor,
&enginePins.idleSolenoidPin,
CONFIG(idle).solenoidFrequency, PERCENT_TO_DUTY(CONFIG(manIdlePosition)));
engineConfiguration->idle.solenoidFrequency, PERCENT_TO_DUTY(engineConfiguration->manIdlePosition));
if (CONFIG(isDoubleSolenoidIdle)) {
if (!isBrainPinValid(CONFIG(secondSolenoidPin))) {
if (engineConfiguration->isDoubleSolenoidIdle) {
if (!isBrainPinValid(engineConfiguration->secondSolenoidPin)) {
firmwareError(OBD_PCM_Processor_Fault, "Second idle pin should be configured for double solenoid mode.");
return;
}
@ -139,7 +139,7 @@ void initIdleHardware() {
startSimplePwm(&idleSolenoidClose, "Idle Valve Close",
&engine->executor,
&enginePins.secondIdleSolenoidPin,
CONFIG(idle).solenoidFrequency, PERCENT_TO_DUTY(CONFIG(manIdlePosition)));
engineConfiguration->idle.solenoidFrequency, PERCENT_TO_DUTY(engineConfiguration->manIdlePosition));
}
}
}

View File

@ -51,7 +51,7 @@ static PidCic idleCicPid;
Pid * getIdlePid() {
#if EFI_IDLE_PID_CIC
if (CONFIG(useCicPidForIdle)) {
if (engineConfiguration->useCicPidForIdle) {
return &idleCicPid;
}
#endif /* EFI_IDLE_PID_CIC */
@ -69,36 +69,36 @@ void idleDebug(const char *msg, percent_t value) {
static void showIdleInfo() {
const char * idleModeStr = getIdle_mode_e(engineConfiguration->idleMode);
efiPrintf("useStepperIdle=%s useHbridges=%s",
boolToString(CONFIG(useStepperIdle)), boolToString(CONFIG(useHbridgesToDriveIdleStepper)));
boolToString(engineConfiguration->useStepperIdle), boolToString(engineConfiguration->useHbridgesToDriveIdleStepper));
efiPrintf("idleMode=%s position=%.2f",
idleModeStr, getIdlePosition());
if (CONFIG(useStepperIdle)) {
if (CONFIG(useHbridgesToDriveIdleStepper)) {
if (engineConfiguration->useStepperIdle) {
if (engineConfiguration->useHbridgesToDriveIdleStepper) {
efiPrintf("Coil A:");
efiPrintf(" pin1=%s", hwPortname(CONFIG(stepperDcIo[0].directionPin1)));
efiPrintf(" pin2=%s", hwPortname(CONFIG(stepperDcIo[0].directionPin2)));
efiPrintf(" pin1=%s", hwPortname(engineConfiguration->stepperDcIo[0].directionPin1));
efiPrintf(" pin2=%s", hwPortname(engineConfiguration->stepperDcIo[0].directionPin2));
showDcMotorInfo(2);
efiPrintf("Coil B:");
efiPrintf(" pin1=%s", hwPortname(CONFIG(stepperDcIo[1].directionPin1)));
efiPrintf(" pin2=%s", hwPortname(CONFIG(stepperDcIo[1].directionPin2)));
efiPrintf(" pin1=%s", hwPortname(engineConfiguration->stepperDcIo[1].directionPin1));
efiPrintf(" pin2=%s", hwPortname(engineConfiguration->stepperDcIo[1].directionPin2));
showDcMotorInfo(3);
} else {
efiPrintf("directionPin=%s reactionTime=%.2f", hwPortname(CONFIG(idle).stepperDirectionPin),
efiPrintf("directionPin=%s reactionTime=%.2f", hwPortname(engineConfiguration->idle.stepperDirectionPin),
engineConfiguration->idleStepperReactionTime);
efiPrintf("stepPin=%s steps=%d", hwPortname(CONFIG(idle).stepperStepPin),
efiPrintf("stepPin=%s steps=%d", hwPortname(engineConfiguration->idle.stepperStepPin),
engineConfiguration->idleStepperTotalSteps);
efiPrintf("enablePin=%s/%d", hwPortname(engineConfiguration->stepperEnablePin),
engineConfiguration->stepperEnablePinMode);
}
} else {
if (!CONFIG(isDoubleSolenoidIdle)) {
efiPrintf("idle valve freq=%d on %s", CONFIG(idle).solenoidFrequency,
hwPortname(CONFIG(idle).solenoidPin));
if (!engineConfiguration->isDoubleSolenoidIdle) {
efiPrintf("idle valve freq=%d on %s", engineConfiguration->idle.solenoidFrequency,
hwPortname(engineConfiguration->idle.solenoidPin));
} else {
efiPrintf("idle valve freq=%d on %s", CONFIG(idle).solenoidFrequency,
hwPortname(CONFIG(idle).solenoidPin));
efiPrintf(" and %s", hwPortname(CONFIG(secondSolenoidPin)));
efiPrintf("idle valve freq=%d on %s", engineConfiguration->idle.solenoidFrequency,
hwPortname(engineConfiguration->idle.solenoidPin));
efiPrintf(" and %s", hwPortname(engineConfiguration->secondSolenoidPin));
}
}
@ -124,7 +124,7 @@ void setManualIdleValvePosition(int positionPercent) {
showIdleInfo();
#endif /* EFI_UNIT_TEST */
// todo: this is not great that we have to write into configuration here
CONFIG(manIdlePosition) = positionPercent;
engineConfiguration->manIdlePosition = positionPercent;
}
#endif /* EFI_UNIT_TEST */
@ -137,10 +137,10 @@ void IdleController::init(pid_s* idlePidConfig) {
}
int IdleController::getTargetRpm(float clt) const {
auto target = interpolate2d(clt, CONFIG(cltIdleRpmBins), CONFIG(cltIdleRpm));
auto target = interpolate2d(clt, engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm);
// Bump for AC
target += engine->acSwitchState ? CONFIG(acIdleRpmBump) : 0;
target += engine->acSwitchState ? engineConfiguration->acIdleRpmBump : 0;
return target;
}
@ -156,18 +156,18 @@ IIdleController::Phase IdleController::determinePhase(int rpm, int targetRpm, Se
}
// if throttle pressed, we're out of the idle corner
if (tps.Value > CONFIG(idlePidDeactivationTpsThreshold)) {
if (tps.Value > engineConfiguration->idlePidDeactivationTpsThreshold) {
return Phase::Running;
}
// If rpm too high (but throttle not pressed), we're coasting
int maximumIdleRpm = targetRpm + CONFIG(idlePidRpmUpperLimit);
int maximumIdleRpm = targetRpm + engineConfiguration->idlePidRpmUpperLimit;
if (rpm > maximumIdleRpm) {
return Phase::Coasting;
}
// If the vehicle is moving too quickly, disable CL idle
auto maxVss = CONFIG(maxIdleVss);
auto maxVss = engineConfiguration->maxIdleVss;
if (maxVss != 0 && vss > maxVss) {
return Phase::Running;
}
@ -182,35 +182,35 @@ IIdleController::Phase IdleController::determinePhase(int rpm, int targetRpm, Se
}
float IdleController::getCrankingTaperFraction() const {
return (float)engine->rpmCalculator.getRevolutionCounterSinceStart() / CONFIG(afterCrankingIACtaperDuration);
return (float)engine->rpmCalculator.getRevolutionCounterSinceStart() / engineConfiguration->afterCrankingIACtaperDuration;
}
float IdleController::getCrankingOpenLoop(float clt) const {
float mult =
CONFIG(overrideCrankingIacSetting)
engineConfiguration->overrideCrankingIacSetting
// Override to separate table
? interpolate2d(clt, config->cltCrankingCorrBins, config->cltCrankingCorr)
// Otherwise use plain running table
: interpolate2d(clt, config->cltIdleCorrBins, config->cltIdleCorr);
return CONFIG(crankingIACposition) * mult;
return engineConfiguration->crankingIACposition * mult;
}
float IdleController::getRunningOpenLoop(float clt, SensorResult tps) const {
float running =
CONFIG(manIdlePosition) // Base idle position (slider)
engineConfiguration->manIdlePosition // Base idle position (slider)
* interpolate2d(clt, config->cltIdleCorrBins, config->cltIdleCorr);
// Now we bump it by the AC/fan amount if necessary
running += engine->acSwitchState ? CONFIG(acIdleExtraOffset) : 0;
running += enginePins.fanRelay.getLogicValue() ? CONFIG(fan1ExtraIdle) : 0;
running += enginePins.fanRelay2.getLogicValue() ? CONFIG(fan2ExtraIdle) : 0;
running += engine->acSwitchState ? engineConfiguration->acIdleExtraOffset : 0;
running += enginePins.fanRelay.getLogicValue() ? engineConfiguration->fan1ExtraIdle : 0;
running += enginePins.fanRelay2.getLogicValue() ? engineConfiguration->fan2ExtraIdle : 0;
// Now bump it by the specified amount when the throttle is opened (if configured)
// nb: invalid tps will make no change, no explicit check required
running += interpolateClamped(
0, 0,
CONFIG(idlePidDeactivationTpsThreshold), CONFIG(iacByTpsTaper),
engineConfiguration->idlePidDeactivationTpsThreshold, engineConfiguration->iacByTpsTaper,
tps.value_or(0));
return clampF(0, running, 100);
@ -226,8 +226,8 @@ float IdleController::getOpenLoop(Phase phase, float clt, SensorResult tps, floa
// If coasting (and enabled), use the coasting position table instead of normal open loop
// TODO: this should be a table of open loop mult vs. RPM, not vs. clt
if (CONFIG(useIacTableForCoasting) && phase == Phase::Coasting) {
return interpolate2d(clt, CONFIG(iacCoastingBins), CONFIG(iacCoasting));
if (engineConfiguration->useIacTableForCoasting && phase == Phase::Coasting) {
return interpolate2d(clt, engineConfiguration->iacCoastingBins, engineConfiguration->iacCoasting);
}
float running = getRunningOpenLoop(clt, tps);
@ -243,7 +243,7 @@ float IdleController::getIdleTimingAdjustment(int rpm) {
float IdleController::getIdleTimingAdjustment(int rpm, int targetRpm, Phase phase) {
// if not enabled, do nothing
if (!CONFIG(useIdleTimingPidControl)) {
if (!engineConfiguration->useIdleTimingPidControl) {
return 0;
}
@ -253,12 +253,12 @@ float IdleController::getIdleTimingAdjustment(int rpm, int targetRpm, Phase phas
return 0;
}
if (CONFIG(useInstantRpmForIdle)) {
if (engineConfiguration->useInstantRpmForIdle) {
rpm = engine->triggerCentral.triggerState.getInstantRpm();
}
// If inside the deadzone, do nothing
if (absI(rpm - targetRpm) < CONFIG(idleTimingPidDeadZone)) {
if (absI(rpm - targetRpm) < engineConfiguration->idleTimingPidDeadZone) {
m_timingPid.reset();
return 0;
}
@ -332,7 +332,7 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos,
// #1553 we need to give FSIO variable offset or minValue a chance
bool acToggleJustTouched = (nowUs - engine->acSwitchLastChangeTime) < MS2US(500);
// check if within the dead zone
if (!acToggleJustTouched && absI(rpm - targetRpm) <= CONFIG(idlePidRpmDeadZone)) {
if (!acToggleJustTouched && absI(rpm - targetRpm) <= engineConfiguration->idlePidRpmDeadZone) {
engine->idle.idleState = RPM_DEAD_ZONE;
// current RPM is close enough, no need to change anything
return m_lastAutomaticPosition;
@ -342,7 +342,7 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos,
// So PID reaction should be increased by adding extra percent to PID-error:
percent_t errorAmpCoef = 1.0f;
if (rpm < targetRpm) {
errorAmpCoef += (float)CONFIG(pidExtraForLowRpm) / PERCENT_MULT;
errorAmpCoef += (float)engineConfiguration->pidExtraForLowRpm / PERCENT_MULT;
}
// if PID was previously reset, we store the time when it turned on back (see errorAmpCoef correction below)
@ -354,7 +354,7 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos,
// todo: move restoreAfterPidResetTimeUs to idle?
efitimeus_t timeSincePidResetUs = nowUs - /*engine->idle.*/restoreAfterPidResetTimeUs;
// todo: add 'pidAfterResetDampingPeriodMs' setting
errorAmpCoef = interpolateClamped(0, 0, MS2US(/*CONFIG(pidAfterResetDampingPeriodMs)*/1000), errorAmpCoef, timeSincePidResetUs);
errorAmpCoef = interpolateClamped(0, 0, MS2US(/*engineConfiguration->pidAfterResetDampingPeriodMs*/1000), errorAmpCoef, timeSincePidResetUs);
// If errorAmpCoef > 1.0, then PID thinks that RPM is lower than it is, and controls IAC more aggressively
idlePid->setErrorAmplification(errorAmpCoef);
@ -365,7 +365,7 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos,
engine->idle.mightResetPid = true;
// Apply PID Multiplier if used
if (CONFIG(useIacPidMultTable)) {
if (engineConfiguration->useIacPidMultTable) {
float engineLoad = getFuelingLoad();
float multCoef = iacPidMultMap.getValue(rpm / RPM_1_BYTE_PACKING_MULT, engineLoad);
// PID can be completely disabled of multCoef==0, or it just works as usual if multCoef==1
@ -376,7 +376,7 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos,
// if tps==0 then PID just works as usual, or we completely disable it if tps>=threshold
// TODO: should we just remove this? It reduces the gain if your zero throttle stop isn't perfect,
// which could give unstable results.
newValue = interpolateClamped(0, newValue, CONFIG(idlePidDeactivationTpsThreshold), 0, tpsPos);
newValue = interpolateClamped(0, newValue, engineConfiguration->idlePidDeactivationTpsThreshold, 0, tpsPos);
m_lastAutomaticPosition = newValue;
return newValue;
@ -386,7 +386,7 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos,
// Simplify hardware CI: we borrow the idle valve controller as a PWM source for various stimulation tasks
// The logic in this function is solidly unit tested, so it's not necessary to re-test the particulars on real hardware.
#ifdef HARDWARE_CI
return CONFIG(manIdlePosition);
return engineConfiguration->manIdlePosition;
#endif
/*
@ -404,7 +404,7 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos,
auto tps = Sensor::get(SensorType::DriverThrottleIntent);
float rpm;
if (CONFIG(useInstantRpmForIdle)) {
if (engineConfiguration->useInstantRpmForIdle) {
rpm = engine->triggerCentral.triggerState.getInstantRpm();
} else {
rpm = GET_RPM();
@ -494,7 +494,7 @@ bool isIdlingOrTaper() {
static void applyPidSettings() {
getIdlePid()->updateFactors(engineConfiguration->idleRpmPid.pFactor, engineConfiguration->idleRpmPid.iFactor, engineConfiguration->idleRpmPid.dFactor);
iacPidMultMap.init(CONFIG(iacPidMultTable), CONFIG(iacPidMultLoadBins), CONFIG(iacPidMultRpmBins));
iacPidMultMap.init(engineConfiguration->iacPidMultTable, engineConfiguration->iacPidMultLoadBins, engineConfiguration->iacPidMultRpmBins);
}
void setDefaultIdleParameters() {
@ -506,16 +506,16 @@ void setDefaultIdleParameters() {
engineConfiguration->idlerpmpid_iTermMax = 20;
// Good starting point is 10 degrees per 100 rpm, aka 0.1 deg/rpm
CONFIG(idleTimingPid).pFactor = 0.1f;
CONFIG(idleTimingPid).iFactor = 0;
CONFIG(idleTimingPid).dFactor = 0;
engineConfiguration->idleTimingPid.pFactor = 0.1f;
engineConfiguration->idleTimingPid.iFactor = 0;
engineConfiguration->idleTimingPid.dFactor = 0;
// Allow +- 10 degrees adjustment
CONFIG(idleTimingPid).minValue = -10;
CONFIG(idleTimingPid).minValue = 10;
engineConfiguration->idleTimingPid.minValue = -10;
engineConfiguration->idleTimingPid.minValue = 10;
// Idle region is target + 100 RPM
CONFIG(idlePidRpmUpperLimit) = 100;
engineConfiguration->idlePidRpmUpperLimit = 100;
}
#if ! EFI_UNIT_TEST
@ -566,9 +566,9 @@ void startIdleBench(void) {
#endif /* EFI_UNIT_TEST */
void startIdleThread() {
idleControllerInstance.init(&CONFIG(idleTimingPid));
idleControllerInstance.init(&engineConfiguration->idleTimingPid);
ENGINE(idleController) = &idleControllerInstance;
engine->idleController = &idleControllerInstance;
getIdlePid()->initPidClass(&engineConfiguration->idleRpmPid);
@ -602,19 +602,19 @@ void startPedalPins() {
#if EFI_PROD_CODE
// this is neutral/no gear switch input. on Miata it's wired both to clutch pedal and neutral in gearbox
// this switch is not used yet
if (isBrainPinValid(CONFIG(clutchDownPin))) {
efiSetPadMode("clutch down switch", CONFIG(clutchDownPin),
getInputMode(CONFIG(clutchDownPinMode)));
if (isBrainPinValid(engineConfiguration->clutchDownPin)) {
efiSetPadMode("clutch down switch", engineConfiguration->clutchDownPin,
getInputMode(engineConfiguration->clutchDownPinMode));
}
if (isBrainPinValid(CONFIG(clutchUpPin))) {
efiSetPadMode("clutch up switch", CONFIG(clutchUpPin),
getInputMode(CONFIG(clutchUpPinMode)));
if (isBrainPinValid(engineConfiguration->clutchUpPin)) {
efiSetPadMode("clutch up switch", engineConfiguration->clutchUpPin,
getInputMode(engineConfiguration->clutchUpPinMode));
}
if (isBrainPinValid(CONFIG(throttlePedalUpPin))) {
efiSetPadMode("throttle pedal up switch", CONFIG(throttlePedalUpPin),
getInputMode(CONFIG(throttlePedalUpPinMode)));
if (isBrainPinValid(engineConfiguration->throttlePedalUpPin)) {
efiSetPadMode("throttle pedal up switch", engineConfiguration->throttlePedalUpPin,
getInputMode(engineConfiguration->throttlePedalUpPinMode));
}
if (isBrainPinValid(engineConfiguration->brakePedalPin)) {

View File

@ -58,7 +58,7 @@ public:
// Allow querying state from outside
bool isIdlingOrTaper() {
return m_lastPhase == Phase::Idling || (CONFIG(useSeparateIdleTablesForCrankingTaper) && m_lastPhase == Phase::CrankToIdleTaper);
return m_lastPhase == Phase::Idling || (engineConfiguration->useSeparateIdleTablesForCrankingTaper && m_lastPhase == Phase::CrankToIdleTaper);
}
private:

View File

@ -26,7 +26,7 @@ static void startPwmTest(int freq) {
/**
* See custom_engine.cpp for pinout
*/
// currently this is PB9 by default - see CONFIG(injectionPins)
// currently this is PB9 by default - see engineConfiguration->injectionPins
startSimplePwm(&pwmTest[1], "tester", &enginePins.injectors[0], freq / 1.3333333333, 0.5f);
// currently this is PE2 by default
startSimplePwm(&pwmTest[2], "tester", &enginePins.injectors[1], freq / 1000, 0.5f);

View File

@ -27,7 +27,7 @@ void VvtController::init(int index, int bankIndex, int camIndex, const ValueProv
m_cam = camIndex;
// Use the same settings for the Nth cam in every bank (ie, all exhaust cams use the same PID)
m_pid.initPidClass(&CONFIG(auxPid[camIndex]));
m_pid.initPidClass(&engineConfiguration->auxPid[camIndex]);
m_targetMap = targetMap;
}

View File

@ -50,11 +50,11 @@ floatms_t TpsAccelEnrichment::getTpsEnrichment() {
// Fractional enrichment (fuel portions are accumulated and split between several engine cycles.
// This is a crude imitation of carburetor's acceleration pump.
isFractionalEnrichment = CONFIG(tpsAccelFractionPeriod) > 1 || CONFIG(tpsAccelFractionDivisor) > 1.0f;
isFractionalEnrichment = engineConfiguration->tpsAccelFractionPeriod > 1 || engineConfiguration->tpsAccelFractionDivisor > 1.0f;
if (isFractionalEnrichment) {
// make sure both values are non-zero
float periodF = (float)maxI(CONFIG(tpsAccelFractionPeriod), 1);
float divisor = maxF(CONFIG(tpsAccelFractionDivisor), 1.0f);
float periodF = (float)maxI(engineConfiguration->tpsAccelFractionPeriod, 1);
float divisor = maxF(engineConfiguration->tpsAccelFractionDivisor, 1.0f);
// if current extra fuel portion is not "strong" enough, then we keep up the "pump pressure" with the accumulated portion
floatms_t maxExtraFuel = maxF(extraFuel, accumulatedValue);
@ -116,7 +116,7 @@ void TpsAccelEnrichment::onEngineCycleTps() {
}
// reset the counter
cycleCnt = CONFIG(tpsAccelFractionPeriod);
cycleCnt = engineConfiguration->tpsAccelFractionPeriod;
}
}

View File

@ -36,7 +36,7 @@ int minCrankingRpm = 0;
* @return ignition timing angle advance before TDC
*/
static angle_t getRunningAdvance(int rpm, float engineLoad) {
if (CONFIG(timingMode) == TM_FIXED) {
if (engineConfiguration->timingMode == TM_FIXED) {
return engineConfiguration->fixedTiming;
}
@ -50,22 +50,22 @@ static angle_t getRunningAdvance(int rpm, float engineLoad) {
float advanceAngle = advanceMap.getValue((float) rpm, engineLoad);
// get advance from the separate table for Idle
if (CONFIG(useSeparateAdvanceForIdle) && isIdlingOrTaper()) {
if (engineConfiguration->useSeparateAdvanceForIdle && isIdlingOrTaper()) {
float idleAdvance = interpolate2d(rpm, config->idleAdvanceBins, config->idleAdvance);
auto [valid, tps] = Sensor::get(SensorType::DriverThrottleIntent);
if (valid) {
// interpolate between idle table and normal (running) table using TPS threshold
advanceAngle = interpolateClamped(0.0f, idleAdvance, CONFIG(idlePidDeactivationTpsThreshold), advanceAngle, tps);
advanceAngle = interpolateClamped(0.0f, idleAdvance, engineConfiguration->idlePidDeactivationTpsThreshold, advanceAngle, tps);
}
}
#if EFI_LAUNCH_CONTROL
if (engine->launchController.isLaunchCondition && CONFIG(enableLaunchRetard)) {
if (CONFIG(launchSmoothRetard)) {
float launchAngle = CONFIG(launchTimingRetard);
int launchAdvanceRpmRange = CONFIG(launchTimingRpmRange);
int launchRpm = CONFIG(launchRpm);
if (engine->launchController.isLaunchCondition && engineConfiguration->enableLaunchRetard) {
if (engineConfiguration->launchSmoothRetard) {
float launchAngle = engineConfiguration->launchTimingRetard;
int launchAdvanceRpmRange = engineConfiguration->launchTimingRpmRange;
int launchRpm = engineConfiguration->launchRpm;
// interpolate timing from rpm at launch triggered to full retard at launch launchRpm + launchTimingRpmRange
return interpolateClamped(launchRpm, advanceAngle, (launchRpm + launchAdvanceRpmRange), launchAngle, rpm);
} else {
@ -109,16 +109,16 @@ angle_t getAdvanceCorrections(int rpm) {
*/
static angle_t getCrankingAdvance(int rpm, float engineLoad) {
// get advance from the separate table for Cranking
if (CONFIG(useSeparateAdvanceForCranking)) {
return interpolate2d(rpm, CONFIG(crankingAdvanceBins), CONFIG(crankingAdvance));
if (engineConfiguration->useSeparateAdvanceForCranking) {
return interpolate2d(rpm, engineConfiguration->crankingAdvanceBins, engineConfiguration->crankingAdvance);
}
// Interpolate the cranking timing angle to the earlier running angle for faster engine start
angle_t crankingToRunningTransitionAngle = getRunningAdvance(CONFIG(cranking.rpm), engineLoad);
angle_t crankingToRunningTransitionAngle = getRunningAdvance(engineConfiguration->cranking.rpm, engineLoad);
// interpolate not from zero, but starting from min. possible rpm detected
if (rpm < minCrankingRpm || minCrankingRpm == 0)
minCrankingRpm = rpm;
return interpolateClamped(minCrankingRpm, CONFIG(crankingTimingAngle), CONFIG(cranking.rpm), crankingToRunningTransitionAngle, rpm);
return interpolateClamped(minCrankingRpm, engineConfiguration->crankingTimingAngle, engineConfiguration->cranking.rpm, crankingToRunningTransitionAngle, rpm);
}
@ -130,7 +130,7 @@ angle_t getAdvance(int rpm, float engineLoad) {
angle_t angle;
bool isCranking = ENGINE(rpmCalculator).isCranking();
bool isCranking = engine->rpmCalculator.isCranking();
if (isCranking) {
angle = getCrankingAdvance(rpm, engineLoad);
assertAngleRange(angle, "crAngle", CUSTOM_ERR_ANGLE_CR);
@ -146,8 +146,8 @@ angle_t getAdvance(int rpm, float engineLoad) {
// Allow correction only if set to dynamic
// AND we're either not cranking OR allowed to correct in cranking
bool allowCorrections = CONFIG(timingMode) == TM_DYNAMIC
&& (!isCranking || CONFIG(useAdvanceCorrectionsForCranking));
bool allowCorrections = engineConfiguration->timingMode == TM_DYNAMIC
&& (!isCranking || engineConfiguration->useAdvanceCorrectionsForCranking);
if (allowCorrections) {
angle_t correction = getAdvanceCorrections(rpm);
@ -166,26 +166,26 @@ angle_t getAdvance(int rpm, float engineLoad) {
size_t getMultiSparkCount(int rpm) {
// Compute multispark (if enabled)
if (CONFIG(multisparkEnable)
&& rpm <= CONFIG(multisparkMaxRpm)
&& CONFIG(multisparkMaxExtraSparkCount) > 0) {
if (engineConfiguration->multisparkEnable
&& rpm <= engineConfiguration->multisparkMaxRpm
&& engineConfiguration->multisparkMaxExtraSparkCount > 0) {
// For zero RPM, disable multispark. We don't yet know the engine speed, so multispark may not be safe.
if (rpm == 0) {
return 0;
}
floatus_t multiDelay = CONFIG(multisparkSparkDuration);
floatus_t multiDwell = CONFIG(multisparkDwell);
floatus_t multiDelay = engineConfiguration->multisparkSparkDuration;
floatus_t multiDwell = engineConfiguration->multisparkDwell;
// dwell times are below 10 seconds here so we use 32 bit type for performance reasons
ENGINE(engineState.multispark.delay) = (uint32_t)USF2NT(multiDelay);
ENGINE(engineState.multispark.dwell) = (uint32_t)USF2NT(multiDwell);
engine->engineState.multispark.delay = (uint32_t)USF2NT(multiDelay);
engine->engineState.multispark.dwell = (uint32_t)USF2NT(multiDwell);
constexpr float usPerDegreeAt1Rpm = 60e6 / 360;
floatus_t usPerDegree = usPerDegreeAt1Rpm / rpm;
// How long is there for sparks? The user configured an angle, convert to time.
floatus_t additionalSparksUs = usPerDegree * CONFIG(multisparkMaxSparkingAngle);
floatus_t additionalSparksUs = usPerDegree * engineConfiguration->multisparkMaxSparkingAngle;
// How long does one spark take?
floatus_t oneSparkTime = multiDelay + multiDwell;
@ -196,7 +196,7 @@ size_t getMultiSparkCount(int rpm) {
uint32_t floored = sparksFitInTime;
// Allow no more than the maximum number of extra sparks
return minI(floored, CONFIG(multisparkMaxExtraSparkCount));
return minI(floored, engineConfiguration->multisparkMaxExtraSparkCount);
} else {
return 0;
}

View File

@ -6,7 +6,7 @@
AirmassVeModelBase::AirmassVeModelBase(const ValueProvider3D& veTable) : m_veTable(&veTable) {}
float AirmassVeModelBase::getVeLoadAxis(float passedLoad) const {
switch(CONFIG(veOverrideMode)) {
switch(engineConfiguration->veOverrideMode) {
case VE_None: return passedLoad;
case VE_MAP: return Sensor::getOrZero(SensorType::Map);
case VE_TPS: return Sensor::getOrZero(SensorType::Tps1);
@ -24,13 +24,13 @@ float AirmassVeModelBase::getVe(int rpm, float load) const {
auto tps = Sensor::get(SensorType::Tps1);
// get VE from the separate table for Idle if idling
if (isIdlingOrTaper() && tps && CONFIG(useSeparateVeForIdle)) {
if (isIdlingOrTaper() && tps && engineConfiguration->useSeparateVeForIdle) {
float idleVe = interpolate2d(rpm, config->idleVeBins, config->idleVe);
// interpolate between idle table and normal (running) table using TPS threshold
ve = interpolateClamped(0.0f, idleVe, CONFIG(idlePidDeactivationTpsThreshold), ve, tps.Value);
ve = interpolateClamped(0.0f, idleVe, engineConfiguration->idlePidDeactivationTpsThreshold, ve, tps.Value);
}
ENGINE(engineState.currentVe) = ve;
ENGINE(engineState.currentVeLoad) = load;
engine->engineState.currentVe = ve;
engine->engineState.currentVeLoad = load;
return ve * 0.01f;
}

View File

@ -26,12 +26,12 @@ 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 rev
// This math is floating point to work properly on engines with odd cyl count
float halfCylCount = CONFIG(specs.cylindersCount) / 2.0f;
float halfCylCount = engineConfiguration->specs.cylindersCount / 2.0f;
float cylinderAirmass = airPerRevolution / halfCylCount;
//Create % load for fuel table using relative naturally aspiratedcylinder filling
float airChargeLoad = 100 * cylinderAirmass / ENGINE(standardAirCharge);
float airChargeLoad = 100 * cylinderAirmass / engine->standardAirCharge;
//Correct air mass by VE table
float correctedAirmass = cylinderAirmass * getVe(rpm, airChargeLoad);

View File

@ -7,7 +7,7 @@ AirmassResult SpeedDensityAirmass::getAirmass(int rpm) {
/**
* most of the values are pre-calculated for performance reasons
*/
float tChargeK = ENGINE(engineState.sd.tChargeK);
float tChargeK = engine->engineState.sd.tChargeK;
if (cisnan(tChargeK)) {
warning(CUSTOM_ERR_TCHARGE_NOT_READY2, "tChargeK not ready"); // this would happen before we have CLT reading for example
return {};
@ -39,15 +39,15 @@ float SpeedDensityAirmass::getMap(int rpm) const {
return map.Value;
} else {
float fallbackMap;
if (CONFIG(enableMapEstimationTableFallback)) {
if (engineConfiguration->enableMapEstimationTableFallback) {
// if the map estimation table is enabled, estimate map based on the TPS and RPM
fallbackMap = m_mapEstimationTable->getValue(rpm, Sensor::getOrZero(SensorType::Tps1));
} else {
fallbackMap = CONFIG(failedMapFallback);
fallbackMap = engineConfiguration->failedMapFallback;
}
#if EFI_TUNER_STUDIO
if (CONFIG(debugMode) == DBG_MAP) {
if (engineConfiguration->debugMode == DBG_MAP) {
tsOutputChannels.debugFloatField4 = fallbackMap;
}
#endif // EFI_TUNER_STUDIO

View File

@ -24,6 +24,6 @@ float idealGasLaw(float volume, float pressure, float temperature) {
}
/*static*/ float SpeedDensityBase::getAirmassImpl(float ve, float manifoldPressure, float temperature) {
float cycleAir = ve * idealGasLaw(CONFIG(specs.displacement), manifoldPressure, temperature);
return cycleAir / CONFIG(specs.cylindersCount);
float cycleAir = ve * idealGasLaw(engineConfiguration->specs.displacement, manifoldPressure, temperature);
return cycleAir / engineConfiguration->specs.cylindersCount;
}

View File

@ -18,7 +18,7 @@ void setDefaultBaseEngine() {
engineConfiguration->specs.displacement = 2;
engineConfiguration->specs.firingOrder = FO_1_3_4_2;
CONFIG(compressionRatio) = 9;
engineConfiguration->compressionRatio = 9;
engineConfiguration->fuelAlgorithm = LM_SPEED_DENSITY;
@ -60,9 +60,9 @@ void setDefaultBaseEngine() {
// Tachometer
// 50% duty cycle is the default for tach signal
CONFIG(tachPulseDurationAsDutyCycle) = true;
CONFIG(tachPulseDuractionMs) = 0.5;
CONFIG(tachPulsePerRev) = 1;
engineConfiguration->tachPulseDurationAsDutyCycle = true;
engineConfiguration->tachPulseDuractionMs = 0.5;
engineConfiguration->tachPulsePerRev = 1;
// Check engine light
#if EFI_PROD_CODE

View File

@ -7,12 +7,12 @@ void setDefaultCranking() {
engineConfiguration->cranking.rpm = 550;
// Fuel
CONFIG(crankingInjectionMode) = IM_SIMULTANEOUS;
engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS;
engineConfiguration->cranking.baseFuel = 27;
// Ignition
engineConfiguration->ignitionDwellForCrankingMs = 6;
CONFIG(crankingTimingAngle) = 6;
engineConfiguration->crankingTimingAngle = 6;
// IAC
engineConfiguration->crankingIACposition = 50;
@ -77,5 +77,5 @@ void setDefaultCranking() {
static const float advanceBins[] = { 0, 200, 400, 1000 };
copyArray(engineConfiguration->crankingAdvanceBins, advanceBins);
CONFIG(useTLE8888_cranking_hack) = true;
engineConfiguration->useTLE8888_cranking_hack = true;
}

View File

@ -107,13 +107,13 @@ static void setDefaultFuelCutParameters() {
}
static void setDefaultStftSettings() {
auto& cfg = CONFIG(stft);
auto& cfg = engineConfiguration->stft;
// Default to disabled
CONFIG(fuelClosedLoopCorrectionEnabled) = false;
engineConfiguration->fuelClosedLoopCorrectionEnabled = false;
// Default to proportional mode (for wideband sensors)
CONFIG(stftIgnoreErrorMagnitude) = false;
engineConfiguration->stftIgnoreErrorMagnitude = false;
// 60 second startup delay - some O2 sensors are slow to warm up.
cfg.startupDelay = 60;

View File

@ -51,7 +51,7 @@ static void setDefaultIatTimingCorrection() {
void setDefaultIgnition() {
// Ignition base settings
CONFIG(isIgnitionEnabled) = true;
engineConfiguration->isIgnitionEnabled = true;
engineConfiguration->timingMode = TM_DYNAMIC;
engineConfiguration->fixedModeTiming = 50;

View File

@ -45,7 +45,7 @@ void DynoView::update(vssSrc src) {
//updating here would display acceleration = 0 at constant speed
updateAcceleration(deltaTime, deltaSpeed);
#if EFI_TUNER_STUDIO
if (CONFIG(debugMode) == DBG_LOGIC_ANALYZER) {
if (engineConfiguration->debugMode == DBG_LOGIC_ANALYZER) {
tsOutputChannels.debugIntField1 = deltaTime;
tsOutputChannels.debugFloatField1 = vss;
tsOutputChannels.debugFloatField2 = speed;
@ -92,7 +92,7 @@ void DynoView::updateHP() {
//these are actually at the wheel
//we would need final drive to calcualte the correct torque at the wheel
if (acceleration != 0) {
engineForce = CONFIG(vehicleWeight) * acceleration;
engineForce = engineConfiguration->vehicleWeight * acceleration;
enginePower = engineForce * (vss / 3.6);
engineHP = enginePower / 746;
if (isValidRpm(GET_RPM())) {
@ -144,8 +144,8 @@ int getDynoviewPower() {
* Only updates if we have Vss from input pin.
*/
void updateDynoView() {
if (isBrainPinValid(CONFIG(vehicleSpeedSensorInputPin)) &&
(!CONFIG(enableCanVss))) {
if (isBrainPinValid(engineConfiguration->vehicleSpeedSensorInputPin) &&
(!engineConfiguration->enableCanVss)) {
dynoInstance.update(ICU);
}
}
@ -155,7 +155,7 @@ void updateDynoView() {
* as soon as we can to be more acurate.
*/
void updateDynoViewCan() {
if (!CONFIG(enableCanVss)) {
if (!engineConfiguration->enableCanVss) {
return;
}

View File

@ -104,22 +104,22 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode) {
static void initVvtShape(int camIndex, TriggerState &initState) {
vvt_mode_e vvtMode = engineConfiguration->vvtMode[camIndex];
TriggerWaveform *shape = &ENGINE(triggerCentral).vvtShape[camIndex];
TriggerWaveform *shape = &engine->triggerCentral.vvtShape[camIndex];
// not ideas but good for now code
ENGINE(triggerCentral).vvtState[0][0].name = "vvt00";
ENGINE(triggerCentral).vvtState[0][1].name = "vvt01";
ENGINE(triggerCentral).vvtState[1][0].name = "vvt10";
ENGINE(triggerCentral).vvtState[1][1].name = "vvt11";
engine->triggerCentral.vvtState[0][0].name = "vvt00";
engine->triggerCentral.vvtState[0][1].name = "vvt01";
engine->triggerCentral.vvtState[1][0].name = "vvt10";
engine->triggerCentral.vvtState[1][1].name = "vvt11";
if (vvtMode != VVT_INACTIVE) {
trigger_config_s config;
// todo: should 'vvtWithRealDecoder' be used here?
ENGINE(triggerCentral).vvtTriggerType[camIndex] = config.type = getVvtTriggerType(vvtMode);
engine->triggerCentral.vvtTriggerType[camIndex] = config.type = getVvtTriggerType(vvtMode);
shape->initializeTriggerWaveform(
engineConfiguration->ambiguousOperationMode,
CONFIG(vvtCamSensorUseRise), &config);
engineConfiguration->vvtCamSensorUseRise, &config);
shape->initializeSyncPoint(initState,
engine->vvtTriggerConfiguration[camIndex],
@ -149,16 +149,16 @@ void Engine::initializeTriggerWaveform() {
* this is only useful while troubleshooting a new trigger shape in the field
* in very VERY rare circumstances
*/
if (CONFIG(overrideTriggerGaps)) {
if (engineConfiguration->overrideTriggerGaps) {
int gapIndex = 0;
for (;gapIndex<=CONFIG(overrideTriggerGaps);gapIndex++) {
float gapOverrideFrom = CONFIG(triggerGapOverrideFrom[gapIndex]);
float gapOverrideTo = CONFIG(triggerGapOverrideTo[gapIndex]);
for (;gapIndex<=engineConfiguration->overrideTriggerGaps;gapIndex++) {
float gapOverrideFrom = engineConfiguration->triggerGapOverrideFrom[gapIndex];
float gapOverrideTo = engineConfiguration->triggerGapOverrideTo[gapIndex];
TRIGGER_WAVEFORM(setTriggerSynchronizationGap3(/*gapIndex*/gapIndex, gapOverrideFrom, gapOverrideTo));
}
for (;gapIndex<GAP_TRACKING_LENGTH;gapIndex++) {
ENGINE(triggerCentral.triggerShape).syncronizationRatioFrom[gapIndex] = NAN;
ENGINE(triggerCentral.triggerShape).syncronizationRatioTo[gapIndex] = NAN;
engine->triggerCentral.triggerShape.syncronizationRatioFrom[gapIndex] = NAN;
engine->triggerCentral.triggerShape.syncronizationRatioTo[gapIndex] = NAN;
}
}
@ -167,10 +167,10 @@ void Engine::initializeTriggerWaveform() {
* 'initState' instance of TriggerState is used only to initialize 'this' TriggerWaveform instance
* #192 BUG real hardware trigger events could be coming even while we are initializing trigger
*/
calculateTriggerSynchPoint(ENGINE(triggerCentral.triggerShape),
calculateTriggerSynchPoint(engine->triggerCentral.triggerShape,
initState);
ENGINE(triggerCentral.triggerState).name = "TRG";
engine->triggerCentral.triggerState.name = "TRG";
engine->engineCycleEventCount = TRIGGER_WAVEFORM(getLength());
}
@ -261,7 +261,7 @@ void Engine::periodicSlowCallback() {
#endif // EFI_PROD_CODE
#if ANALOG_HW_CHECK_MODE
efiAssertVoid(OBD_PCM_Processor_Fault, isAdcChannelValid(CONFIG(clt).adcChannel), "No CLT setting");
efiAssertVoid(OBD_PCM_Processor_Fault, isAdcChannelValid(engineConfiguration->clt.adcChannel), "No CLT setting");
efitimesec_t secondsNow = getTimeNowSeconds();
if (secondsNow > 2 && secondsNow < 180) {
assertCloseTo("RPM", Sensor::get(SensorType::Rpm).Value, HW_CHECK_RPM);
@ -294,8 +294,8 @@ void Engine::updateSlowSensors() {
#if EFI_ENGINE_CONTROL
int rpm = GET_RPM();
isEngineChartEnabled = CONFIG(isEngineChartEnabled) && rpm < CONFIG(engineSnifferRpmThreshold);
sensorChartMode = rpm < CONFIG(sensorSnifferRpmThreshold) ? CONFIG(sensorChartMode) : SC_OFF;
isEngineChartEnabled = engineConfiguration->isEngineChartEnabled && rpm < engineConfiguration->engineSnifferRpmThreshold;
sensorChartMode = rpm < engineConfiguration->sensorSnifferRpmThreshold ? engineConfiguration->sensorChartMode : SC_OFF;
engineState.updateSlowSensors();
@ -313,8 +313,8 @@ void Engine::updateSlowSensors() {
void Engine::updateSwitchInputs() {
#if EFI_GPIO_HARDWARE
// this value is not used yet
if (isBrainPinValid(CONFIG(clutchDownPin))) {
engine->clutchDownState = CONFIG(clutchDownPinInverted) ^ efiReadPin(CONFIG(clutchDownPin));
if (isBrainPinValid(engineConfiguration->clutchDownPin)) {
engine->clutchDownState = engineConfiguration->clutchDownPinInverted ^ efiReadPin(engineConfiguration->clutchDownPin);
}
if (hasAcToggle()) {
bool result = getAcToggle();
@ -324,11 +324,11 @@ void Engine::updateSwitchInputs() {
}
engine->acSwitchState = result;
}
if (isBrainPinValid(CONFIG(clutchUpPin))) {
engine->clutchUpState = CONFIG(clutchUpPinInverted) ^ efiReadPin(CONFIG(clutchUpPin));
if (isBrainPinValid(engineConfiguration->clutchUpPin)) {
engine->clutchUpState = engineConfiguration->clutchUpPinInverted ^ efiReadPin(engineConfiguration->clutchUpPin);
}
if (isBrainPinValid(CONFIG(throttlePedalUpPin))) {
engine->idle.throttlePedalUpState = efiReadPin(CONFIG(throttlePedalUpPin));
if (isBrainPinValid(engineConfiguration->throttlePedalUpPin)) {
engine->idle.throttlePedalUpState = efiReadPin(engineConfiguration->throttlePedalUpPin);
}
if (isBrainPinValid(engineConfiguration->brakePedalPin)) {
@ -396,7 +396,7 @@ void Engine::OnTriggerStateDecodingError() {
triggerCentral.triggerState.totalTriggerErrorCounter++;
if (CONFIG(verboseTriggerSynchDetails) || (triggerCentral.triggerState.someSortOfTriggerError && !CONFIG(silentTriggerError))) {
if (engineConfiguration->verboseTriggerSynchDetails || (triggerCentral.triggerState.someSortOfTriggerError && !engineConfiguration->silentTriggerError)) {
#if EFI_PROD_CODE
efiPrintf("error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d",
triggerCentral.triggerState.currentCycle.current_index,
@ -593,7 +593,7 @@ float Engine::getTimeIgnitionSeconds(void) const {
}
injection_mode_e Engine::getCurrentInjectionMode() {
return rpmCalculator.isCranking() ? CONFIG(crankingInjectionMode) : CONFIG(injectionMode);
return rpmCalculator.isCranking() ? engineConfiguration->crankingInjectionMode : engineConfiguration->injectionMode;
}
// see also in TunerStudio project '[doesTriggerImplyOperationMode] tag

View File

@ -102,7 +102,7 @@ void EngineState::periodicFastCallback() {
warning(CUSTOM_SLOW_NOT_INVOKED, "Slow not invoked yet");
}
efitick_t nowNt = getTimeNowNt();
if (ENGINE(rpmCalculator).isCranking()) {
if (engine->rpmCalculator.isCranking()) {
crankingTime = nowNt;
timeSinceCranking = 0.0f;
} else {
@ -110,7 +110,7 @@ void EngineState::periodicFastCallback() {
}
recalculateAuxValveTiming();
int rpm = ENGINE(rpmCalculator).getRpm();
int rpm = engine->rpmCalculator.getRpm();
sparkDwell = getSparkDwell(rpm);
dwellAngle = cisnan(rpm) ? NAN : sparkDwell / getOneDegreeTimeMs(rpm);
@ -150,12 +150,12 @@ void EngineState::periodicFastCallback() {
// compute per-bank fueling
for (size_t i = 0; i < STFT_BANK_COUNT; i++) {
float corr = clResult.banks[i];
ENGINE(injectionMass)[i] = injectionMass * corr;
ENGINE(stftCorrection)[i] = corr;
engine->injectionMass[i] = injectionMass * corr;
engine->stftCorrection[i] = corr;
}
// Store the pre-wall wetting injection duration for scheduling purposes only, not the actual injection duration
ENGINE(injectionDuration) = ENGINE(injectorModel)->getInjectionDuration(injectionMass);
engine->injectionDuration = engine->injectorModel->getInjectionDuration(injectionMass);
float fuelLoad = getFuelingLoad();
injectionOffset = getInjectionOffset(rpm, fuelLoad);
@ -164,7 +164,7 @@ void EngineState::periodicFastCallback() {
timingAdvance = getAdvance(rpm, ignitionLoad) * luaAdjustments.ignitionTimingMult + luaAdjustments.ignitionTimingAdd;
// TODO: calculate me from a table!
trailingSparkAngle = CONFIG(trailingSparkAngle);
trailingSparkAngle = engineConfiguration->trailingSparkAngle;
multispark.count = getMultiSparkCount(rpm);
@ -185,7 +185,7 @@ void EngineState::updateTChargeK(int rpm, float tps) {
float secsPassed = (float)NT2US(curTime - timeSinceLastTChargeK) / US_PER_SECOND_F;
if (!cisnan(newTCharge)) {
// control the rate of change or just fill with the initial value
sd.tCharge = (sd.tChargeK == 0) ? newTCharge : limitRateOfChange(newTCharge, sd.tCharge, CONFIG(tChargeAirIncrLimit), CONFIG(tChargeAirDecrLimit), secsPassed);
sd.tCharge = (sd.tChargeK == 0) ? newTCharge : limitRateOfChange(newTCharge, sd.tCharge, engineConfiguration->tChargeAirIncrLimit, engineConfiguration->tChargeAirDecrLimit, secsPassed);
sd.tChargeK = convertCelsiusToKelvin(sd.tCharge);
timeSinceLastTChargeK = curTime;
}
@ -256,19 +256,19 @@ void TriggerConfiguration::update() {
}
bool PrimaryTriggerConfiguration::isUseOnlyRisingEdgeForTrigger() const {
return CONFIG(useOnlyRisingEdgeForTrigger);
return engineConfiguration->useOnlyRisingEdgeForTrigger;
}
trigger_type_e PrimaryTriggerConfiguration::getType() const {
return CONFIG(trigger.type);
return engineConfiguration->trigger.type;
}
bool PrimaryTriggerConfiguration::isVerboseTriggerSynchDetails() const {
return CONFIG(verboseTriggerSynchDetails);
return engineConfiguration->verboseTriggerSynchDetails;
}
bool VvtTriggerConfiguration::isUseOnlyRisingEdgeForTrigger() const {
return CONFIG(vvtCamSensorUseRise);
return engineConfiguration->vvtCamSensorUseRise;
}
trigger_type_e VvtTriggerConfiguration::getType() const {
@ -276,5 +276,5 @@ trigger_type_e VvtTriggerConfiguration::getType() const {
}
bool VvtTriggerConfiguration::isVerboseTriggerSynchDetails() const {
return CONFIG(verboseVVTDecoding);
return engineConfiguration->verboseVVTDecoding;
}

View File

@ -369,8 +369,8 @@ void setTargetRpmCurve(int rpm) {
void setDefaultGppwmParameters() {
// Same config for all channels
for (size_t i = 0; i < efi::size(CONFIG(gppwm)); i++) {
auto& cfg = CONFIG(gppwm)[i];
for (size_t i = 0; i < efi::size(engineConfiguration->gppwm); i++) {
auto& cfg = engineConfiguration->gppwm[i];
cfg.pin = GPIO_UNASSIGNED;
cfg.dutyIfError = 0;
@ -414,22 +414,22 @@ static void setHip9011FrankensoPinout() {
/**
* SPI on PB13/14/15
*/
// CONFIG(hip9011CsPin) = GPIOD_0; // rev 0.1
// engineConfiguration->hip9011CsPin = GPIOD_0; // rev 0.1
CONFIG(isHip9011Enabled) = true;
engineConfiguration->isHip9011Enabled = true;
engineConfiguration->hip9011PrescalerAndSDO = HIP_8MHZ_PRESCALER; // 8MHz chip
CONFIG(is_enabled_spi_2) = true;
engineConfiguration->is_enabled_spi_2 = true;
// todo: convert this to rusEfi, hardware-independent enum
#if EFI_PROD_CODE
#ifdef EFI_HIP_CS_PIN
CONFIG(hip9011CsPin) = EFI_HIP_CS_PIN;
engineConfiguration->hip9011CsPin = EFI_HIP_CS_PIN;
#else
CONFIG(hip9011CsPin) = GPIOB_0; // rev 0.4
engineConfiguration->hip9011CsPin = GPIOB_0; // rev 0.4
#endif
CONFIG(hip9011CsPinMode) = OM_OPENDRAIN;
engineConfiguration->hip9011CsPinMode = OM_OPENDRAIN;
CONFIG(hip9011IntHoldPin) = GPIOB_11;
CONFIG(hip9011IntHoldPinMode) = OM_OPENDRAIN;
engineConfiguration->hip9011IntHoldPin = GPIOB_11;
engineConfiguration->hip9011IntHoldPinMode = OM_OPENDRAIN;
engineConfiguration->spi2SckMode = PO_OPENDRAIN; // 4
engineConfiguration->spi2MosiMode = PO_OPENDRAIN; // 4
@ -438,7 +438,7 @@ static void setHip9011FrankensoPinout() {
engineConfiguration->hip9011Gain = 1;
if (!CONFIG(useTpicAdvancedMode)) {
if (!engineConfiguration->useTpicAdvancedMode) {
engineConfiguration->hipOutputChannel = EFI_ADC_10; // PC0
}
}
@ -498,9 +498,9 @@ static void setDefaultEngineConfiguration() {
#endif
// OBD-II default rate is 500kbps
CONFIG(canBaudRate) = B500KBPS;
engineConfiguration->canBaudRate = B500KBPS;
CONFIG(mafSensorType) = Bosch0280218037;
engineConfiguration->mafSensorType = Bosch0280218037;
setBosch0280218037(config);
engineConfiguration->canSleepPeriodMs = 50;
@ -512,9 +512,9 @@ static void setDefaultEngineConfiguration() {
engineConfiguration->sdCardPeriodMs = 50;
CONFIG(mapMinBufferLength) = 1;
engineConfiguration->mapMinBufferLength = 1;
CONFIG(startCrankingDuration) = 3;
engineConfiguration->startCrankingDuration = 3;
engineConfiguration->idlePidRpmDeadZone = 50;
engineConfiguration->startOfCrankingPrimingPulse = 0;

View File

@ -9,10 +9,10 @@ mass_t FuelComputerBase::getCycleFuel(mass_t airmass, int rpm, float load) const
float lambda = getTargetLambda(rpm, load);
float afr = stoich * lambda;
ENGINE(engineState.currentAfrLoad) = load;
ENGINE(engineState.targetLambda) = lambda;
ENGINE(engineState.targetAFR) = afr;
ENGINE(engineState.stoichiometricRatio) = stoich;
engine->engineState.currentAfrLoad = load;
engine->engineState.targetLambda = lambda;
engine->engineState.targetAFR = afr;
engine->engineState.stoichiometricRatio = stoich;
return airmass / afr;
}
@ -20,7 +20,7 @@ mass_t FuelComputerBase::getCycleFuel(mass_t airmass, int rpm, float load) const
FuelComputer::FuelComputer(const ValueProvider3D& lambdaTable) : m_lambdaTable(&lambdaTable) {}
float FuelComputer::getStoichiometricRatio() const {
float primary = CONFIG(stoichRatioPrimary);
float primary = engineConfiguration->stoichRatioPrimary;
// Config compatibility: this field may be zero on ECUs with old defaults
if (primary < 5) {
@ -33,7 +33,7 @@ float FuelComputer::getStoichiometricRatio() const {
return primary;
}
float secondary = CONFIG(stoichRatioSecondary);
float secondary = engineConfiguration->stoichRatioSecondary;
// Config compatibility: this field may be zero on ECUs with old defaults
if (secondary < 5) {
@ -56,7 +56,7 @@ float FuelComputer::getTargetLambda(int rpm, float load) const {
}
float FuelComputer::getTargetLambdaLoadAxis(float defaultLoad) const {
return getLoadOverride(defaultLoad, CONFIG(afrOverrideMode));
return getLoadOverride(defaultLoad, engineConfiguration->afrOverrideMode);
}
float getLoadOverride(float defaultLoad, afr_override_e overrideMode) {
@ -67,7 +67,7 @@ float getLoadOverride(float defaultLoad, afr_override_e overrideMode) {
// TPS/pedal default to 100% - failed TPS goes rich
case AFR_Tps: return Sensor::get(SensorType::Tps1).value_or(100);
case AFR_AccPedal: return Sensor::get(SensorType::AcceleratorPedal).value_or(100);
case AFR_CylFilling: return 100 * ENGINE(engineState.sd.airMassInOneCylinder) / ENGINE(standardAirCharge);
case AFR_CylFilling: return 100 * engine->engineState.sd.airMassInOneCylinder / engine->standardAirCharge;
default: return 0;
}
}

View File

@ -16,10 +16,10 @@ constexpr float convertToGramsPerSecond(float ccPerMinute) {
}
expected<float> InjectorModel::getAbsoluteRailPressure() const {
switch (CONFIG(injectorCompensationMode)) {
switch (engineConfiguration->injectorCompensationMode) {
case ICM_FixedRailPressure:
// Add barometric pressure, as "fixed" really means "fixed pressure above atmosphere"
return CONFIG(fuelReferencePressure) + Sensor::get(SensorType::BarometricPressure).value_or(101.325f);
return engineConfiguration->fuelReferencePressure + Sensor::get(SensorType::BarometricPressure).value_or(101.325f);
case ICM_SensedRailPressure:
if (!Sensor::hasSensor(SensorType::FuelPressureInjector)) {
firmwareError(OBD_PCM_Processor_Fault, "Fuel pressure compensation is set to use a pressure sensor, but none is configured.");
@ -34,11 +34,11 @@ expected<float> InjectorModel::getAbsoluteRailPressure() const {
float InjectorModel::getInjectorFlowRatio() const {
// Compensation disabled, use reference flow.
if (CONFIG(injectorCompensationMode) == ICM_None) {
if (engineConfiguration->injectorCompensationMode == ICM_None) {
return 1.0f;
}
float referencePressure = CONFIG(fuelReferencePressure);
float referencePressure = engineConfiguration->fuelReferencePressure;
expected<float> absRailPressure = getAbsoluteRailPressure();
// If sensor failed, best we can do is disable correction
@ -64,7 +64,7 @@ float InjectorModel::getInjectorFlowRatio() const {
float flowRatio = sqrtf(pressureRatio);
#if EFI_TUNER_STUDIO
if (CONFIG(debugMode) == DBG_INJECTOR_COMPENSATION) {
if (engineConfiguration->debugMode == DBG_INJECTOR_COMPENSATION) {
tsOutputChannels.debugFloatField1 = pressureDelta;
tsOutputChannels.debugFloatField2 = pressureRatio;
tsOutputChannels.debugFloatField3 = flowRatio;
@ -77,7 +77,7 @@ float InjectorModel::getInjectorFlowRatio() const {
float InjectorModel::getInjectorMassFlowRate() const {
// TODO: injector flow dependent upon temperature/ethanol content?
auto injectorVolumeFlow = CONFIG(injector.flow);
auto injectorVolumeFlow = engineConfiguration->injector.flow;
float flowRatio = getInjectorFlowRatio();
@ -118,7 +118,7 @@ float InjectorModelBase::getFuelMassForDuration(floatms_t duration) const {
}
float InjectorModel::correctShortPulse(float baseDuration) const {
switch (CONFIG(injectorNonlinearMode)) {
switch (engineConfiguration->injectorNonlinearMode) {
case INJ_PolynomialAdder:
return correctInjectionPolynomial(baseDuration);
case INJ_None:
@ -128,12 +128,12 @@ float InjectorModel::correctShortPulse(float baseDuration) const {
}
float InjectorModel::correctInjectionPolynomial(float baseDuration) const {
if (baseDuration > USF2MS(CONFIG(applyNonlinearBelowPulse))) {
if (baseDuration > USF2MS(engineConfiguration->applyNonlinearBelowPulse)) {
// Large pulse, skip correction.
return baseDuration;
}
auto& is = CONFIG(injectorCorrectionPolynomial);
auto& is = engineConfiguration->injectorCorrectionPolynomial;
float xi = 1;
float adder = 0;

View File

@ -95,15 +95,15 @@ float getCrankingFuel3(
float getRunningFuel(float baseFuel) {
ScopePerf perf(PE::GetRunningFuel);
ENGINE(engineState.running.baseFuel) = baseFuel;
engine->engineState.running.baseFuel = baseFuel;
float iatCorrection = ENGINE(engineState.running.intakeTemperatureCoefficient);
float iatCorrection = engine->engineState.running.intakeTemperatureCoefficient;
float cltCorrection = ENGINE(engineState.running.coolantTemperatureCoefficient);
float cltCorrection = engine->engineState.running.coolantTemperatureCoefficient;
float postCrankingFuelCorrection = ENGINE(engineState.running.postCrankingFuelCorrection);
float postCrankingFuelCorrection = engine->engineState.running.postCrankingFuelCorrection;
float baroCorrection = ENGINE(engineState.baroCorrection);
float baroCorrection = engine->engineState.baroCorrection;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(iatCorrection), "NaN iatCorrection", 0);
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(cltCorrection), "NaN cltCorrection", 0);
@ -112,7 +112,7 @@ float getRunningFuel(float baseFuel) {
float runningFuel = baseFuel * baroCorrection * iatCorrection * cltCorrection * postCrankingFuelCorrection;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(runningFuel), "NaN runningFuel", 0);
ENGINE(engineState.running.fuel) = runningFuel * 1000;
engine->engineState.running.fuel = runningFuel * 1000;
return runningFuel;
}
@ -136,7 +136,7 @@ AirmassModelBase* getAirmassModel(engine_load_mode_e mode) {
#endif
default:
// this is a bad work-around for https://github.com/rusefi/rusefi/issues/1690 issue
warning(CUSTOM_ERR_ASSERT, "Invalid airmass mode %d", CONFIG(fuelAlgorithm));
warning(CUSTOM_ERR_ASSERT, "Invalid airmass mode %d", engineConfiguration->fuelAlgorithm);
return &sdAirmass;
/* todo: this should be the implementation
return nullptr;
@ -149,20 +149,20 @@ static float getBaseFuelMass(int rpm) {
ScopePerf perf(PE::GetBaseFuel);
// airmass modes - get airmass first, then convert to fuel
auto model = getAirmassModel(CONFIG(fuelAlgorithm));
auto model = getAirmassModel(engineConfiguration->fuelAlgorithm);
efiAssert(CUSTOM_ERR_ASSERT, model != nullptr, "Invalid airmass mode", 0.0f);
auto airmass = model->getAirmass(rpm);
// Plop some state for others to read
ENGINE(engineState.sd.airMassInOneCylinder) = airmass.CylinderAirmass;
ENGINE(engineState.fuelingLoad) = airmass.EngineLoadPercent;
ENGINE(engineState.ignitionLoad) = getLoadOverride(airmass.EngineLoadPercent, CONFIG(ignOverrideMode));
engine->engineState.sd.airMassInOneCylinder = airmass.CylinderAirmass;
engine->engineState.fuelingLoad = airmass.EngineLoadPercent;
engine->engineState.ignitionLoad = getLoadOverride(airmass.EngineLoadPercent, engineConfiguration->ignOverrideMode);
float baseFuelMass = ENGINE(fuelComputer)->getCycleFuel(airmass.CylinderAirmass, rpm, airmass.EngineLoadPercent);
float baseFuelMass = engine->fuelComputer->getCycleFuel(airmass.CylinderAirmass, rpm, airmass.EngineLoadPercent);
// Fudge it by the global correction factor
baseFuelMass *= CONFIG(globalFuelCorrection);
baseFuelMass *= engineConfiguration->globalFuelCorrection;
engine->engineState.baseFuel = baseFuelMass;
if (cisnan(baseFuelMass)) {
@ -190,7 +190,7 @@ angle_t getInjectionOffset(float rpm, float load) {
return 0;
}
angle_t result = value + CONFIG(extraInjectionOffset);
angle_t result = value + engineConfiguration->extraInjectionOffset;
fixAngle(result, "inj offset#2", CUSTOM_ERR_6553);
return result;
}
@ -244,7 +244,7 @@ float getInjectionModeDurationMultiplier() {
* @see getCoilDutyCycle
*/
percent_t getInjectorDutyCycle(int rpm) {
floatms_t totalInjectiorAmountPerCycle = ENGINE(injectionDuration) * getNumberOfInjections(engineConfiguration->injectionMode);
floatms_t totalInjectiorAmountPerCycle = engine->injectionDuration * getNumberOfInjections(engineConfiguration->injectionMode);
floatms_t engineCycleDuration = getEngineCycleDuration(rpm);
return 100 * totalInjectiorAmountPerCycle / engineCycleDuration;
}
@ -268,27 +268,27 @@ float getInjectionMass(int rpm) {
// Always update base fuel - some cranking modes use it
float baseFuelMass = getBaseFuelMass(rpm);
bool isCranking = ENGINE(rpmCalculator).isCranking();
bool isCranking = engine->rpmCalculator.isCranking();
float cycleFuelMass = getCycleFuelMass(isCranking, baseFuelMass);
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(cycleFuelMass), "NaN cycleFuelMass", 0);
// Fuel cut-off isn't just 0 or 1, it can be tapered
cycleFuelMass *= ENGINE(engineState.fuelCutoffCorrection);
cycleFuelMass *= engine->engineState.fuelCutoffCorrection;
float durationMultiplier = getInjectionModeDurationMultiplier();
float injectionFuelMass = cycleFuelMass * durationMultiplier;
// Prepare injector flow rate & deadtime
ENGINE(injectorModel)->prepare();
engine->injectorModel->prepare();
floatms_t tpsAccelEnrich = ENGINE(tpsAccelEnrichment.getTpsEnrichment());
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(tpsAccelEnrich), "NaN tpsAccelEnrich", 0);
ENGINE(engineState.tpsAccelEnrich) = tpsAccelEnrich;
engine->engineState.tpsAccelEnrich = tpsAccelEnrich;
// For legacy reasons, the TPS accel table is in units of milliseconds, so we have to convert BACK to mass
float tpsAccelPerInjection = durationMultiplier * tpsAccelEnrich;
float tpsFuelMass = ENGINE(injectorModel)->getFuelMassForDuration(tpsAccelPerInjection);
float tpsFuelMass = engine->injectorModel->getFuelMassForDuration(tpsAccelPerInjection);
return injectionFuelMass + tpsFuelMass;
#else
@ -307,8 +307,8 @@ static InjectorModel injectorModel;
void initFuelMap() {
ENGINE(fuelComputer) = &fuelComputer;
ENGINE(injectorModel) = &injectorModel;
engine->fuelComputer = &fuelComputer;
engine->injectorModel = &injectorModel;
mapEstimationTable.init(config->mapEstimateTable, config->mapEstimateTpsBins, config->mapEstimateRpmBins);
@ -357,7 +357,7 @@ float getFuelCutOffCorrection(efitick_t nowNt, int rpm) {
float fuelCorr = 1.0f;
// coasting fuel cut-off correction
if (CONFIG(coastingFuelCutEnabled)) {
if (engineConfiguration->coastingFuelCutEnabled) {
auto [tpsValid, tpsPos] = Sensor::get(SensorType::Tps1);
if (!tpsValid) {
return 1.0f;
@ -374,21 +374,21 @@ float getFuelCutOffCorrection(efitick_t nowNt, int rpm) {
}
// gather events
bool mapDeactivate = (map >= CONFIG(coastingFuelCutMap));
bool tpsDeactivate = (tpsPos >= CONFIG(coastingFuelCutTps));
bool mapDeactivate = (map >= engineConfiguration->coastingFuelCutMap);
bool tpsDeactivate = (tpsPos >= engineConfiguration->coastingFuelCutTps);
// If no CLT sensor (or broken), don't allow DFCO
bool cltDeactivate = clt < (float)CONFIG(coastingFuelCutClt);
bool rpmDeactivate = (rpm < CONFIG(coastingFuelCutRpmLow));
bool rpmActivate = (rpm > CONFIG(coastingFuelCutRpmHigh));
bool cltDeactivate = clt < (float)engineConfiguration->coastingFuelCutClt;
bool rpmDeactivate = (rpm < engineConfiguration->coastingFuelCutRpmLow);
bool rpmActivate = (rpm > engineConfiguration->coastingFuelCutRpmHigh);
// state machine (coastingFuelCutStartTime is also used as a flag)
if (!mapDeactivate && !tpsDeactivate && !cltDeactivate && rpmActivate) {
ENGINE(engineState.coastingFuelCutStartTime) = nowNt;
engine->engineState.coastingFuelCutStartTime = nowNt;
} else if (mapDeactivate || tpsDeactivate || rpmDeactivate || cltDeactivate) {
ENGINE(engineState.coastingFuelCutStartTime) = 0;
engine->engineState.coastingFuelCutStartTime = 0;
}
// enable fuelcut?
if (ENGINE(engineState.coastingFuelCutStartTime) != 0) {
if (engine->engineState.coastingFuelCutStartTime != 0) {
// todo: add taper - interpolate using (nowNt - coastingFuelCutStartTime)?
fuelCorr = 0.0f;
}
@ -424,8 +424,8 @@ float getCrankingFuel(float baseFuel) {
}
float getStandardAirCharge() {
float totalDisplacement = CONFIG(specs.displacement);
float cylDisplacement = totalDisplacement / CONFIG(specs.cylindersCount);
float totalDisplacement = engineConfiguration->specs.displacement;
float cylDisplacement = totalDisplacement / engineConfiguration->specs.cylindersCount;
// Calculation of 100% VE air mass in g/cyl - 1 cylinder filling at 1.204/L
// 101.325kpa, 20C

View File

@ -20,18 +20,18 @@
* In case we are dependent on VSS we just return true.
*/
bool LaunchControlBase::isInsideSwitchCondition() {
switch (CONFIG(launchActivationMode)) {
switch (engineConfiguration->launchActivationMode) {
case SWITCH_INPUT_LAUNCH:
#if !EFI_SIMULATOR
if (isBrainPinValid(CONFIG(launchActivatePin))) {
if (isBrainPinValid(engineConfiguration->launchActivatePin)) {
//todo: we should take into consideration if this sw is pulled high or low!
launchActivatePinState = efiReadPin(CONFIG(launchActivatePin));
launchActivatePinState = efiReadPin(engineConfiguration->launchActivatePin);
}
#endif // EFI_PROD_CODE
return launchActivatePinState;
case CLUTCH_INPUT_LAUNCH:
if (isBrainPinValid(CONFIG(clutchDownPin))) {
if (isBrainPinValid(engineConfiguration->clutchDownPin)) {
return engine->clutchDownState;
} else {
return false;
@ -52,7 +52,7 @@ bool LaunchControlBase::isInsideSwitchCondition() {
bool LaunchControlBase::isInsideSpeedCondition() const {
int speed = Sensor::getOrZero(SensorType::VehicleSpeed);
return (CONFIG(launchSpeedThreshold) > speed) || (!(CONFIG(launchActivationMode) == ALWAYS_ACTIVE_LAUNCH));
return (engineConfiguration->launchSpeedThreshold > speed) || (!(engineConfiguration->launchActivationMode == ALWAYS_ACTIVE_LAUNCH));
}
/**
@ -66,14 +66,14 @@ bool LaunchControlBase::isInsideTpsCondition() const {
return false;
}
return CONFIG(launchTpsTreshold) < tps.Value;
return engineConfiguration->launchTpsTreshold < tps.Value;
}
/**
* Condition is true as soon as we are above LaunchRpm
*/
bool LaunchControlBase::isInsideRPMCondition(int rpm) const {
int launchRpm = CONFIG(launchRpm);
int launchRpm = engineConfiguration->launchRpm;
return (launchRpm < rpm);
}
@ -97,7 +97,7 @@ bool LaunchControlBase::isLaunchConditionMet(int rpm) {
}
void LaunchControlBase::update() {
if (!CONFIG(launchControlEnabled)) {
if (!engineConfiguration->launchControlEnabled) {
return;
}
@ -105,8 +105,8 @@ void LaunchControlBase::update() {
bool combinedConditions = isLaunchConditionMet(rpm);
//and still recalculat in case user changed the values
retardThresholdRpm = CONFIG(launchRpm) + (CONFIG(enableLaunchRetard) ?
CONFIG(launchAdvanceRpmRange) : 0) + CONFIG(hardCutRpmRange);
retardThresholdRpm = engineConfiguration->launchRpm + (engineConfiguration->enableLaunchRetard ?
engineConfiguration->launchAdvanceRpmRange : 0) + engineConfiguration->hardCutRpmRange;
if (!combinedConditions) {
// conditions not met, reset timer
@ -114,11 +114,11 @@ void LaunchControlBase::update() {
isLaunchCondition = false;
} else {
// If conditions are met...
isLaunchCondition = m_launchTimer.hasElapsedSec(CONFIG(launchActivateDelay));
isLaunchCondition = m_launchTimer.hasElapsedSec(engineConfiguration->launchActivateDelay);
}
#if EFI_TUNER_STUDIO
if (CONFIG(debugMode) == DBG_LAUNCH) {
if (engineConfiguration->debugMode == DBG_LAUNCH) {
tsOutputChannels.debugIntField5 = engine->clutchDownState;
tsOutputChannels.debugFloatField1 = launchActivatePinState;
tsOutputChannels.debugFloatField2 = isLaunchCondition;

View File

@ -17,7 +17,7 @@ floatms_t WallFuel::adjust(floatms_t desiredFuel) {
return desiredFuel;
}
// disable this correction for cranking
if (ENGINE(rpmCalculator).isCranking()) {
if (engine->rpmCalculator.isCranking()) {
return desiredFuel;
}
@ -59,7 +59,7 @@ floatms_t WallFuel::adjust(floatms_t desiredFuel) {
// if tau is really small, we get div/0.
// you probably meant to disable wwae.
float tau = CONFIG(wwaeTau);
float tau = engineConfiguration->wwaeTau;
if (tau < 0.01f) {
return desiredFuel;
}
@ -71,7 +71,7 @@ floatms_t WallFuel::adjust(floatms_t desiredFuel) {
}
float alpha = expf_taylor(-120 / (rpm * tau));
float beta = CONFIG(wwaeBeta);
float beta = engineConfiguration->wwaeBeta;
#if EFI_TUNER_STUDIO
if (engineConfiguration->debugMode == DBG_KNOCK) {

View File

@ -131,7 +131,7 @@ static void doRunFuel(size_t humanIndex, const char *delayStr, const char * onTi
efiPrintf("Invalid index: %d", humanIndex);
return;
}
brain_pin_e b = CONFIG(injectionPins)[humanIndex - 1];
brain_pin_e b = engineConfiguration->injectionPins[humanIndex - 1];
pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.injectors[humanIndex - 1], b);
}
@ -141,7 +141,7 @@ static void doTestSolenoid(int humanIndex, const char *delayStr, const char * on
efiPrintf("Invalid index: %d", humanIndex);
return;
}
brain_pin_e b = CONFIG(tcu_solenoid)[humanIndex - 1];
brain_pin_e b = engineConfiguration->tcu_solenoid[humanIndex - 1];
pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.tcuSolenoids[humanIndex - 1], b);
}
@ -152,7 +152,7 @@ static void doBenchTestFsio(int humanIndex, const char *delayStr, const char * o
// return;
// }
// todo: convert in lua bench test
// brain_pin_e b = CONFIG(fsioOutputPins)[humanIndex - 1];
// brain_pin_e b = engineConfiguration->fsioOutputPins[humanIndex - 1];
// pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.fsioOutputs[humanIndex - 1], b);
}
@ -187,7 +187,7 @@ static void fsioBench2(const char *delayStr, const char *indexStr, const char *
}
static void fanBenchExt(const char *durationMs) {
pinbench("0", durationMs, "100", "1", &enginePins.fanRelay, CONFIG(fanPin));
pinbench("0", durationMs, "100", "1", &enginePins.fanRelay, engineConfiguration->fanPin);
}
void fanBench(void) {
@ -195,26 +195,26 @@ void fanBench(void) {
}
void fan2Bench(void) {
pinbench("0", "3000", "100", "1", &enginePins.fanRelay2, CONFIG(fan2Pin));
pinbench("0", "3000", "100", "1", &enginePins.fanRelay2, engineConfiguration->fan2Pin);
}
/**
* we are blinking for 16 seconds so that one can click the button and walk around to see the light blinking
*/
void milBench(void) {
pinbench("0", "500", "500", "16", &enginePins.checkEnginePin, CONFIG(malfunctionIndicatorPin));
pinbench("0", "500", "500", "16", &enginePins.checkEnginePin, engineConfiguration->malfunctionIndicatorPin);
}
void starterRelayBench(void) {
pinbench("0", "6000", "100", "1", &enginePins.starterControl, CONFIG(starterControlPin));
pinbench("0", "6000", "100", "1", &enginePins.starterControl, engineConfiguration->starterControlPin);
}
void fuelPumpBenchExt(const char *durationMs) {
pinbench("0", durationMs, "100", "1", &enginePins.fuelPumpRelay, CONFIG(fuelPumpPin));
pinbench("0", durationMs, "100", "1", &enginePins.fuelPumpRelay, engineConfiguration->fuelPumpPin);
}
void acRelayBench(void) {
pinbench("0", "1000", "100", "1", &enginePins.acRelay, CONFIG(acRelayPin));
pinbench("0", "1000", "100", "1", &enginePins.acRelay, engineConfiguration->acRelayPin);
}
void mainRelayBench(void) {
@ -223,7 +223,7 @@ void mainRelayBench(void) {
}
void hpfpValveBench(void) {
pinbench(/*delay*/"1000", /* onTime */"20", /*oftime*/"500", "3", &enginePins.hpfpValve, CONFIG(hpfpValvePin));
pinbench(/*delay*/"1000", /* onTime */"20", /*oftime*/"500", "3", &enginePins.hpfpValve, engineConfiguration->hpfpValvePin);
}
void fuelPumpBench(void) {
@ -241,7 +241,7 @@ static void doRunSpark(size_t humanIndex, const char *delayStr, const char * onT
efiPrintf("Invalid index: %d", humanIndex);
return;
}
brain_pin_e b = CONFIG(ignitionPins)[humanIndex - 1];
brain_pin_e b = engineConfiguration->ignitionPins[humanIndex - 1];
pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.coils[humanIndex - 1], b);
}
@ -424,7 +424,7 @@ static void fatalErrorForPresetApply() {
void executeTSCommand(uint16_t subsystem, uint16_t index) {
efiPrintf("IO test subsystem=%d index=%d", subsystem, index);
bool running = !ENGINE(rpmCalculator).isStopped();
bool running = !engine->rpmCalculator.isStopped();
switch (subsystem) {
case TS_CLEAR_WARNINGS:

View File

@ -22,8 +22,8 @@ ButtonShiftController::ButtonShiftController() :
void ButtonShiftController::init() {
// 500 millisecond is maybe a little long?
debounceUp.init(500, CONFIG(tcuUpshiftButtonPin), CONFIG(tcuUpshiftButtonPinMode));
debounceDown.init(500, CONFIG(tcuDownshiftButtonPin), CONFIG(tcuDownshiftButtonPinMode));
debounceUp.init(500, engineConfiguration->tcuUpshiftButtonPin, engineConfiguration->tcuUpshiftButtonPinMode);
debounceDown.init(500, engineConfiguration->tcuDownshiftButtonPin, engineConfiguration->tcuDownshiftButtonPinMode);
GearControllerBase::init();
}

View File

@ -112,7 +112,7 @@ void canDashboardGenesisCoupe(CanCycle cycle);
void updateDash(CanCycle cycle) {
// Transmit dash data, if enabled
switch (CONFIG(canNbcType)) {
switch (engineConfiguration->canNbcType) {
case CAN_BUS_NBC_BMW:
canDashboardBMW(cycle);
break;

View File

@ -15,7 +15,7 @@
typedef float SCRIPT_TABLE_8x8_f32t_linear[SCRIPT_TABLE_8 * SCRIPT_TABLE_8];
bool acceptCanRx(int sid) {
if (!CONFIG(usescriptTableForCanSniffingFiltering)) {
if (!engineConfiguration->usescriptTableForCanSniffingFiltering) {
// accept anything if filtering is not enabled
return true;
}
@ -123,7 +123,7 @@ static void processCanRxImu(const CANRxFrame& frame, efitick_t nowNt) {
efiPrintf("CAN_rx 130 %f %f", a, b);
}
if (CONFIG(imuType) == IMU_VAG) {
if (engineConfiguration->imuType == IMU_VAG) {
if (CAN_SID(frame) == VAG_YAW_RATE_G_LAT) {
efiPrintf("CAN_rx VAG_YAW_RATE_G_LAT");
} else if (CAN_SID(frame) == VAG_YAW_ACCEL_G_LONG) {
@ -134,7 +134,7 @@ static void processCanRxImu(const CANRxFrame& frame, efitick_t nowNt) {
if (CONFIG(imuType) == IMU_MM5_10) {
if (engineConfiguration->imuType == IMU_MM5_10) {
#define MM5_10_RATE_QUANT 0.005
#define MM5_10_ACC_QUANT 0.0001274
@ -161,7 +161,7 @@ static void processCanRxImu(const CANRxFrame& frame, efitick_t nowNt) {
}
void processCanRxMessage(const CANRxFrame &frame, efitick_t nowNt) {
if (CONFIG(debugMode) == DBG_CAN) {
if (engineConfiguration->debugMode == DBG_CAN) {
printPacket(frame);
}
@ -177,7 +177,7 @@ void processCanRxMessage(const CANRxFrame &frame, efitick_t nowNt) {
processLuaCan(frame);
#if EFI_CANBUS_SLAVE
if (CAN_EID(frame) == CONFIG(verboseCanBaseAddress) + CAN_SENSOR_1_OFFSET) {
if (CAN_EID(frame) == engineConfiguration->verboseCanBaseAddress + CAN_SENSOR_1_OFFSET) {
int16_t mapScaled = *reinterpret_cast<const int16_t*>(&frame.data8[0]);
canMap = mapScaled / (1.0 * PACK_MULT_PRESSURE);
} else

View File

@ -31,10 +31,10 @@ void CanWrite::PeriodicTask(efitime_t nowNt) {
CanCycle cycle(cycleCount);
//in case we have Verbose Can enabled, we should keep user configured period
if (CONFIG(enableVerboseCanTx)) {
if (engineConfiguration->enableVerboseCanTx) {
uint16_t cycleCountsPeriodMs = cycleCount * CAN_CYCLE_PERIOD;
if (0 != CONFIG(canSleepPeriodMs)) {
if (cycleCountsPeriodMs % CONFIG(canSleepPeriodMs)) {
if (0 != engineConfiguration->canSleepPeriodMs) {
if (cycleCountsPeriodMs % engineConfiguration->canSleepPeriodMs) {
void sendCanVerbose();
sendCanVerbose();
}
@ -54,7 +54,7 @@ void CanWrite::PeriodicTask(efitime_t nowNt) {
updateDash(cycle);
if (CONFIG(enableAemXSeries) && cycle.isInterval(CI::_50ms)) {
if (engineConfiguration->enableAemXSeries && cycle.isInterval(CI::_50ms)) {
sendWidebandInfo();
}

View File

@ -36,7 +36,7 @@ static void populateFrame(Status& msg) {
msg.warningCounter = engine->engineState.warnings.warningCounter;
msg.lastErrorCode = engine->engineState.warnings.lastErrorCode;
msg.revLimit = GET_RPM() > CONFIG(rpmHardLimit);
msg.revLimit = GET_RPM() > engineConfiguration->rpmHardLimit;
msg.mainRelay = enginePins.mainRelay.getLogicValue();
msg.fuelPump = enginePins.fuelPumpRelay.getLogicValue();
msg.checkEngine = enginePins.checkEnginePin.getLogicValue();
@ -140,12 +140,12 @@ static void populateFrame(Fueling2& msg) {
msg.fuelFlowRate = engine->engineState.fuelConsumption.getConsumptionGramPerSecond();
for (size_t i = 0; i < 2; i++) {
msg.fuelTrim[i] = 100.0f * (ENGINE(stftCorrection)[i] - 1.0f);
msg.fuelTrim[i] = 100.0f * (engine->stftCorrection[i] - 1.0f);
}
}
void sendCanVerbose() {
auto base = CONFIG(verboseCanBaseAddress);
auto base = engineConfiguration->verboseCanBaseAddress;
transmitStruct<Status> (base + 0);
transmitStruct<Speeds> (base + 1);

View File

@ -48,20 +48,20 @@ float processW202(const CANRxFrame& frame) {
/* End of specific processing functions */
void canVssInfo(void) {
efiPrintf("vss using can option selected %x", CONFIG(canVssNbcType));
efiPrintf("vss using can option selected %x", engineConfiguration->canVssNbcType);
efiPrintf("vss filter for %x canID", filterCanID);
efiPrintf("Vss module is %d", isInit);
efiPrintf("CONFIG_enableCanVss is %d", CONFIG(enableCanVss));
efiPrintf("CONFIG_enableCanVss is %d", engineConfiguration->enableCanVss);
}
expected<float> processCanRxVssImpl(const CANRxFrame& frame) {
switch (CONFIG(canVssNbcType)){
switch (engineConfiguration->canVssNbcType){
case BMW_e46:
return processBMW_e46(frame);
case W202:
return processW202(frame);
default:
efiPrintf("vss unsupported can option selected %x", CONFIG(canVssNbcType) );
efiPrintf("vss unsupported can option selected %x", engineConfiguration->canVssNbcType );
}
return unexpected;
@ -70,7 +70,7 @@ expected<float> processCanRxVssImpl(const CANRxFrame& frame) {
static StoredValueSensor canSpeed(SensorType::VehicleSpeed, MS2NT(500));
void processCanRxVss(const CANRxFrame& frame, efitick_t nowNt) {
if ((!CONFIG(enableCanVss)) || (!isInit)) {
if ((!engineConfiguration->enableCanVss) || (!isInit)) {
return;
}
@ -91,8 +91,8 @@ void processCanRxVss(const CANRxFrame& frame, efitick_t nowNt) {
void initCanVssSupport() {
addConsoleAction("canvssinfo", canVssInfo);
if (CONFIG(enableCanVss)) {
if (auto canId = look_up_can_id(CONFIG(canVssNbcType))) {
if (engineConfiguration->enableCanVss) {
if (auto canId = look_up_can_id(engineConfiguration->canVssNbcType)) {
filterCanID = canId.Value;
canSpeed.Register();
isInit = true;

View File

@ -123,10 +123,10 @@ static void handleGetDataRequest(const CANRxFrame& rx) {
obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Clt) + ODB_TEMP_EXTRA);
break;
case PID_STFT_BANK1:
obdSendValue(_1_MODE, pid, 1, 128 * ENGINE(stftCorrection)[0]);
obdSendValue(_1_MODE, pid, 1, 128 * engine->stftCorrection[0]);
break;
case PID_STFT_BANK2:
obdSendValue(_1_MODE, pid, 1, 128 * ENGINE(stftCorrection)[1]);
obdSendValue(_1_MODE, pid, 1, 128 * engine->stftCorrection[1]);
break;
case PID_INTAKE_MAP:
obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Map));

View File

@ -118,7 +118,7 @@ bool warning(obd_code_e code, const char *fmt, ...) {
chvsnprintf(warningBuffer, sizeof(warningBuffer), fmt, ap);
va_end(ap);
if (CONFIG(showHumanReadableWarning)) {
if (engineConfiguration->showHumanReadableWarning) {
#if EFI_TUNER_STUDIO
#if defined(EFI_NO_CONFIG_WORKING_COPY)
memcpy(persistentState.persistentConfiguration.warning_message, warningBuffer, sizeof(warningBuffer));

View File

@ -210,24 +210,24 @@ static void setPinState(const char * msg, OutputPin *pin, LEElement *element) {
*/
void runFsio() {
#if EFI_FUEL_PUMP
if (isBrainPinValid(CONFIG(fuelPumpPin))) {
if (isBrainPinValid(engineConfiguration->fuelPumpPin)) {
setPinState("pump", &enginePins.fuelPumpRelay, fuelPumpLogic);
}
#endif /* EFI_FUEL_PUMP */
#if EFI_MAIN_RELAY_CONTROL
if (isBrainPinValid(CONFIG(mainRelayPin)))
if (isBrainPinValid(engineConfiguration->mainRelayPin))
// the MAIN_RELAY_LOGIC calls engine->isInShutdownMode()
setPinState("main_relay", &enginePins.mainRelay, mainRelayLogic);
#else /* EFI_MAIN_RELAY_CONTROL */
/**
* main relay is always on if ECU is on, that's a good enough initial implementation
*/
if (isBrainPinValid(CONFIG(mainRelayPin)))
if (isBrainPinValid(engineConfiguration->mainRelayPin))
enginePins.mainRelay.setValue(!engine->isInMainRelayBench());
#endif /* EFI_MAIN_RELAY_CONTROL */
if (isBrainPinValid(CONFIG(starterRelayDisablePin)))
if (isBrainPinValid(engineConfiguration->starterRelayDisablePin))
setPinState("starter_relay", &enginePins.starterRelayDisable, starterRelayDisableLogic);
/**
@ -257,7 +257,7 @@ static void showFsioInfo() {
showFsio("fuel", fuelPumpLogic);
for (int i = 0; i < SCRIPT_SETTING_COUNT; i++) {
float v = CONFIG(scriptSetting)[i];
float v = engineConfiguration->scriptSetting[i];
if (!cisnan(v)) {
efiPrintf("user property #%d: %.2f", i + 1, v);
}
@ -338,10 +338,10 @@ void initFsioImpl() {
#endif /* EFI_FUEL_PUMP */
#if EFI_MAIN_RELAY_CONTROL
if (isBrainPinValid(CONFIG(mainRelayPin)))
if (isBrainPinValid(engineConfiguration->mainRelayPin))
mainRelayLogic = sysPool.parseExpression(MAIN_RELAY_LOGIC);
#endif /* EFI_MAIN_RELAY_CONTROL */
if (isBrainPinValid(CONFIG(starterRelayDisablePin)))
if (isBrainPinValid(engineConfiguration->starterRelayDisablePin))
starterRelayDisableLogic = sysPool.parseExpression(STARTER_RELAY_LOGIC);
scriptTable1.init(config->scriptTable1, config->scriptTable1LoadBins,
@ -366,15 +366,15 @@ void runHardcodedFsio() {
#endif /* EFI_PROD_CODE */
// see MAIN_RELAY_LOGIC
if (isBrainPinValid(CONFIG(mainRelayPin))) {
if (isBrainPinValid(engineConfiguration->mainRelayPin)) {
enginePins.mainRelay.setValue((getTimeNowSeconds() < 2) || (Sensor::getOrZero(SensorType::BatteryVoltage) > LOW_VBATT) || engine->isInShutdownMode());
}
// see STARTER_RELAY_LOGIC
if (isBrainPinValid(CONFIG(starterRelayDisablePin))) {
if (isBrainPinValid(engineConfiguration->starterRelayDisablePin)) {
enginePins.starterRelayDisable.setValue(engine->rpmCalculator.getRpm() < engineConfiguration->cranking.rpm);
}
// see FUEL_PUMP_LOGIC
if (isBrainPinValid(CONFIG(fuelPumpPin))) {
if (isBrainPinValid(engineConfiguration->fuelPumpPin)) {
int triggerActivityOrEcuStartSecond = maxI(0, engine->triggerActivityMs / 1000);
enginePins.fuelPumpRelay.setValue((getTimeNowSeconds() < triggerActivityOrEcuStartSecond + engineConfiguration->startUpFuelPumpDuration) || (engine->rpmCalculator.getRpm() > 0));

View File

@ -150,7 +150,7 @@ class EngineStateBlinkingTask : public PeriodicTimerController {
void PeriodicTask() override {
counter++;
#if EFI_SHAFT_POSITION_INPUT
bool is_running = ENGINE(rpmCalculator).isRunning();
bool is_running = engine->rpmCalculator.isRunning();
#else
bool is_running = false;
#endif /* EFI_SHAFT_POSITION_INPUT */
@ -159,7 +159,7 @@ class EngineStateBlinkingTask : public PeriodicTimerController {
// blink in running mode
enginePins.runningLedPin.setValue(counter % 2);
} else {
int is_cranking = ENGINE(rpmCalculator).isCranking();
int is_cranking = engine->rpmCalculator.isCranking();
enginePins.runningLedPin.setValue(is_cranking);
}
}
@ -219,7 +219,7 @@ static void doPeriodicSlowCallback() {
engine->rpmCalculator.setStopSpinning();
}
if (ENGINE(directSelfStimulation) || engine->rpmCalculator.isStopped()) {
if (engine->directSelfStimulation || engine->rpmCalculator.isStopped()) {
/**
* rusEfi usually runs on hardware which halts execution while writing to internal flash, so we
* postpone writes to until engine is stopped. Writes in case of self-stimulation are fine.
@ -244,7 +244,7 @@ static void doPeriodicSlowCallback() {
engine->periodicSlowCallback();
#endif /* if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT */
if (CONFIG(tcuEnabled)) {
if (engineConfiguration->tcuEnabled) {
engine->gearController->update();
}
}
@ -572,7 +572,7 @@ void commonInitEngineController() {
#endif /* EFI_SHAFT_POSITION_INPUT */
#if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || EFI_SIMULATOR || EFI_UNIT_TEST
if (CONFIG(isEngineControlEnabled)) {
if (engineConfiguration->isEngineControlEnabled) {
initAuxValves();
/**
* This method adds trigger listener which actually schedules ignition
@ -589,8 +589,8 @@ void commonInitEngineController() {
// Returns false if there's an obvious problem with the loaded configuration
bool validateConfig() {
if (CONFIG(specs.cylindersCount) > MAX_CYLINDER_COUNT) {
firmwareError(OBD_PCM_Processor_Fault, "Invalid cylinder count: %d", CONFIG(specs.cylindersCount));
if (engineConfiguration->specs.cylindersCount > MAX_CYLINDER_COUNT) {
firmwareError(OBD_PCM_Processor_Fault, "Invalid cylinder count: %d", engineConfiguration->specs.cylindersCount);
return false;
}
@ -653,8 +653,8 @@ bool validateConfig() {
ensureArrayIsAscending("Idle timing", config->idleAdvanceBins);
}
for (size_t index = 0; index < efi::size(CONFIG(vrThreshold)); index++) {
auto& cfg = CONFIG(vrThreshold)[index];
for (size_t index = 0; index < efi::size(engineConfiguration->vrThreshold); index++) {
auto& cfg = engineConfiguration->vrThreshold[index];
if (cfg.pin == GPIO_UNASSIGNED) {
continue;
@ -672,13 +672,13 @@ bool validateConfig() {
ensureArrayIsAscending("Pedal map RPM", config->pedalToTpsRpmBins);
// VVT
if (CONFIG(camInputs[0]) != GPIO_UNASSIGNED) {
if (engineConfiguration->camInputs[0] != GPIO_UNASSIGNED) {
ensureArrayIsAscending("VVT intake load", config->vvtTable1LoadBins);
ensureArrayIsAscending("VVT intake RPM", config->vvtTable1RpmBins);
}
#if CAM_INPUTS_COUNT != 1
if (CONFIG(camInputs[1]) != GPIO_UNASSIGNED) {
if (engineConfiguration->camInputs[1] != GPIO_UNASSIGNED) {
ensureArrayIsAscending("VVT exhaust load", config->vvtTable2LoadBins);
ensureArrayIsAscending("VVT exhaust RPM", config->vvtTable2RpmBins);
}

View File

@ -79,8 +79,8 @@ static void onStartStopButtonToggle() {
if (!wasStarterEngaged) {
engine->startStopStateLastPushTime = getTimeNowNt();
efiPrintf("Let's crank this engine for up to %d seconds via %s!",
CONFIG(startCrankingDuration),
hwPortname(CONFIG(starterControlPin)));
engineConfiguration->startCrankingDuration,
hwPortname(engineConfiguration->starterControlPin));
}
} else if (engine->rpmCalculator.isRunning()) {
efiPrintf("Let's stop this engine!");
@ -113,10 +113,10 @@ void slowStartStopButtonCallback() {
}
}
if (getTimeNowNt() - engine->startStopStateLastPushTime > NT_PER_SECOND * CONFIG(startCrankingDuration)) {
if (getTimeNowNt() - engine->startStopStateLastPushTime > NT_PER_SECOND * engineConfiguration->startCrankingDuration) {
bool wasStarterEngaged = enginePins.starterControl.getAndSet(0);
if (wasStarterEngaged) {
efiPrintf("Cranking timeout %d seconds", CONFIG(startCrankingDuration));
efiPrintf("Cranking timeout %d seconds", engineConfiguration->startCrankingDuration);
engine->startStopStateLastPushTime = 0;
}
}

View File

@ -32,7 +32,7 @@ void FuelSchedule::resetOverlapping() {
bool FuelSchedule::addFuelEventsForCylinder(int i ) {
efiAssert(CUSTOM_ERR_ASSERT, engine!=NULL, "engine is NULL", false);
floatus_t oneDegreeUs = ENGINE(rpmCalculator.oneDegreeUs); // local copy
floatus_t oneDegreeUs = engine->rpmCalculator.oneDegreeUs; // local copy
if (cisnan(oneDegreeUs)) {
// in order to have fuel schedule we need to have current RPM
// wonder if this line slows engine startup?
@ -46,12 +46,12 @@ bool FuelSchedule::addFuelEventsForCylinder(int i ) {
* todo: since this method is not invoked within trigger event handler and
* engineState.injectionOffset is calculated from the same utility timer should we more that logic here?
*/
floatms_t fuelMs = ENGINE(injectionDuration);
floatms_t fuelMs = engine->injectionDuration;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(fuelMs), "NaN fuelMs", false);
angle_t injectionDurationAngle = MS2US(fuelMs) / oneDegreeUs;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(injectionDurationAngle), "NaN injectionDurationAngle", false);
assertAngleRange(injectionDurationAngle, "injectionDuration_r", CUSTOM_INJ_DURATION);
floatus_t injectionOffset = ENGINE(engineState.injectionOffset);
floatus_t injectionOffset = engine->engineState.injectionOffset;
if (cisnan(injectionOffset)) {
// injection offset map not ready - we are not ready to schedule fuel events
return false;
@ -66,7 +66,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i ) {
if (mode == IM_SIMULTANEOUS || mode == IM_SINGLE_POINT) {
// These modes only have one injector
injectorIndex = 0;
} else if (mode == IM_SEQUENTIAL || (mode == IM_BATCH && CONFIG(twoWireBatchInjection))) {
} else if (mode == IM_SEQUENTIAL || (mode == IM_BATCH && engineConfiguration->twoWireBatchInjection)) {
// Map order index -> cylinder index (firing order)
injectorIndex = getCylinderId(i) - 1;
} else if (mode == IM_BATCH) {
@ -78,14 +78,14 @@ bool FuelSchedule::addFuelEventsForCylinder(int i ) {
}
InjectorOutputPin *secondOutput;
if (mode == IM_BATCH && CONFIG(twoWireBatchInjection)) {
if (mode == IM_BATCH && engineConfiguration->twoWireBatchInjection) {
/**
* also fire the 2nd half of the injectors so that we can implement a batch mode on individual wires
*/
// 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 + (CONFIG(specs.cylindersCount) / 2)) % CONFIG(specs.cylindersCount);
int secondOrder = (i + (engineConfiguration->specs.cylindersCount / 2)) % engineConfiguration->specs.cylindersCount;
int secondIndex = getCylinderId(secondOrder) - 1;
secondOutput = &enginePins.injectors[secondIndex];
} else {
@ -109,7 +109,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i ) {
warning(CUSTOM_OBD_INJECTION_NO_PIN_ASSIGNED, "no_pin_inj #%s", output->name);
}
angle_t ignitionPositionWithinEngineCycle = ENGINE(ignitionPositionWithinEngineCycle[i]);
angle_t ignitionPositionWithinEngineCycle = engine->ignitionPositionWithinEngineCycle[i];
float angle = baseAngle + ignitionPositionWithinEngineCycle;
@ -128,7 +128,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i ) {
}
void FuelSchedule::addFuelEvents() {
for (size_t cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) {
for (size_t cylinderIndex = 0; cylinderIndex < engineConfiguration->specs.cylindersCount; cylinderIndex++) {
InjectionEvent *ev = &elements[cylinderIndex];
ev->ownIndex = cylinderIndex; // todo: is this assignment needed here? we now initialize in constructor
bool result = addFuelEventsForCylinder(cylinderIndex);
@ -148,7 +148,7 @@ void FuelSchedule::onTriggerTooth(size_t toothIndex, int rpm, efitick_t nowNt) {
return;
}
for (size_t i = 0; i < CONFIG(specs.cylindersCount); i++) {
for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
elements[i].onTriggerTooth(toothIndex, rpm, nowNt);
}
}

View File

@ -16,29 +16,29 @@ int getCylinderKnockBank(uint8_t cylinderIndex) {
switch (cylinderIndex) {
#if EFI_PROD_CODE
case 0:
return CONFIG(knockBankCyl1);
return engineConfiguration->knockBankCyl1;
case 1:
return CONFIG(knockBankCyl2);
return engineConfiguration->knockBankCyl2;
case 2:
return CONFIG(knockBankCyl3);
return engineConfiguration->knockBankCyl3;
case 3:
return CONFIG(knockBankCyl4);
return engineConfiguration->knockBankCyl4;
case 4:
return CONFIG(knockBankCyl5);
return engineConfiguration->knockBankCyl5;
case 5:
return CONFIG(knockBankCyl6);
return engineConfiguration->knockBankCyl6;
case 6:
return CONFIG(knockBankCyl7);
return engineConfiguration->knockBankCyl7;
case 7:
return CONFIG(knockBankCyl8);
return engineConfiguration->knockBankCyl8;
case 8:
return CONFIG(knockBankCyl9);
return engineConfiguration->knockBankCyl9;
case 9:
return CONFIG(knockBankCyl10);
return engineConfiguration->knockBankCyl10;
case 10:
return CONFIG(knockBankCyl11);
return engineConfiguration->knockBankCyl11;
case 11:
return CONFIG(knockBankCyl12);
return engineConfiguration->knockBankCyl12;
#endif
default:
return 0;
@ -46,7 +46,7 @@ int getCylinderKnockBank(uint8_t cylinderIndex) {
}
bool KnockController::onKnockSenseCompleted(uint8_t cylinderIndex, float dbv, efitick_t lastKnockTime) {
bool isKnock = dbv > ENGINE(engineState).knockThreshold;
bool isKnock = dbv > engine->engineState.knockThreshold;
#if EFI_TUNER_STUDIO
// Pass through per-cylinder peak detector
@ -64,20 +64,20 @@ bool KnockController::onKnockSenseCompleted(uint8_t cylinderIndex, float dbv, ef
// TODO: retard timing, then put it back!
if (isKnock) {
auto baseTiming = ENGINE(engineState).timingAdvance;
auto baseTiming = engine->engineState.timingAdvance;
// TODO: 20 configurable? Better explanation why 20?
auto distToMinimum = baseTiming - (-20);
// 0.1% per unit -> multiply by 0.001
auto retardFraction = CONFIG(knockRetardAggression) * 0.001f;
auto retardFraction = engineConfiguration->knockRetardAggression * 0.001f;
auto retardAmount = distToMinimum * retardFraction;
{
// Adjust knock retard under lock
chibios_rt::CriticalSectionLocker csl;
auto newRetard = m_knockRetard + retardAmount;
m_knockRetard = clampF(0, newRetard, CONFIG(knockRetardMaximum));
m_knockRetard = clampF(0, newRetard, engineConfiguration->knockRetardMaximum);
}
}
@ -92,7 +92,7 @@ void KnockController::periodicFastCallback() {
constexpr auto callbackPeriodSeconds = FAST_CALLBACK_PERIOD_MS / 1000.0f;
// stored in units of 0.1 deg/sec
auto applyRate = CONFIG(knockRetardReapplyRate) * 0.1f;
auto applyRate = engineConfiguration->knockRetardReapplyRate * 0.1f;
auto applyAmount = applyRate * callbackPeriodSeconds;
{
@ -123,7 +123,7 @@ static void startKnockSampling(Engine* engine) {
}
// Convert sampling angle to time
float samplingSeconds = ENGINE(rpmCalculator).oneDegreeUs * CONFIG(knockSamplingDuration) / US_PER_SECOND_F;
float samplingSeconds = engine->rpmCalculator.oneDegreeUs * engineConfiguration->knockSamplingDuration / US_PER_SECOND_F;
// Look up which channel this cylinder uses
auto channel = getCylinderKnockBank(cylinderIndexCopy);
@ -139,7 +139,7 @@ void Engine::onSparkFireKnockSense(uint8_t cylinderIndex, efitick_t nowNt) {
#if EFI_HIP_9011 || EFI_SOFTWARE_KNOCK
scheduleByAngle(&startSampling, nowNt,
/*angle*/CONFIG(knockDetectionWindowStart), { startKnockSampling, engine });
/*angle*/engineConfiguration->knockDetectionWindowStart, { startKnockSampling, engine });
#endif
#if EFI_HIP_9011

View File

@ -58,14 +58,14 @@
void startSimultaniousInjection(void*) {
efitick_t nowNt = getTimeNowNt();
for (size_t i = 0; i < CONFIG(specs.cylindersCount); i++) {
for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
enginePins.injectors[i].open(nowNt);
}
}
static void endSimultaniousInjectionOnlyTogglePins(void*) {
efitick_t nowNt = getTimeNowNt();
for (size_t i = 0; i < CONFIG(specs.cylindersCount); i++) {
for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
enginePins.injectors[i].close(nowNt);
}
}
@ -167,23 +167,23 @@ void InjectionEvent::onTriggerTooth(size_t trgEventIndex, int rpm, efitick_t now
// Select fuel mass from the correct bank
uint8_t bankIndex = CONFIG(cylinderBankSelect[this->cylinderNumber]);
float injectionMassGrams = ENGINE(injectionMass)[bankIndex];
float injectionMassGrams = engine->injectionMass[bankIndex];
// Perform wall wetting adjustment on fuel mass, not duration, so that
// it's correct during fuel pressure (injector flow) or battery voltage (deadtime) transients
injectionMassGrams = wallFuel.adjust(injectionMassGrams);
const floatms_t injectionDuration = ENGINE(injectorModel)->getInjectionDuration(injectionMassGrams);
const floatms_t injectionDuration = engine->injectorModel->getInjectionDuration(injectionMassGrams);
#if EFI_PRINTF_FUEL_DETAILS
if (printFuelDebug) {
printf("fuel index=%d injectionDuration=%.2fms adjusted=%.2fms\n",
eventIndex,
ENGINE(injectionDuration),
engine->injectionDuration,
injectionDuration);
}
#endif /*EFI_PRINTF_FUEL_DETAILS */
bool isCranking = ENGINE(rpmCalculator).isCranking();
bool isCranking = engine->rpmCalculator.isCranking();
/**
* todo: pre-calculate 'numberOfInjections'
* see also injectorDutyCycle
@ -193,9 +193,9 @@ void InjectionEvent::onTriggerTooth(size_t trgEventIndex, int rpm, efitick_t now
warning(CUSTOM_TOO_LONG_FUEL_INJECTION, "Too long fuel injection %.2fms", injectionDuration);
}
ENGINE(engineState.fuelConsumption).consumeFuel(injectionMassGrams * numberOfInjections, nowNt);
engine->engineState.fuelConsumption.consumeFuel(injectionMassGrams * numberOfInjections, nowNt);
ENGINE(actualLastInjection)[bankIndex] = injectionDuration;
engine->actualLastInjection[bankIndex] = injectionDuration;
if (cisnan(injectionDuration)) {
warning(CUSTOM_OBD_NAN_INJECTION, "NaN injection pulse");
@ -294,7 +294,7 @@ static void handleFuel(const bool limitedFuel, uint32_t trgEventIndex, int rpm,
if (limitedFuel) {
return;
}
if (ENGINE(isCylinderCleanupMode)) {
if (engine->isCylinderCleanupMode) {
return;
}
@ -309,7 +309,7 @@ static void handleFuel(const bool limitedFuel, uint32_t trgEventIndex, int rpm,
* Injection events are defined by addFuelEvents() according to selected
* fueling strategy
*/
FuelSchedule *fs = &ENGINE(injectionEvents);
FuelSchedule *fs = &engine->injectionEvents;
if (!fs->isReady) {
fs->addFuelEvents();
}
@ -337,7 +337,7 @@ uint32_t *cyccnt = (uint32_t*) &DWT->CYCCNT;
void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
ScopePerf perf(PE::MainTriggerCallback);
if (CONFIG(vvtMode[0]) == VVT_MIATA_NB2 && ENGINE(triggerCentral.vvtSyncTimeNt) == 0) {
if (engineConfiguration->vvtMode[0] == VVT_MIATA_NB2 && engine->triggerCentral.vvtSyncTimeNt == 0) {
// this is a bit spaghetti code for sure
// do not spark & do not fuel until we have VVT sync. NB2 is a special case
// due to symmetrical crank wheel and we need to make sure no spark happens out of sync
@ -355,13 +355,13 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
#endif // HW_CHECK_MODE
#if EFI_CDM_INTEGRATION
if (trgEventIndex == 0 && isBrainPinValid(CONFIG(cdmInputPin))) {
if (trgEventIndex == 0 && isBrainPinValid(engineConfiguration->cdmInputPin)) {
int cdmKnockValue = getCurrentCdmValue(engine->triggerCentral.triggerState.getTotalRevolutionCounter());
engine->knockLogic(cdmKnockValue);
}
#endif /* EFI_CDM_INTEGRATION */
if (trgEventIndex >= ENGINE(engineCycleEventCount)) {
if (trgEventIndex >= engine->engineCycleEventCount) {
/**
* this could happen in case of a trigger error, just exit silently since the trigger error is supposed to be handled already
* todo: should this check be somewhere higher so that no trigger listeners are invoked with noise?
@ -390,8 +390,8 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
return;
}
bool limitedSpark = !ENGINE(limpManager).allowIgnition();
bool limitedFuel = !ENGINE(limpManager).allowInjection();
bool limitedSpark = !engine->limpManager.allowIgnition();
bool limitedFuel = !engine->limpManager.allowInjection();
#if EFI_LAUNCH_CONTROL
if (engine->launchController.isLaunchCondition && !limitedSpark && !limitedFuel) {
@ -432,7 +432,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
static bool isPrimeInjectionPulseSkipped() {
if (!engine->rpmCalculator.isStopped())
return true;
return CONFIG(isCylinderCleanupEnabled) && (Sensor::getOrZero(SensorType::Tps1) > CLEANUP_MODE_TPS);
return engineConfiguration->isCylinderCleanupEnabled && (Sensor::getOrZero(SensorType::Tps1) > CLEANUP_MODE_TPS);
}
/**
@ -461,12 +461,12 @@ void startPrimeInjectionPulse() {
engine->primeInjEvent.ownIndex = 0;
engine->primeInjEvent.isSimultanious = true;
scheduling_s *sDown = &ENGINE(injectionEvents.elements[0]).endOfInjectionEvent;
scheduling_s *sDown = &engine->injectionEvents.elements[0].endOfInjectionEvent;
// When the engine is hot, basically we don't need prime inj.pulse, so we use an interpolation over temperature (falloff).
// If 'primeInjFalloffTemperature' is not specified (by default), we have a prime pulse deactivation at zero celsius degrees, which is okay.
const float maxPrimeInjAtTemperature = -40.0f; // at this temperature the pulse is maximal.
floatms_t pulseLength = interpolateClamped(maxPrimeInjAtTemperature, CONFIG(startOfCrankingPrimingPulse),
CONFIG(primeInjFalloffTemperature), 0.0f, Sensor::get(SensorType::Clt).value_or(70));
floatms_t pulseLength = interpolateClamped(maxPrimeInjAtTemperature, engineConfiguration->startOfCrankingPrimingPulse,
engineConfiguration->primeInjFalloffTemperature, 0.0f, Sensor::get(SensorType::Clt).value_or(70));
if (pulseLength > 0) {
startSimultaniousInjection();
int turnOffDelayUs = efiRound(MS2US(pulseLength), 1.0f);
@ -501,7 +501,7 @@ static void showMainInfo(Engine *engine) {
int rpm = GET_RPM();
float el = getFuelingLoad();
efiPrintf("rpm %d engine_load %.2f", rpm, el);
efiPrintf("fuel %.2fms timing %.2f", ENGINE(injectionDuration), engine->engineState.timingAdvance);
efiPrintf("fuel %.2fms timing %.2f", engine->injectionDuration, engine->engineState.timingAdvance);
#endif /* EFI_PROD_CODE */
}
@ -513,7 +513,7 @@ void initMainEventListener() {
#endif
// We start prime injection pulse at the early init stage - don't wait for the engine to start spinning!
if (CONFIG(startOfCrankingPrimingPulse) > 0)
if (engineConfiguration->startOfCrankingPrimingPulse > 0)
startPrimeInjectionPulse();
}

View File

@ -98,7 +98,7 @@ static void startAveraging(scheduling_s *endAveragingScheduling) {
mapAveragingPin.setHigh();
scheduleByAngle(endAveragingScheduling, getTimeNowNt(), ENGINE(engineState.mapAveragingDuration),
scheduleByAngle(endAveragingScheduling, getTimeNowNt(), engine->engineState.mapAveragingDuration,
endAveraging);
}
@ -109,7 +109,7 @@ static void startAveraging(scheduling_s *endAveragingScheduling) {
* as fast as possible
*/
void mapAveragingAdcCallback(adcsample_t adcValue) {
if (!isAveraging && ENGINE(sensorChartMode) != SC_MAP) {
if (!isAveraging && engine->sensorChartMode != SC_MAP) {
return;
}
@ -118,7 +118,7 @@ void mapAveragingAdcCallback(adcsample_t adcValue) {
efiAssertVoid(CUSTOM_ERR_6650, getCurrentRemainingStack() > 128, "lowstck#9a");
#if EFI_SENSOR_CHART && EFI_ANALOG_SENSORS
if (ENGINE(sensorChartMode) == SC_MAP) {
if (engine->sensorChartMode == SC_MAP) {
if (measurementsPerRevolutionCounter % FAST_MAP_CHART_SKIP_FACTOR
== 0) {
float voltage = adcToVoltsDivided(adcValue);
@ -174,7 +174,7 @@ static void endAveraging(void*) {
static void applyMapMinBufferLength() {
// check range
mapMinBufferLength = maxI(minI(CONFIG(mapMinBufferLength), MAX_MAP_BUFFER_LENGTH), 1);
mapMinBufferLength = maxI(minI(engineConfiguration->mapMinBufferLength, MAX_MAP_BUFFER_LENGTH), 1);
// reset index
averagedMapBufIdx = 0;
// fill with maximum values
@ -199,7 +199,7 @@ void refreshMapAveragingPreCalc() {
angle_t start = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle);
efiAssertVoid(CUSTOM_ERR_MAP_START_ASSERT, !cisnan(start), "start");
angle_t offsetAngle = ENGINE(triggerCentral.triggerFormDetails).eventAngles[CONFIG(mapAveragingSchedulingAtIndex)];
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++) {
@ -229,7 +229,7 @@ void mapAveragingTriggerCallback(
uint32_t index, efitick_t edgeTimestamp) {
#if EFI_ENGINE_CONTROL
// this callback is invoked on interrupt thread
if (index != (uint32_t)CONFIG(mapAveragingSchedulingAtIndex))
if (index != (uint32_t)engineConfiguration->mapAveragingSchedulingAtIndex)
return;
int rpm = GET_RPM();
@ -239,7 +239,7 @@ void mapAveragingTriggerCallback(
ScopePerf perf(PE::MapAveragingTriggerCallback);
if (CONFIG(mapMinBufferLength) != mapMinBufferLength) {
if (engineConfiguration->mapMinBufferLength != mapMinBufferLength) {
applyMapMinBufferLength();
}
@ -247,12 +247,12 @@ void mapAveragingTriggerCallback(
measurementsPerRevolutionCounter = 0;
// todo: this could be pre-calculated
int samplingCount = CONFIG(measureMapOnlyInOneCylinder) ? 1 : engineConfiguration->specs.cylindersCount;
int samplingCount = engineConfiguration->measureMapOnlyInOneCylinder ? 1 : engineConfiguration->specs.cylindersCount;
for (int i = 0; i < samplingCount; i++) {
angle_t samplingStart = ENGINE(engineState.mapAveragingStart[i]);
angle_t samplingStart = engine->engineState.mapAveragingStart[i];
angle_t samplingDuration = ENGINE(engineState.mapAveragingDuration);
angle_t samplingDuration = engine->engineState.mapAveragingDuration;
// todo: this assertion could be moved out of trigger handler
assertAngleRange(samplingDuration, "samplingDuration", CUSTOM_ERR_6563);
if (samplingDuration <= 0) {

View File

@ -150,7 +150,7 @@ void RpmCalculator::setRpmValue(float value) {
// Change state
if (rpmValue == 0) {
state = STOPPED;
} else if (rpmValue >= CONFIG(cranking.rpm)) {
} else if (rpmValue >= engineConfiguration->cranking.rpm) {
if (state != RUNNING) {
// Store the time the engine started
engineStartTimer.reset();
@ -167,7 +167,7 @@ void RpmCalculator::setRpmValue(float value) {
#if EFI_ENGINE_CONTROL
// This presumably fixes injection mode change for cranking-to-running transition.
// 'isSimultanious' flag should be updated for events if injection modes differ for cranking and running.
if (state != oldState && CONFIG(crankingInjectionMode) != CONFIG(injectionMode)) {
if (state != oldState && engineConfiguration->crankingInjectionMode != engineConfiguration->injectionMode) {
// Reset the state of all injectors: when we change fueling modes, we could
// immediately reschedule an injection that's currently underway. That will cause
// the injector's overlappingCounter to get out of sync with reality. As the fix,
@ -213,7 +213,7 @@ void RpmCalculator::setStopSpinning() {
}
void RpmCalculator::setSpinningUp(efitick_t nowNt) {
if (!CONFIG(isFasterEngineSpinUpEnabled))
if (!engineConfiguration->isFasterEngineSpinUpEnabled)
return;
// Only a completely stopped and non-spinning engine can enter the spinning-up state.
if (isStopped() && !isSpinning) {
@ -280,7 +280,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
#if EFI_SENSOR_CHART
// this 'index==0' case is here so that it happens after cycle callback so
// it goes into sniffer report into the first position
if (ENGINE(sensorChartMode) == SC_TRIGGER) {
if (engine->sensorChartMode == SC_TRIGGER) {
angle_t crankAngle = getCrankshaftAngleNt(nowNt);
int signal = 1000 * ckpSignalType + index;
scAddData(crankAngle, signal);
@ -335,7 +335,7 @@ static void onTdcCallback(void *) {
void tdcMarkCallback(
uint32_t index0, efitick_t edgeTimestamp) {
bool isTriggerSynchronizationPoint = index0 == 0;
if (isTriggerSynchronizationPoint && ENGINE(isEngineChartEnabled) && ENGINE(tdcMarkEnabled)) {
if (isTriggerSynchronizationPoint && engine->isEngineChartEnabled && engine->tdcMarkEnabled) {
// two instances of scheduling_s are needed to properly handle event overlap
int revIndex2 = getRevolutionCounter() % 2;
int rpm = GET_RPM();
@ -372,8 +372,8 @@ void initRpmCalculator() {
#endif // HW_CHECK_MODE
// Only register if not configured to read RPM over OBD2
if (!CONFIG(consumeObdSensors)) {
ENGINE(rpmCalculator).Register();
if (!engineConfiguration->consumeObdSensors) {
engine->rpmCalculator.Register();
}
}
@ -385,7 +385,7 @@ void initRpmCalculator() {
*/
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle,
action_s action) {
float delayUs = ENGINE(rpmCalculator.oneDegreeUs) * angle;
float delayUs = engine->rpmCalculator.oneDegreeUs * angle;
// 'delayNt' is below 10 seconds here so we use 32 bit type for performance reasons
int32_t delayNt = USF2NT(delayUs);

View File

@ -179,7 +179,7 @@ float getCrankshaftAngleNt(efitick_t timeNt);
#define getRevolutionCounter() ENGINE(rpmCalculator.getRevolutionCounterM())
#if EFI_ENGINE_SNIFFER
#define addEngineSnifferEvent(name, msg) { efiAssertVoid(OBD_PCM_Processor_Fault, engine!=NULL, "engine ptr missing"); if (ENGINE(isEngineChartEnabled)) { waveChart.addEvent3((name), (msg)); } }
#define addEngineSnifferEvent(name, msg) { efiAssertVoid(OBD_PCM_Processor_Fault, engine!=NULL, "engine ptr missing"); if (engine->isEngineChartEnabled) { waveChart.addEvent3((name), (msg)); } }
#else
#define addEngineSnifferEvent(n, msg) {}
#endif /* EFI_ENGINE_SNIFFER */

View File

@ -78,7 +78,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
assertAngleRange(ignitionPositionWithinEngineCycle, "aPWEC", CUSTOM_ERR_6566);
// this correction is usually zero (not used)
float perCylinderCorrection = CONFIG(timing_offset_cylinder[event->cylinderIndex]);
const angle_t sparkAngle = -ENGINE(engineState.timingAdvance) + ENGINE(knockController).getKnockRetard() + ignitionPositionWithinEngineCycle + perCylinderCorrection;
const angle_t sparkAngle = -engine->engineState.timingAdvance + engine->knockController.getKnockRetard() + ignitionPositionWithinEngineCycle + perCylinderCorrection;
efiAssertVoid(CUSTOM_SPARK_ANGLE_9, !cisnan(sparkAngle), "findAngle#9");
efiAssertVoid(CUSTOM_SPARK_ANGLE_1, !cisnan(sparkAngle), "sparkAngle#1");
@ -87,8 +87,8 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
IgnitionOutputPin *output = &enginePins.coils[coilIndex];
IgnitionOutputPin *secondOutput;
if (getCurrentIgnitionMode() == IM_WASTED_SPARK && CONFIG(twoWireBatchIgnition)) {
int secondIndex = index + CONFIG(specs.cylindersCount) / 2;
if (getCurrentIgnitionMode() == IM_WASTED_SPARK && engineConfiguration->twoWireBatchIgnition) {
int secondIndex = index + engineConfiguration->specs.cylindersCount / 2;
int secondCoilIndex = ID2INDEX(getCylinderId(secondIndex));
secondOutput = &enginePins.coils[secondCoilIndex];
assertPinAssigned(secondOutput);
@ -184,8 +184,8 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
#endif /* EFI_UNIT_TEST */
// now that we've just fired a coil let's prepare the new schedule for the next engine revolution
angle_t dwellAngleDuration = ENGINE(engineState.dwellAngle);
floatms_t sparkDwell = ENGINE(engineState.sparkDwell);
angle_t dwellAngleDuration = engine->engineState.dwellAngle;
floatms_t sparkDwell = engine->engineState.sparkDwell;
if (cisnan(dwellAngleDuration) || cisnan(sparkDwell)) {
// we are here if engine has just stopped
return;
@ -205,14 +205,14 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
engine->executor.scheduleByTimestampNt("dwell", &event->dwellStartTimer, nextDwellStart, { &turnSparkPinHigh, event });
engine->executor.scheduleByTimestampNt("firing", &event->sparkEvent.scheduling, nextFiring, { fireSparkAndPrepareNextSchedule, event });
} else {
if (CONFIG(enableTrailingSparks)) {
if (engineConfiguration->enableTrailingSparks) {
#if SPARK_EXTREME_LOGGING
efiPrintf("scheduleByAngle TrailingSparks");
#endif /* SPARK_EXTREME_LOGGING */
// Trailing sparks are enabled - schedule an event for the corresponding trailing coil
scheduleByAngle(
&event->trailingSparkFire, nowNt, ENGINE(engineState.trailingSparkAngle),
&event->trailingSparkFire, nowNt, engine->engineState.trailingSparkAngle,
{ &fireTrailingSpark, &enginePins.trailingCoils[event->cylinderNumber] }
);
}
@ -270,11 +270,11 @@ void turnSparkPinHigh(IgnitionEvent *event) {
}
}
if (CONFIG(enableTrailingSparks)) {
if (engineConfiguration->enableTrailingSparks) {
IgnitionOutputPin *output = &enginePins.trailingCoils[event->cylinderNumber];
// Trailing sparks are enabled - schedule an event for the corresponding trailing coil
scheduleByAngle(
&event->trailingSparkCharge, nowNt, ENGINE(engineState.trailingSparkAngle),
&event->trailingSparkCharge, nowNt, engine->engineState.trailingSparkAngle,
{ &chargeTrailingSpark, output }
);
}
@ -320,13 +320,13 @@ bool scheduleOrQueue(AngleBasedEvent *event,
/**
* Spark should be scheduled in relation to some future trigger event, this way we get better firing precision
*/
bool isPending = assertNotInIgnitionList(ENGINE(angleBasedEventsHead), event);
bool isPending = assertNotInIgnitionList(engine->angleBasedEventsHead, event);
if (isPending) {
#if SPARK_EXTREME_LOGGING
efiPrintf("isPending thus not adding to queue index=%d rev=%d now=%d", trgEventIndex, getRevolutionCounter(), (int)getTimeNowUs());
#endif /* SPARK_EXTREME_LOGGING */
} else {
LL_APPEND2(ENGINE(angleBasedEventsHead), event, nextToothEvent);
LL_APPEND2(engine->angleBasedEventsHead, event, nextToothEvent);
}
return false;
}
@ -336,7 +336,7 @@ static void scheduleSparkEvent(bool limitedSpark, uint32_t trgEventIndex, Igniti
int rpm, efitick_t edgeTimestamp) {
angle_t sparkAngle = event->sparkAngle;
const floatms_t dwellMs = ENGINE(engineState.sparkDwell);
const floatms_t dwellMs = engine->engineState.sparkDwell;
if (cisnan(dwellMs) || dwellMs <= 0) {
warning(CUSTOM_DWELL, "invalid dwell to handle: %.2f at %d", dwellMs, rpm);
return;
@ -377,7 +377,7 @@ static void scheduleSparkEvent(bool limitedSpark, uint32_t trgEventIndex, Igniti
*/
chargeTime = scheduleByAngle(&event->dwellStartTimer, edgeTimestamp, angleOffset, { &turnSparkPinHigh, event });
event->sparksRemaining = ENGINE(engineState.multispark.count);
event->sparksRemaining = engine->engineState.multispark.count;
} else {
// don't fire multispark if spark is cut completely!
event->sparksRemaining = 0;
@ -419,9 +419,9 @@ static void scheduleSparkEvent(bool limitedSpark, uint32_t trgEventIndex, Igniti
void initializeIgnitionActions() {
IgnitionEventList *list = &engine->ignitionEvents;
angle_t dwellAngle = ENGINE(engineState.dwellAngle);
floatms_t sparkDwell = ENGINE(engineState.sparkDwell);
if (cisnan(ENGINE(engineState.timingAdvance)) || cisnan(dwellAngle)) {
angle_t dwellAngle = engine->engineState.dwellAngle;
floatms_t sparkDwell = engine->engineState.sparkDwell;
if (cisnan(engine->engineState.timingAdvance) || cisnan(dwellAngle)) {
// error should already be reported
// need to invalidate previous ignition schedule
list->isReady = false;
@ -429,7 +429,7 @@ void initializeIgnitionActions() {
}
efiAssertVoid(CUSTOM_ERR_6592, engineConfiguration->specs.cylindersCount > 0, "cylindersCount");
for (size_t cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) {
for (size_t cylinderIndex = 0; cylinderIndex < engineConfiguration->specs.cylindersCount; cylinderIndex++) {
list->elements[cylinderIndex].cylinderIndex = cylinderIndex;
prepareCylinderIgnitionSchedule(dwellAngle, sparkDwell, &list->elements[cylinderIndex]);
}
@ -468,11 +468,11 @@ static void prepareIgnitionSchedule() {
static void scheduleAllSparkEventsUntilNextTriggerTooth(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
AngleBasedEvent *current, *tmp;
LL_FOREACH_SAFE2(ENGINE(angleBasedEventsHead), current, tmp, nextToothEvent)
LL_FOREACH_SAFE2(engine->angleBasedEventsHead, current, tmp, nextToothEvent)
{
if (current->position.triggerEventIndex == trgEventIndex) {
// time to fire a spark which was scheduled previously
LL_DELETE2(ENGINE(angleBasedEventsHead), current, nextToothEvent);
LL_DELETE2(engine->angleBasedEventsHead, current, nextToothEvent);
scheduling_s * sDown = &current->scheduling;
@ -498,12 +498,12 @@ void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm
ScopePerf perf(PE::OnTriggerEventSparkLogic);
if (!isValidRpm(rpm) || !CONFIG(isIgnitionEnabled)) {
if (!isValidRpm(rpm) || !engineConfiguration->isIgnitionEnabled) {
// this might happen for instance in case of a single trigger event after a pause
return;
}
if (!ENGINE(ignitionEvents.isReady)) {
if (!engine->ignitionEvents.isReady) {
prepareIgnitionSchedule();
}
@ -516,13 +516,13 @@ void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm
// scheduleSimpleMsg(&logger, "eventId spark ", eventIndex);
if (ENGINE(ignitionEvents.isReady)) {
for (size_t i = 0; i < CONFIG(specs.cylindersCount); i++) {
IgnitionEvent *event = &ENGINE(ignitionEvents.elements[i]);
if (engine->ignitionEvents.isReady) {
for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
IgnitionEvent *event = &engine->ignitionEvents.elements[i];
if (event->dwellPosition.triggerEventIndex != trgEventIndex)
continue;
if (i == 0 && CONFIG(artificialTestMisfire) && (getRevolutionCounter() % ((int)engineConfiguration->scriptSetting[5]) == 0)) {
if (i == 0 && engineConfiguration->artificialTestMisfire && (getRevolutionCounter() % ((int)engineConfiguration->scriptSetting[5]) == 0)) {
// artificial misfire on cylinder #1 for testing purposes
// enable artificialMisfire
// set_fsio_setting 6 20
@ -559,7 +559,7 @@ int getNumberOfSparks(ignition_mode_e mode) {
* @see getInjectorDutyCycle
*/
percent_t getCoilDutyCycle(int rpm) {
floatms_t totalPerCycle = ENGINE(engineState.sparkDwell) * getNumberOfSparks(getCurrentIgnitionMode());
floatms_t totalPerCycle = engine->engineState.sparkDwell * getNumberOfSparks(getCurrentIgnitionMode());
floatms_t engineCycleDuration = getCrankshaftRevolutionTimeMs(rpm) * (engine->getOperationMode() == TWO_STROKE ? 1 : 2);
return 100 * totalPerCycle / engineCycleDuration;
}

View File

@ -149,7 +149,7 @@ static void showLine(lcd_line_e line, int /*screenY*/) {
#if EFI_FILE_LOGGING
{
char sdState;
if (CONFIG(isSdCardEnabled)) {
if (engineConfiguration->isSdCardEnabled) {
sdState = isSdCardAlive() ? 'L' : 'n';
} else {
sdState = 'D';

View File

@ -113,7 +113,7 @@ static void testMil() {
#endif /* TEST_MIL_CODE */
bool isMilEnabled() {
return isBrainPinValid(CONFIG(malfunctionIndicatorPin));
return isBrainPinValid(engineConfiguration->malfunctionIndicatorPin);
}
void initMalfunctionIndicator(void) {

View File

@ -35,7 +35,7 @@ void tachSignalCallback() {
}
// How many tach pulse periods do we have?
int periods = CONFIG(tachPulsePerRev);
int periods = engineConfiguration->tachPulsePerRev;
if (periods == 0 || periods > 10) {
firmwareError(CUSTOM_ERR_6709, "Invalid tachometer pulse per rev: %d", periods);
@ -47,12 +47,12 @@ void tachSignalCallback() {
float periodTimeMs = cycleTimeMs / periods;
tachFreq = 1000.0f / periodTimeMs;
if (CONFIG(tachPulseDurationAsDutyCycle)) {
if (engineConfiguration->tachPulseDurationAsDutyCycle) {
// Simple case - duty explicitly set
duty = CONFIG(tachPulseDuractionMs);
duty = engineConfiguration->tachPulseDuractionMs;
} else {
// Constant high-time mode - compute the correct duty cycle
duty = CONFIG(tachPulseDuractionMs) / periodTimeMs;
duty = engineConfiguration->tachPulseDuractionMs / periodTimeMs;
}
// In case Freq is under 1Hz, we stop pwm to avoid warnings!
@ -66,7 +66,7 @@ void tachSignalCallback() {
void initTachometer() {
tachHasInit = false;
if (!isBrainPinValid(CONFIG(tachOutputPin))) {
if (!isBrainPinValid(engineConfiguration->tachOutputPin)) {
return;
}

View File

@ -3,16 +3,16 @@
#include "limp_manager.h"
void LimpManager::updateState(int rpm, efitick_t nowNt) {
Clearable allowFuel = CONFIG(isInjectionEnabled);
Clearable allowSpark = CONFIG(isIgnitionEnabled);
Clearable allowFuel = engineConfiguration->isInjectionEnabled;
Clearable allowSpark = engineConfiguration->isIgnitionEnabled;
// User-configured hard RPM limit
if (rpm > CONFIG(rpmHardLimit)) {
if (CONFIG(cutFuelOnHardLimit)) {
if (rpm > engineConfiguration->rpmHardLimit) {
if (engineConfiguration->cutFuelOnHardLimit) {
allowFuel.clear();
}
if (CONFIG(cutSparkOnHardLimit)) {
if (engineConfiguration->cutSparkOnHardLimit) {
allowSpark.clear();
}
}
@ -23,19 +23,19 @@ void LimpManager::updateState(int rpm, efitick_t nowNt) {
}
// Limit fuel only on boost pressure (limiting spark bends valves)
if (CONFIG(boostCutPressure) != 0) {
if (Sensor::getOrZero(SensorType::Map) > CONFIG(boostCutPressure)) {
if (engineConfiguration->boostCutPressure != 0) {
if (Sensor::getOrZero(SensorType::Map) > engineConfiguration->boostCutPressure) {
allowFuel.clear();
}
}
if (ENGINE(rpmCalculator).isRunning()) {
uint16_t minOilPressure = CONFIG(minOilPressureAfterStart);
if (engine->rpmCalculator.isRunning()) {
uint16_t minOilPressure = engineConfiguration->minOilPressureAfterStart;
// Only check if the setting is enabled
if (minOilPressure > 0) {
// Has it been long enough we should have pressure?
bool isTimedOut = ENGINE(rpmCalculator).getTimeSinceEngineStart(nowNt) > 5.0f;
bool isTimedOut = engine->rpmCalculator.getTimeSinceEngineStart(nowNt) > 5.0f;
// Only check before timed out
if (!isTimedOut) {

View File

@ -90,7 +90,7 @@ template <int HeapIdx>
static void* myAlloc(void* /*ud*/, void* ptr, size_t osize, size_t nsize) {
static_assert(HeapIdx < efi::size(heaps));
if (CONFIG(debugMode) == DBG_LUA) {
if (engineConfiguration->debugMode == DBG_LUA) {
switch (HeapIdx) {
case 0: tsOutputChannels.debugIntField1 = heaps[HeapIdx].used(); break;
case 1: tsOutputChannels.debugIntField2 = heaps[HeapIdx].used(); break;
@ -333,7 +333,7 @@ void LuaThread::ThreadTask() {
bool wasOk = runOneLua(myAlloc<0>, config->luaScript);
// Reset any lua adjustments the script made
ENGINE(engineState).luaAdjustments = {};
engine->engineState.luaAdjustments = {};
if (!wasOk) {
// Something went wrong executing the script, spin

View File

@ -210,7 +210,7 @@ static int lua_startPwm(lua_State* l) {
startSimplePwmExt(
&p.pwm, "lua", &engine->executor,
CONFIG(luaOutputPins[p.idx]), &pins[p.idx],
engineConfiguration->luaOutputPins[p.idx], &pins[p.idx],
freq, duty
);
@ -275,7 +275,7 @@ static int lua_getDigital(lua_State* l) {
static int lua_setDebug(lua_State* l) {
// wrong debug mode, ignore
if (CONFIG(debugMode) != DBG_LUA) {
if (engineConfiguration->debugMode != DBG_LUA) {
return 0;
}
@ -296,7 +296,7 @@ static int lua_setDebug(lua_State* l) {
static auto lua_getAirmassResolveMode(lua_State* l) {
if (lua_gettop(l) == 0) {
// zero args, return configured mode
return CONFIG(fuelAlgorithm);
return engineConfiguration->fuelAlgorithm;
} else {
return static_cast<engine_load_mode_e>(luaL_checkinteger(l, 1));
}
@ -336,25 +336,25 @@ static int lua_stopEngine(lua_State*) {
}
static int lua_setTimingAdd(lua_State* l) {
ENGINE(engineState).luaAdjustments.ignitionTimingAdd = luaL_checknumber(l, 1);
engine->engineState.luaAdjustments.ignitionTimingAdd = luaL_checknumber(l, 1);
return 0;
}
static int lua_setTimingMult(lua_State* l) {
ENGINE(engineState).luaAdjustments.ignitionTimingMult = luaL_checknumber(l, 1);
engine->engineState.luaAdjustments.ignitionTimingMult = luaL_checknumber(l, 1);
return 0;
}
static int lua_setFuelAdd(lua_State* l) {
ENGINE(engineState).luaAdjustments.fuelAdd = luaL_checknumber(l, 1);
engine->engineState.luaAdjustments.fuelAdd = luaL_checknumber(l, 1);
return 0;
}
static int lua_setFuelMult(lua_State* l) {
ENGINE(engineState).luaAdjustments.fuelMult = luaL_checknumber(l, 1);
engine->engineState.luaAdjustments.fuelMult = luaL_checknumber(l, 1);
return 0;
}

View File

@ -46,20 +46,20 @@ size_t computeStftBin(int rpm, float load, stft_s& cfg) {
}
static bool shouldCorrect() {
const auto& cfg = CONFIG(stft);
const auto& cfg = engineConfiguration->stft;
// User disable bit
if (!CONFIG(fuelClosedLoopCorrectionEnabled)) {
if (!engineConfiguration->fuelClosedLoopCorrectionEnabled) {
return false;
}
// Don't correct if not running
if (!ENGINE(rpmCalculator).isRunning()) {
if (!engine->rpmCalculator.isRunning()) {
return false;
}
// Startup delay - allow O2 sensor to warm up, etc
if (cfg.startupDelay > ENGINE(engineState.running.timeSinceCrankingInSecs)) {
if (cfg.startupDelay > engine->engineState.running.timeSinceCrankingInSecs) {
return false;
}
@ -74,7 +74,7 @@ static bool shouldCorrect() {
}
bool shouldUpdateCorrection(SensorType sensor) {
const auto& cfg = CONFIG(stft);
const auto& cfg = engineConfiguration->stft;
// Pause (but don't reset) correction if the AFR is off scale.
// It's probably a transient and poorly tuned transient correction
@ -91,7 +91,7 @@ ClosedLoopFuelResult fuelClosedLoopCorrection() {
return {};
}
size_t binIdx = computeStftBin(GET_RPM(), getFuelingLoad(), CONFIG(stft));
size_t binIdx = computeStftBin(GET_RPM(), getFuelingLoad(), engineConfiguration->stft);
#if EFI_TUNER_STUDIO
if (engineConfiguration->debugMode == DBG_FUEL_PID_CORRECTION) {
@ -107,10 +107,10 @@ ClosedLoopFuelResult fuelClosedLoopCorrection() {
SensorType sensor = getSensorForBankIndex(i);
// todo: push configuration at startup
cell.configure(&CONFIG(stft.cellCfgs[binIdx]), sensor);
cell.configure(&engineConfiguration->stft.cellCfgs[binIdx], sensor);
if (shouldUpdateCorrection(sensor)) {
cell.update(CONFIG(stft.deadband) * 0.001f, CONFIG(stftIgnoreErrorMagnitude));
cell.update(engineConfiguration->stft.deadband * 0.001f, engineConfiguration->stftIgnoreErrorMagnitude);
}
result.banks[i] = cell.getAdjustment();

View File

@ -53,7 +53,7 @@ float ClosedLoopFuelCellImpl::getLambdaError() const {
return 0;
}
return lambda.Value - ENGINE(engineState.targetLambda);
return lambda.Value - engine->engineState.targetLambda;
}
#define MAX_ADJ (0.25f)

View File

@ -44,11 +44,11 @@ floatms_t getCrankshaftRevolutionTimeMs(int rpm) {
}
float getFuelingLoad() {
return ENGINE(engineState.fuelingLoad);
return engine->engineState.fuelingLoad;
}
float getIgnitionLoad() {
return ENGINE(engineState.ignitionLoad);
return engine->engineState.ignitionLoad;
}
/**
@ -76,8 +76,8 @@ void setSingleCoilDwell() {
floatms_t getSparkDwell(int rpm) {
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
float dwellMs;
if (ENGINE(rpmCalculator).isCranking()) {
dwellMs = CONFIG(ignitionDwellForCrankingMs);
if (engine->rpmCalculator.isCranking()) {
dwellMs = engineConfiguration->ignitionDwellForCrankingMs;
} else {
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN);
@ -160,7 +160,7 @@ static const int order_1_14_9_4_7_12_15_6_13_8_3_16_11_2_5_10[] = {1, 14, 9, 4,
static int getFiringOrderLength() {
switch (CONFIG(specs.firingOrder)) {
switch (engineConfiguration->specs.firingOrder) {
case FO_1:
return 1;
// 2 cylinder
@ -221,14 +221,14 @@ static int getFiringOrderLength() {
return 16;
default:
firmwareError(CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", CONFIG(specs.firingOrder));
firmwareError(CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->specs.firingOrder);
}
return 1;
}
static const int *getFiringOrderTable()
{
switch (CONFIG(specs.firingOrder)) {
switch (engineConfiguration->specs.firingOrder) {
case FO_1:
return order_1;
// 2 cylinder
@ -313,7 +313,7 @@ static const int *getFiringOrderTable()
return order_1_14_9_4_7_12_15_6_13_8_3_16_11_2_5_10;
default:
firmwareError(CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", CONFIG(specs.firingOrder));
firmwareError(CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->specs.firingOrder);
}
return NULL;
@ -376,11 +376,11 @@ static int getIgnitionPinForIndex(int cylinderIndex) {
case IM_ONE_COIL:
return 0;
case IM_WASTED_SPARK: {
if (CONFIG(specs.cylindersCount) == 1) {
if (engineConfiguration->specs.cylindersCount == 1) {
// we do not want to divide by zero
return 0;
}
return cylinderIndex % (CONFIG(specs.cylindersCount) / 2);
return cylinderIndex % (engineConfiguration->specs.cylindersCount / 2);
}
case IM_INDIVIDUAL_COILS:
return cylinderIndex;
@ -396,18 +396,18 @@ static int getIgnitionPinForIndex(int cylinderIndex) {
void prepareIgnitionPinIndices(ignition_mode_e ignitionMode) {
(void)ignitionMode;
#if EFI_ENGINE_CONTROL
for (size_t cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) {
ENGINE(ignitionPin[cylinderIndex]) = getIgnitionPinForIndex(cylinderIndex);
for (size_t cylinderIndex = 0; cylinderIndex < engineConfiguration->specs.cylindersCount; cylinderIndex++) {
engine->ignitionPin[cylinderIndex] = getIgnitionPinForIndex(cylinderIndex);
}
#endif /* EFI_ENGINE_CONTROL */
}
/**
* @return IM_WASTED_SPARK if in SPINNING mode and IM_INDIVIDUAL_COILS setting
* @return CONFIG(ignitionMode) otherwise
* @return engineConfiguration->ignitionMode otherwise
*/
ignition_mode_e getCurrentIgnitionMode() {
ignition_mode_e ignitionMode = CONFIG(ignitionMode);
ignition_mode_e ignitionMode = engineConfiguration->ignitionMode;
#if EFI_SHAFT_POSITION_INPUT
// In spin-up cranking mode we don't have full phase sync. info yet, so wasted spark mode is better
if (ignitionMode == IM_INDIVIDUAL_COILS && ENGINE(rpmCalculator.isSpinningUp()))
@ -422,7 +422,7 @@ ignition_mode_e getCurrentIgnitionMode() {
* This heavy method is only invoked in case of a configuration change or initialization.
*/
void prepareOutputSignals() {
ENGINE(engineCycle) = getEngineCycle(engine->getOperationMode());
engine->engineCycle = getEngineCycle(engine->getOperationMode());
angle_t maxTimingCorrMap = -FOUR_STROKE_CYCLE_DURATION;
angle_t maxTimingMap = -FOUR_STROKE_CYCLE_DURATION;
@ -440,16 +440,16 @@ void prepareOutputSignals() {
}
#endif /* EFI_UNIT_TEST */
for (size_t i = 0; i < CONFIG(specs.cylindersCount); i++) {
ENGINE(ignitionPositionWithinEngineCycle[i]) = ENGINE(engineCycle) * i / CONFIG(specs.cylindersCount);
for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
engine->ignitionPositionWithinEngineCycle[i] = engine->engineCycle * i / engineConfiguration->specs.cylindersCount;
}
prepareIgnitionPinIndices(CONFIG(ignitionMode));
prepareIgnitionPinIndices(engineConfiguration->ignitionMode);
TRIGGER_WAVEFORM(prepareShape(&ENGINE(triggerCentral.triggerFormDetails)));
TRIGGER_WAVEFORM(prepareShape(&engine->triggerCentral.triggerFormDetails));
// Fuel schedule may now be completely wrong, force a reset
ENGINE(injectionEvents).invalidate();
engine->injectionEvents.invalidate();
}
void setTimingRpmBin(float from, float to) {

View File

@ -15,7 +15,7 @@ void setAlgorithm(engine_load_mode_e algo);
void setFlatInjectorLag(float value);
#define fixAngle(angle, msg, code) fixAngle2(angle, msg, code, ENGINE(engineCycle))
#define fixAngle(angle, msg, code) fixAngle2(angle, msg, code, engine->engineCycle)
/**
@ -54,8 +54,8 @@ void setTimingLoadBin(float from, float to);
void setSingleCoilDwell();
// we combine trigger-defined triggerShape.tdcPosition with user-defined CONFIG(globalTriggerAngleOffset)
// expectation is that for well-known triggers CONFIG(globalTriggerAngleOffset) would usually be zero
// we combine trigger-defined triggerShape.tdcPosition with user-defined engineConfiguration->globalTriggerAngleOffset
// expectation is that for well-known triggers engineConfiguration->globalTriggerAngleOffset would usually be zero
// while for toothed wheels user would have to provide a value
#define tdcPosition() \
(TRIGGER_WAVEFORM(tdcPosition) + CONFIG(globalTriggerAngleOffset))
(TRIGGER_WAVEFORM(tdcPosition) + engineConfiguration->globalTriggerAngleOffset)

View File

@ -48,27 +48,27 @@ temperature_t getTCharge(int rpm, float tps) {
float coolantTemp = clt.Value;
if ((engine->engineState.sd.isTChargeAirModel = (CONFIG(tChargeMode) == TCHARGE_MODE_AIR_INTERP))) {
if ((engine->engineState.sd.isTChargeAirModel = (engineConfiguration->tChargeMode == TCHARGE_MODE_AIR_INTERP))) {
const 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 = engine->engineState.sd.airMassInOneCylinder * CONFIG(specs.cylindersCount);
floatms_t airMassForEngine = engine->engineState.sd.airMassInOneCylinder * engineConfiguration->specs.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);
// just interpolate between user-specified min and max coefs, based on the max airFlow value
engine->engineState.airFlow = airFlow;
engine->engineState.sd.Tcharge_coff = interpolateClamped(0.0,
CONFIG(tChargeAirCoefMin),
CONFIG(tChargeAirFlowMax),
CONFIG(tChargeAirCoefMax), airFlow);
engineConfiguration->tChargeAirCoefMin,
engineConfiguration->tChargeAirFlowMax,
engineConfiguration->tChargeAirCoefMax, airFlow);
// save it for console output (instead of MAF massAirFlow)
} else {
float minRpmKcurrentTPS = interpolateMsg("minRpm", tpMin,
CONFIG(tChargeMinRpmMinTps), tpMax,
CONFIG(tChargeMinRpmMaxTps), tps);
engineConfiguration->tChargeMinRpmMinTps, tpMax,
engineConfiguration->tChargeMinRpmMaxTps, tps);
float maxRpmKcurrentTPS = interpolateMsg("maxRpm", tpMin,
CONFIG(tChargeMaxRpmMinTps), tpMax,
CONFIG(tChargeMaxRpmMaxTps), tps);
engineConfiguration->tChargeMaxRpmMinTps, tpMax,
engineConfiguration->tChargeMaxRpmMaxTps, tps);
engine->engineState.sd.Tcharge_coff = interpolateMsg("Kcurr", rpmMin, minRpmKcurrentTPS, rpmMax, maxRpmKcurrentTPS, rpm);
}

View File

@ -26,7 +26,7 @@ void AemXSeriesWideband::decodeFrame(const CANRxFrame& frame, efitick_t nowNt) {
#if EFI_TUNER_STUDIO
// rusEfi controller sends some extra diagnostic data about its internal workings
if (isRusefiController && CONFIG(debugMode) == DBG_RUSEFI_WIDEBAND) {
if (isRusefiController && engineConfiguration->debugMode == DBG_RUSEFI_WIDEBAND) {
float pumpDuty = frame.data8[2] / 255.0f;
float sensorEsr = frame.data8[3] * 4;
float nernstVoltage = frame.data8[4] / 200.0f;

View File

@ -13,7 +13,7 @@ ButtonDebounce acDebounce("ac_switch");
void initSensors() {
initMapDecoder();
acDebounce.init(15, CONFIG(acSwitch), CONFIG(acSwitchMode));
acDebounce.init(15, engineConfiguration->acSwitch, engineConfiguration->acSwitchMode);
}
bool getAcToggle() {
@ -21,5 +21,5 @@ bool getAcToggle() {
}
bool hasAcToggle() {
return (isBrainPinValid(CONFIG(acSwitch)));
return (isBrainPinValid(engineConfiguration->acSwitch));
}

View File

@ -46,7 +46,7 @@ static float lastAfr = stoichAfr;
void initEgoAveraging() {
// Our averaging is intended for use only with Narrow EGOs.
if (CONFIG(afr_type) == ES_NarrowBand) {
if (engineConfiguration->afr_type == ES_NarrowBand) {
totalEgoCnt = prevEgoCnt = 0;
egoAfrBuf.clear();
useAveraging = true;
@ -92,12 +92,12 @@ void initEgoAveraging() {
#endif
bool hasAfrSensor() {
if (CONFIG(enableAemXSeries) || CONFIG(enableInnovateLC2)) {
if (engineConfiguration->enableAemXSeries || engineConfiguration->enableInnovateLC2) {
return true;
}
#if EFI_CJ125 && HAL_USE_SPI
if (CONFIG(isCJ125Enabled)) {
if (engineConfiguration->isCJ125Enabled) {
return cjHasAfrSensor();
}
#endif /* EFI_CJ125 && HAL_USE_SPI */
@ -108,16 +108,16 @@ extern float InnovateLC2AFR;
float getAfr() {
#if EFI_AUX_SERIAL
if (CONFIG(enableInnovateLC2))
if (engineConfiguration->enableInnovateLC2)
return InnovateLC2AFR;
#endif
#if EFI_CJ125 && HAL_USE_SPI
if (CONFIG(isCJ125Enabled)) {
if (engineConfiguration->isCJ125Enabled) {
return cjGetAfr();
}
#endif /* EFI_CJ125 && HAL_USE_SPI */
afr_sensor_s * sensor = &CONFIG(afr);
afr_sensor_s * sensor = &engineConfiguration->afr;
if (!isAdcChannelValid(engineConfiguration->afr.hwChannel)) {
return 0;
@ -125,7 +125,7 @@ float getAfr() {
float volts = getVoltageDivided("ego", sensor->hwChannel);
if (CONFIG(afr_type) == ES_NarrowBand) {
if (engineConfiguration->afr_type == ES_NarrowBand) {
float afr = interpolate2d(volts, engineConfiguration->narrowToWideOxygenBins, engineConfiguration->narrowToWideOxygen);
#ifdef EFI_NARROW_EGO_AVERAGING
if (useAveraging)
@ -185,6 +185,6 @@ static void initEgoSensor(afr_sensor_s *sensor, ego_sensor_e type) {
}
void setEgoSensor(ego_sensor_e type) {
CONFIG(afr_type) = type;
engineConfiguration->afr_type = type;
initEgoSensor(&engineConfiguration->afr, type);
}

View File

@ -118,7 +118,7 @@ static float validateBaroMap(float mapKPa) {
float getBaroPressure() {
// Override the real Baro sensor with the stored initial MAP value, if the option is set.
if (CONFIG(useFixedBaroCorrFromMap))
if (engineConfiguration->useFixedBaroCorrFromMap)
return storedInitialBaroPressure;
float voltage = getVoltageDivided("baro", engineConfiguration->baroSensor.hwChannel);
return decodePressure(voltage, &engineConfiguration->baroSensor);
@ -211,7 +211,7 @@ static void printMAPInfo() {
void initMapDecoder() {
applyConfiguration();
if (CONFIG(useFixedBaroCorrFromMap)) {
if (engineConfiguration->useFixedBaroCorrFromMap) {
// Read initial MAP sensor value and store it for Baro correction.
storedInitialBaroPressure = Sensor::get(SensorType::MapSlow).value_or(101.325);
efiPrintf("Get initial baro MAP pressure = %.2fkPa", storedInitialBaroPressure);

View File

@ -105,7 +105,7 @@ const ADCConversionGroup* getConversionGroup(uint8_t channelIdx) {
}
void onStartKnockSampling(uint8_t cylinderIndex, float samplingSeconds, uint8_t channelIdx) {
if (!CONFIG(enableSoftwareKnock)) {
if (!engineConfiguration->enableSoftwareKnock) {
return;
}
@ -144,8 +144,8 @@ public:
static KnockThread kt;
void initSoftwareKnock() {
if (CONFIG(enableSoftwareKnock)) {
knockFilter.configureBandpass(KNOCK_SAMPLE_RATE, 1000 * CONFIG(knockBandCustom), 3);
if (engineConfiguration->enableSoftwareKnock) {
knockFilter.configureBandpass(KNOCK_SAMPLE_RATE, 1000 * engineConfiguration->knockBandCustom, 3);
adcStart(&KNOCK_ADC, nullptr);
efiSetPadMode("knock ch1", KNOCK_PIN_CH1, PAL_MODE_INPUT_ANALOG);

View File

@ -6,7 +6,7 @@ static OutputPin pins[VR_THRESHOLD_COUNT];
static SimplePwm pwms[VR_THRESHOLD_COUNT];
static void updateVrPwm(int rpm, size_t index) {
auto& cfg = CONFIG(vrThreshold)[index];
auto& cfg = engineConfiguration->vrThreshold[index];
if (cfg.pin == GPIO_UNASSIGNED) {
return;
@ -24,14 +24,14 @@ static void updateVrPwm(int rpm, size_t index) {
void updateVrPwm() {
auto rpm = GET_RPM();
for (size_t i = 0; i < efi::size(CONFIG(vrThreshold)); i++) {
for (size_t i = 0; i < efi::size(engineConfiguration->vrThreshold); i++) {
updateVrPwm(rpm, i);
}
}
void initVrPwm() {
for (size_t i = 0; i < efi::size(CONFIG(vrThreshold)); i++) {
auto& cfg = CONFIG(vrThreshold)[i];
for (size_t i = 0; i < efi::size(engineConfiguration->vrThreshold); i++) {
auto& cfg = engineConfiguration->vrThreshold[i];
if (cfg.pin == GPIO_UNASSIGNED) {
continue;

Some files were not shown because too many files have changed in this diff Show More