From 6b171c97fbd1e407167bf596b05b0841f5d29ddb Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 8 Apr 2020 18:03:46 -0400 Subject: [PATCH] TunerStudio: Save settings with self-simulation fix #1272 --- firmware/controllers/engine_controller.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 13be579b58..5c450b20cc 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -272,12 +272,21 @@ static void doPeriodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engine->rpmCalculator.setStopSpinning(PASS_ENGINE_PARAMETER_SIGNATURE); } - if (engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) { + if (CONFIG(directSelfStimulation) || engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) { + /** + * rusEfi usually runs on hardware which halts execution while writing to internal flash, so we + * postpone writes to until engine is stopped. Writes in case of self-stimulation are fine. + * + * todo: allow writing if 2nd bank of flash is used + */ #if EFI_INTERNAL_FLASH writeToFlashIfPending(); #endif /* EFI_INTERNAL_FLASH */ resetAccel(); - } else { + } + + + if (!engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) { updatePrimeInjectionPulseState(PASS_ENGINE_PARAMETER_SIGNATURE); } @@ -707,6 +716,6 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 20200406; + return 20200408; } #endif /* EFI_UNIT_TEST */