From 66b091a5a5bc62da1c0a6c4ea7a8686b7c6fcfb6 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 25 Jun 2021 11:30:06 -0400 Subject: [PATCH] Trigger: warning code on normal engine start up #669 making more code unit-testable --- firmware/controllers/trigger/trigger_central.cpp | 11 ++++++----- firmware/controllers/trigger/trigger_central.h | 2 +- .../controllers/trigger/trigger_emulator_algo.cpp | 4 ++-- firmware/controllers/trigger/trigger_emulator_algo.h | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index e8087cc5e8..bfce24f636 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -286,13 +286,13 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL } -#if EFI_PROD_CODE || EFI_SIMULATOR - int triggerReentraint = 0; int maxTriggerReentraint = 0; uint32_t triggerDuration; uint32_t triggerMaxDuration = 0; +#if EFI_PROD_CODE || EFI_SIMULATOR + /** * this method is invoked only by real hardware call-backs */ @@ -317,14 +317,16 @@ void hwHandleShaftSignal(trigger_event_e signal, efitick_t timestamp) { palWritePad(criticalErrorLedPort, criticalErrorLedPin, 0); #endif // VR_HW_CHECK_MODE - handleShaftSignal(signal, timestamp); + handleShaftSignal2(signal, timestamp); } +#endif /* EFI_PROD_CODE */ + /** * this method is invoked by both real hardware and self-stimulator */ -void handleShaftSignal(trigger_event_e signal, efitick_t timestamp) { +void handleShaftSignal2(trigger_event_e signal, efitick_t timestamp DECLARE_ENGINE_PARAMETER_SUFFIX) { ScopePerf perf(PE::HandleShaftSignal); // Don't accept trigger input in case of some problems @@ -380,7 +382,6 @@ void handleShaftSignal(trigger_event_e signal, efitick_t timestamp) { triggerDuration = getTimeNowLowerNt() - triggerHandlerEntryTime; triggerMaxDuration = maxI(triggerMaxDuration, triggerDuration); } -#endif /* EFI_PROD_CODE */ void TriggerCentral::resetCounters() { memset(hwEventCounters, 0, sizeof(hwEventCounters)); diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 550b152230..615b165526 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -86,7 +86,7 @@ public: }; void triggerInfo(void); -void handleShaftSignal(trigger_event_e signal, efitick_t timestamp); +void handleShaftSignal2(trigger_event_e signal, efitick_t timestamp DECLARE_ENGINE_PARAMETER_SUFFIX); void hwHandleShaftSignal(trigger_event_e signal, efitick_t timestamp); void hwHandleVvtCamSignal(trigger_value_e front, efitick_t timestamp, int index DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index 7d4b0096a8..eadc932ee8 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -47,7 +47,7 @@ EXTERN_ENGINE; static OutputPin emulatorOutputs[PWM_PHASE_MAX_WAVE_PER_PWM]; -void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIndex) { +void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIndex DECLARE_ENGINE_PARAMETER_SUFFIX) { efitick_t stamp = getTimeNowNt(); // todo: code duplication with TriggerStimulatorHelper::feedSimulatedEvent? @@ -62,7 +62,7 @@ void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIn trigger_event_e event = (currentValue ? riseEvents : fallEvents)[i]; - handleShaftSignal(event, stamp); + handleShaftSignal2(event, stamp PASS_ENGINE_PARAMETER_SUFFIX); } } } diff --git a/firmware/controllers/trigger/trigger_emulator_algo.h b/firmware/controllers/trigger/trigger_emulator_algo.h index c75d354542..b369e7c95a 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.h +++ b/firmware/controllers/trigger/trigger_emulator_algo.h @@ -26,7 +26,7 @@ void disableTriggerStimulator(); class TriggerEmulatorHelper { public: TriggerEmulatorHelper(); - void handleEmulatorCallback(PwmConfig *state, int stateIndex); + void handleEmulatorCallback(PwmConfig *state, int stateIndex DECLARE_ENGINE_PARAMETER_SUFFIX); }; void initTriggerEmulatorLogic(DECLARE_ENGINE_PARAMETER_SIGNATURE);