From e8be471b464b92a23813d625b95bb81ebfac875d Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sun, 29 May 2022 07:42:08 -0700 Subject: [PATCH] bail from trigger_central (#4210) --- firmware/controllers/trigger/trigger_central.cpp | 10 ++++++++++ .../hw_layer/digital_input/trigger/trigger_input.h | 12 ------------ .../digital_input/trigger/trigger_input_exti.cpp | 6 ------ .../digital_input/trigger/trigger_input_icu.cpp | 10 ---------- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index e7c49062de..112cd37739 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -226,6 +226,11 @@ static void logFront(bool isImportantFront, efitick_t nowNt, int index) { } void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) { + if (engine->directSelfStimulation || !engine->hwTriggerInputEnabled) { + // sensor noise + self-stim = loss of trigger sync + return; + } + int bankIndex = index / CAMS_PER_BANK; int camIndex = index % CAMS_PER_BANK; TriggerCentral *tc = &engine->triggerCentral; @@ -412,6 +417,11 @@ void hwHandleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp) { palWritePad(criticalErrorLedPort, criticalErrorLedPin, 0); #endif // VR_HW_CHECK_MODE + if (engine->directSelfStimulation || !engine->hwTriggerInputEnabled) { + // sensor noise + self-stim = loss of trigger sync + return; + } + handleShaftSignal(signalIndex, isRising, timestamp); } diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input.h b/firmware/hw_layer/digital_input/trigger/trigger_input.h index 6b5f061925..5035e3e8c1 100644 --- a/firmware/hw_layer/digital_input/trigger/trigger_input.h +++ b/firmware/hw_layer/digital_input/trigger/trigger_input.h @@ -11,18 +11,6 @@ #include "trigger_structure.h" #include "trigger_central.h" -#define TRIGGER_BAIL_IF_DISABLED \ - if (!engine->hwTriggerInputEnabled) { \ - return; \ - } - -#define TRIGGER_BAIL_IF_SELF_STIM \ - if (engine->directSelfStimulation) { \ - /* sensor noise + self-stim = loss of trigger sync */ \ - return; \ - } - - #define TRIGGER_SUPPORTED_CHANNELS 2 void turnOnTriggerInputPins(); diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input_exti.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input_exti.cpp index e7ac89a380..cd9b2608d2 100644 --- a/firmware/hw_layer/digital_input/trigger/trigger_input_exti.cpp +++ b/firmware/hw_layer/digital_input/trigger/trigger_input_exti.cpp @@ -26,9 +26,6 @@ static ioline_t camLines[CAM_INPUTS_COUNT]; static void shaft_callback(void *arg, efitick_t stamp) { // do the time sensitive things as early as possible! - TRIGGER_BAIL_IF_DISABLED - TRIGGER_BAIL_IF_SELF_STIM - int index = (int)arg; ioline_t pal_line = shaftLines[index]; bool rise = (palReadLine(pal_line) == PAL_HIGH); @@ -40,9 +37,6 @@ static void shaft_callback(void *arg, efitick_t stamp) { } static void cam_callback(void *arg, efitick_t stamp) { - TRIGGER_BAIL_IF_DISABLED - TRIGGER_BAIL_IF_SELF_STIM - int index = (int)arg; ioline_t pal_line = camLines[index]; diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input_icu.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input_icu.cpp index b1d5ca0b76..35e40ad07e 100644 --- a/firmware/hw_layer/digital_input/trigger/trigger_input_icu.cpp +++ b/firmware/hw_layer/digital_input/trigger/trigger_input_icu.cpp @@ -25,8 +25,6 @@ int icuFallingCallbackCounter = 0; static void vvtRisingCallback(void *arg) { efitick_t now = getTimeNowNt(); - TRIGGER_BAIL_IF_DISABLED - TRIGGER_BAIL_IF_SELF_STIM int index = (int)arg; @@ -41,8 +39,6 @@ static void vvtRisingCallback(void *arg) { static void vvtFallingCallback(void * arg) { efitick_t now = getTimeNowNt(); - TRIGGER_BAIL_IF_DISABLED - TRIGGER_BAIL_IF_SELF_STIM int index = (int)arg; #if EFI_TOOTH_LOGGER @@ -59,9 +55,6 @@ static void vvtFallingCallback(void * arg) { static void shaftRisingCallback(bool isPrimary) { efitick_t stamp = getTimeNowNt(); - TRIGGER_BAIL_IF_DISABLED - TRIGGER_BAIL_IF_SELF_STIM - icuRisingCallbackCounter++; // icucnt_t last_width = icuGetWidth(icup); so far we are fine with system time @@ -72,9 +65,6 @@ static void shaftRisingCallback(bool isPrimary) { static void shaftFallingCallback(bool isPrimary) { efitick_t stamp = getTimeNowNt(); - TRIGGER_BAIL_IF_DISABLED - TRIGGER_BAIL_IF_SELF_STIM - icuFallingCallbackCounter++; hwHandleShaftSignal(isPrimary ? 0 : 1, false, stamp);