From 0232c7cffeff9add66a81c0f36a91b3c689ead90 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 24 Nov 2014 17:04:41 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/algo/engine.h | 2 ++ firmware/controllers/trigger/main_trigger_callback.cpp | 7 +++++-- firmware/controllers/trigger/trigger_central.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 24eae247e1..06fa2b41bf 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -54,6 +54,8 @@ public: */ bool isCylinderCleanupMode; + uint32_t ignitionMathTime; + void updateSlowSensors(); void watchdog(); diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index df7e40c860..b0c2e6b583 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -53,6 +53,7 @@ #include "LocalVersionHolder.h" #include "event_queue.h" #include "engine.h" +#include "efilib2.h" EXTERN_ENGINE ; @@ -313,7 +314,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng warning(OBD_Camshaft_Position_Sensor_Circuit_Range_Performance, "noisy trigger"); return; } - if (rpm > engine->engineConfiguration->rpmHardLimit) { + if (rpm > engineConfiguration->rpmHardLimit) { warning(OBD_PCM_Processor_Fault, "skipping stroke due to rpm=%d", rpm); return; } @@ -327,6 +328,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng if (eventIndex == 0) { if (localVersion.isOld()) prepareOutputSignals(engine); + uint32_t beforeIgnitionMath = GET_TIMESTAMP(); /** * TODO: warning. there is a bit of a hack here, todo: improve. @@ -366,8 +368,9 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng // todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that - initializeIgnitionActions(fixAngle(-advance PASS_ENGINE_PARAMETER), dwellAngle, + initializeIgnitionActions(-advance, dwellAngle, &engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER); + engine->ignitionMathTime = GET_TIMESTAMP() - beforeIgnitionMath; } triggerEventsQueue.executeAll(getCrankEventCounter()); diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 26ecdff2d1..343150611a 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -217,7 +217,7 @@ static void triggerInfo(Engine *engine) { scheduleMsg(&logger, "Template %s/%d trigger %d", getConfigurationName(engineConfiguration->engineType), engineConfiguration->engineType, engineConfiguration->triggerConfig.triggerType); - scheduleMsg(&logger, "sn=%d", ts->isSynchronizationNeeded); + scheduleMsg(&logger, "sn=%d ignitionMathTime=%d", ts->isSynchronizationNeeded, engine->ignitionMathTime); scheduleMsg(&logger, "trigger event counters %d/%d/%d/%d", triggerCentral.getHwEventCounter(0), triggerCentral.getHwEventCounter(1), triggerCentral.getHwEventCounter(2),