From c0e9d2914b51e9d5eef24a97dc48aea1482fa4d4 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 26 Jan 2021 21:43:23 -0500 Subject: [PATCH] M62T vanos support #2243 --- firmware/controllers/engine_controller.cpp | 9 +++++---- firmware/controllers/trigger/trigger_central.cpp | 4 ++-- firmware/controllers/trigger/trigger_central.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 5c3c33ebe6..f5733a7828 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -225,10 +225,11 @@ static void doPeriodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { efitick_t nowNt = getTimeNowNt(); - - if (nowNt - engine->triggerCentral.vvtSyncTimeNt >= NT_PER_SECOND) { - // loss of VVT sync - engine->triggerCentral.vvtSyncTimeNt = 0; + for (int bankIndex = 0; bankIndex < BANKS_COUNT; bankIndex++) { + if (nowNt - engine->triggerCentral.vvtSyncTimeNt[bankIndex] >= NT_PER_SECOND) { + // loss of VVT sync + engine->triggerCentral.vvtSyncTimeNt[bankIndex] = 0; + } } // for performance reasons this assertion related to mainTriggerCallback should better be here diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 99c14ce703..a3344fdb58 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -47,7 +47,7 @@ WaveChart waveChart; trigger_central_s::trigger_central_s() : hwEventCounters() { } -TriggerCentral::TriggerCentral() : trigger_central_s() { +TriggerCentral::TriggerCentral() : trigger_central_s(), vvtSyncTimeNt() { triggerState.resetTriggerState(); noiseFilter.resetAccumSignalData(); } @@ -210,7 +210,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt DECLARE_ENGINE_ break; } - tc->vvtSyncTimeNt = nowNt; + tc->vvtSyncTimeNt[bankIndex] = nowNt; // we do NOT clamp VVT position into the [0, engineCycle) range - we expect vvtOffset to be configured so that // it's not necessary diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 0efa0b6b49..b699a8601b 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -64,7 +64,7 @@ public: */ efitick_t timeAtVirtualZeroNt = 0; - efitick_t vvtSyncTimeNt = 0; + efitick_t vvtSyncTimeNt[BANKS_COUNT]; TriggerStateWithRunningStatistics triggerState; TriggerWaveform triggerShape;