From 9237c4b16a11027bdf5551d779f08eed68250173 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 5 Nov 2023 12:09:25 -0500 Subject: [PATCH] better EFI_ENGINE_CONTROL --- firmware/controllers/can/can_dash.cpp | 4 ++++ firmware/controllers/can/can_dash_ms.cpp | 2 ++ firmware/controllers/can/can_rx.cpp | 3 ++- firmware/controllers/can/can_verbose.cpp | 8 ++++++-- firmware/controllers/core/error_handling.cpp | 2 ++ firmware/controllers/sensors/sensor_checker.cpp | 2 ++ 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/can/can_dash.cpp b/firmware/controllers/can/can_dash.cpp index e77655590e..59ce2dc6c1 100644 --- a/firmware/controllers/can/can_dash.cpp +++ b/firmware/controllers/can/can_dash.cpp @@ -578,6 +578,7 @@ void canDashboardHaltech(CanCycle cycle) { msg[7] = 0; } +#if EFI_ENGINE_CONTROL /* 0x362 - 50Hz rate */ { CanTxMessage msg(CanCategory::NBC, 0x362, 6); @@ -595,6 +596,7 @@ void canDashboardHaltech(CanCycle cycle) { msg[4] = (ignAngle >> 8); msg[5] = (ignAngle & 0x00ff); } +#endif // EFI_ENGINE_CONTROL /* todo: 0x3E5 = 50Hz rate */ { @@ -1233,12 +1235,14 @@ struct Aim5f7 { }; static void populateFrame(Aim5f7& msg) { +#if EFI_ENGINE_CONTROL // We don't handle wheel speed, just set to 0? msg.LambdaErr1 = 0; msg.LambdaErr2 = 0; // both targets are the same for now msg.LambdaTarget1 = (float)engine->fuelComputer.targetLambda; msg.LambdaTarget2 = (float)engine->fuelComputer.targetLambda; +#endif // EFI_ENGINE_CONTROL } void canDashboardAim(CanCycle cycle) { diff --git a/firmware/controllers/can/can_dash_ms.cpp b/firmware/controllers/can/can_dash_ms.cpp index 98b64426f2..65d6da7143 100644 --- a/firmware/controllers/can/can_dash_ms.cpp +++ b/firmware/controllers/can/can_dash_ms.cpp @@ -68,6 +68,7 @@ struct ms1514 { static void populateFrame(ms1514& msg) { +#if EFI_ENGINE_CONTROL msg.afrtgt1 = (float)engine->fuelComputer.targetLambda * STOICH_RATIO; msg.AFR1 = Sensor::getOrZero(SensorType::Lambda1) * STOICH_RATIO; /* TODO: banks? */ @@ -75,6 +76,7 @@ static void populateFrame(ms1514& msg) /* TODO */ msg.egt1 = 0; msg.pwseq1 = engine->engineState.injectionDuration; +#endif // EFI_ENGINE_CONTROL } struct ms1515 { diff --git a/firmware/controllers/can/can_rx.cpp b/firmware/controllers/can/can_rx.cpp index 90ef9cf3c6..45734798a6 100644 --- a/firmware/controllers/can/can_rx.cpp +++ b/firmware/controllers/can/can_rx.cpp @@ -197,11 +197,12 @@ void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick obdOnCanPacketRx(frame, busIndex); } +#if EFI_ENGINE_CONTROL if (CAN_EID(frame) == GDI4_BASE_ADDRESS && frame.data8[7] == GDI4_MAGIC) { // efiPrintf("CAN GDI4 says hi"); getLimpManager()->gdiComms.reset(); } - +#endif // EFI_ENGINE_CONTROL #if EFI_WIDEBAND_FIRMWARE_UPDATE // Bootloader acks with address 0x727573 aka ascii "rus" diff --git a/firmware/controllers/can/can_verbose.cpp b/firmware/controllers/can/can_verbose.cpp index 852072aa31..55fe2c49a2 100644 --- a/firmware/controllers/can/can_verbose.cpp +++ b/firmware/controllers/can/can_verbose.cpp @@ -46,7 +46,9 @@ static void populateFrame(Status& msg) { msg.fuelPump = enginePins.fuelPumpRelay.getLogicValue(); msg.checkEngine = enginePins.checkEnginePin.getLogicValue(); msg.o2Heater = enginePins.o2heater.getLogicValue(); +#if EFI_ENGINE_CONTROL msg.lambdaProtectActive = engine->lambdaMonitor.isCut(); +#endif // EFI_ENGINE_CONTROL msg.fan = enginePins.fanRelay.getLogicValue(); msg.fan2 = enginePins.fanRelay2.getLogicValue(); @@ -71,10 +73,10 @@ static void populateFrame(Speeds& msg) { auto timing = engine->engineState.timingAdvance[0]; msg.timing = timing > 360 ? timing - 720 : timing; - +#if EFI_ENGINE_CONTROL msg.injDuty = getInjectorDutyCycle(rpm); msg.coilDuty = getCoilDutyCycle(rpm); - +#endif // EFI_ENGINE_CONTROL msg.vssKph = Sensor::getOrZero(SensorType::VehicleSpeed); msg.EthanolPercent = Sensor::getOrZero(SensorType::FuelEthanolPercent); @@ -145,10 +147,12 @@ struct Fueling { }; static void populateFrame(Fueling& msg) { +#if EFI_ENGINE_CONTROL msg.cylAirmass = engine->fuelComputer.sdAirMassInOneCylinder; msg.estAirflow = engine->engineState.airflowEstimate; msg.fuel_pulse = (float)engine->outputChannels.actualLastInjection; msg.knockCount = engine->module()->getKnockCount(); +#endif // EFI_ENGINE_CONTROL } struct Fueling2 { diff --git a/firmware/controllers/core/error_handling.cpp b/firmware/controllers/core/error_handling.cpp index d9096a7855..97800b95e9 100644 --- a/firmware/controllers/core/error_handling.cpp +++ b/firmware/controllers/core/error_handling.cpp @@ -258,7 +258,9 @@ void firmwareError(ObdCode code, const char *fmt, ...) { #if EFI_PROD_CODE if (hasFirmwareErrorFlag) return; +#if EFI_ENGINE_CONTROL getLimpManager()->fatalError(); +#endif // EFI_ENGINE_CONTROL engine->engineState.warnings.addWarningCode(code); #ifdef EFI_PRINT_ERRORS_AS_WARNINGS { diff --git a/firmware/controllers/sensors/sensor_checker.cpp b/firmware/controllers/sensors/sensor_checker.cpp index 49ad715bcd..cd4497078e 100644 --- a/firmware/controllers/sensors/sensor_checker.cpp +++ b/firmware/controllers/sensors/sensor_checker.cpp @@ -177,6 +177,7 @@ void SensorChecker::onSlowCallback() { // only bother checking these if we have GPIO chips actually capable of reporting an error #if BOARD_EXT_GPIOCHIPS > 0 && EFI_PROD_CODE // Check injectors +#if EFI_ENGINE_CONTROL bool withInjectorIssues = false; for (size_t i = 0; i < efi::size(enginePins.injectors); i++) { InjectorOutputPin& pin = enginePins.injectors[i]; @@ -197,6 +198,7 @@ void SensorChecker::onSlowCallback() { } } engine->fuelComputer.injectorHwIssue = withInjectorIssues; +#endif // EFI_ENGINE_CONTROL // Check ignition for (size_t i = 0; i < efi::size(enginePins.injectors); i++) {