From 154b679491e3080301b8c92291d54ae4d8c9da1a Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 26 Jan 2020 03:48:25 -0500 Subject: [PATCH] refactoring: de-coupling trigger decoder and engine --- firmware/controllers/algo/engine.cpp | 2 +- firmware/controllers/engine_controller.cpp | 2 +- firmware/controllers/trigger/trigger_decoder.cpp | 14 +++++++------- firmware/controllers/trigger/trigger_decoder.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 87102b9e27..901911da5c 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -279,7 +279,7 @@ void Engine::OnTriggerSyncronization(bool wasSynchronized) { /** * We can check if things are fine by comparing the number of events in a cycle with the expected number of event. */ - bool isDecodingError = triggerCentral.triggerState.validateEventCounters(PASS_ENGINE_PARAMETER_SIGNATURE); + bool isDecodingError = triggerCentral.triggerState.validateEventCounters(&triggerCentral.triggerShape); enginePins.triggerDecoderErrorPin.setValue(isDecodingError); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index ea157f2069..68e6537881 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -839,6 +839,6 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 201200125; + return 201200126; } #endif /* EFI_UNIT_TEST */ diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index eff2ae794f..47424efdd6 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -331,17 +331,17 @@ void TriggerState::onSynchronizationLost(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engine->rpmCalculator.setStopSpinning(PASS_ENGINE_PARAMETER_SIGNATURE); } -bool TriggerState::validateEventCounters(DECLARE_ENGINE_PARAMETER_SIGNATURE) const { - bool isDecodingError = currentCycle.eventCount[0] != TRIGGER_WAVEFORM(expectedEventCount[0]) - || currentCycle.eventCount[1] != TRIGGER_WAVEFORM(expectedEventCount[1]) - || currentCycle.eventCount[2] != TRIGGER_WAVEFORM(expectedEventCount[2]); +bool TriggerState::validateEventCounters(TriggerWaveform *triggerShape) const { + bool isDecodingError = currentCycle.eventCount[0] != triggerShape->expectedEventCount[0] + || currentCycle.eventCount[1] != triggerShape->expectedEventCount[1] + || currentCycle.eventCount[2] != triggerShape->expectedEventCount[2]; #if EFI_UNIT_TEST printf("sync point: isDecodingError=%d\r\n", isDecodingError); if (isDecodingError) { - printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[0], TRIGGER_WAVEFORM(expectedEventCount[0])); - printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[1], TRIGGER_WAVEFORM(expectedEventCount[1])); - printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[2], TRIGGER_WAVEFORM(expectedEventCount[2])); + printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[0], triggerShape->expectedEventCount[0]); + printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[1], triggerShape->expectedEventCount[1]); + printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[2], triggerShape->expectedEventCount[2]); } #endif /* EFI_UNIT_TEST */ diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index 6f78a88f7d..b9296c26cb 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -71,7 +71,7 @@ public: TriggerStateListener * triggerStateListener, trigger_event_e const signal, efitime_t nowUs DECLARE_CONFIG_PARAMETER_SUFFIX); - bool validateEventCounters(DECLARE_ENGINE_PARAMETER_SIGNATURE) const; + bool validateEventCounters(TriggerWaveform *triggerShape) const; void handleTriggerError(DECLARE_ENGINE_PARAMETER_SIGNATURE); void onShaftSynchronization(const TriggerStateCallback triggerCycleCallback, efitick_t nowNt, trigger_wheel_e triggerWheel, TriggerWaveform *triggerShape);