From 323904728da6aa05c5a430a94df02dd5b0467794 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 16 Oct 2019 22:29:19 -0400 Subject: [PATCH] Revert "Performance improvement: call GetBaseFuel less (#979)" This reverts commit aa9ec543 --- firmware/controllers/algo/engine.cpp | 6 +++++- firmware/controllers/algo/engine.h | 2 +- firmware/controllers/algo/fuel_math.cpp | 2 +- firmware/controllers/trigger/main_trigger_callback.cpp | 6 ++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index b7a290a6dd..41f0e44b02 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -368,9 +368,13 @@ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engine->m.beforeFuelCalc = getTimeNowLowerNt(); int rpm = GET_RPM(); - + /** + * we have same assignment of 'getInjectionDuration' to 'injectionDuration' in handleFuel() + * Open question why do we refresh that in two places? + */ ENGINE(injectionDuration) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX); engine->m.fuelCalcTime = getTimeNowLowerNt() - engine->m.beforeFuelCalc; + } void doScheduleStopEngine(DECLARE_ENGINE_PARAMETER_SIGNATURE) { diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 5de0986af1..fa12c32967 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -29,7 +29,7 @@ #include "global_execution_queue.h" #endif /* EFI_UNIT_TEST */ -#define FAST_CALLBACK_PERIOD_MS 5 +#define FAST_CALLBACK_PERIOD_MS 20 class RpmCalculator; diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 6de092a976..61b8f1691b 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -220,7 +220,7 @@ int getNumberOfInjections(injection_mode_e mode DECLARE_ENGINE_PARAMETER_SUFFIX) * @see getCoilDutyCycle */ percent_t getInjectorDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { - floatms_t totalInjectiorAmountPerCycle = ENGINE(injectionDuration) * getNumberOfInjections(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER_SUFFIX); + floatms_t totalInjectiorAmountPerCycle = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX) * getNumberOfInjections(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER_SUFFIX); floatms_t engineCycleDuration = getEngineCycleDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX); return 100 * totalInjectiorAmountPerCycle / engineCycleDuration; } diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 90a968ef22..29b8f63883 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -389,6 +389,12 @@ static ALWAYS_INLINE void handleFuel(const bool limitedFuel, uint32_t trgEventIn ENGINE(engineLoadAccelEnrichment.onEngineCycle(PASS_ENGINE_PARAMETER_SIGNATURE)); } + /** + * we have same assignment of 'getInjectionDuration' to 'injectionDuration' in periodicFastCallback() + * Open question why do we refresh that in two places? + */ + ENGINE(injectionDuration) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX); + for (int injEventIndex = 0; injEventIndex < CONFIG(specs.cylindersCount); injEventIndex++) { InjectionEvent *event = &fs->elements[injEventIndex]; uint32_t eventIndex = event->injectionStart.triggerEventIndex;