From f3ffecbc2b232f0362add07bbc6c62f0dbe6e807 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 3 Jul 2021 09:43:27 -0400 Subject: [PATCH] Nissan VVT trigger decoder #2887 --- firmware/controllers/algo/engine.cpp | 4 +++- .../controllers/trigger/trigger_central.cpp | 17 ++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 3d4f10d982..5dea000fe0 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -100,8 +100,10 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode) { return TT_FORD_ST170; case VVT_BARRA_3_PLUS_1: return TT_VVT_BARRA_3_PLUS_1; + case VVT_NISSAN_VQ: + return TT_VVT_NISSAN_VQ; default: - return TT_ONE; + firmwareError(OBD_PCM_Processor_Fault, "getVvtTriggerType for %s", getVvt_mode_e(vvtMode)); } } diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index f06d4583da..65d2db38e8 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -87,13 +87,12 @@ angle_t TriggerCentral::getVVTPosition(uint8_t bankIndex, uint8_t camIndex) { #define miataNbIndex (0) -// todo: should we hard-code the list of 'not real decoder' modes instead of adding to list of 'real decoders'? these days we only add 'real decode' modes static bool vvtWithRealDecoder(vvt_mode_e vvtMode) { - return vvtMode == VVT_MIATA_NB2 - || vvtMode == VVT_BOSCH_QUICK_START - || vvtMode == VVT_FORD_ST170 - || vvtMode == VVT_4_1 - || vvtMode == VVT_BARRA_3_PLUS_1; + // todo: why does VVT_2JZ not use real decoder? + return vvtMode != VVT_INACTIVE + && vvtMode != VVT_2JZ + && vvtMode != VVT_SECOND_HALF + && vvtMode != VVT_FIRST_HALF; } void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECLARE_ENGINE_PARAMETER_SUFFIX) { @@ -178,8 +177,8 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL return; } - ENGINE(triggerCentral).vvtState[bankIndex][camIndex].decodeTriggerEvent( - ENGINE(triggerCentral).vvtShape[camIndex], + tc->vvtState[bankIndex][camIndex].decodeTriggerEvent( + tc->vvtShape[camIndex], nullptr, nullptr, engine->vvtTriggerConfiguration[camIndex], @@ -217,7 +216,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL case VVT_BOSCH_QUICK_START: case VVT_BARRA_3_PLUS_1: { - if (engine->triggerCentral.vvtState[bankIndex][camIndex].currentCycle.current_index != 0) { + if (tc->vvtState[bankIndex][camIndex].currentCycle.current_index != 0) { // this is not sync tooth - exiting return; }