diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index d68451eb7f..1e293a116e 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -315,6 +315,7 @@ void Engine::watchdog() { void Engine::prepareFuelSchedule(DECLARE_ENGINE_PARAMETER_F) { int rpm = rpmCalculator.rpmValue; + efiAssertVoid(ENGINE(engineConfiguration2)->injectionEvents != ENGINE(engineConfiguration2)->processing, "fuel pointers"); ENGINE(m.beforeInjectonSch) = GET_TIMESTAMP(); diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 45208c2ae7..e58d486fdd 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -70,9 +70,18 @@ public: engine_configuration2_s(); #if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) + /** + * Lock-free multithreading: two instances, while one is being modified another one is used read-only + */ FuelSchedule injectionEvents0; FuelSchedule injectionEvents1; + /** + * this points at an instance we use to run the engine + */ FuelSchedule *injectionEvents; + /** + * this variable is pointing at the instance which is being modified + */ FuelSchedule *processing; #endif diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index fb3e22a2a0..5cb8bc75a8 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -915,8 +915,8 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN } engine_configuration2_s::engine_configuration2_s() { - injectionEvents = &injectionEvents0; - processing = &injectionEvents0; + injectionEvents = &injectionEvents0; + processing = &injectionEvents1; } void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S) { diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index a235b45ac6..306651654b 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -156,6 +156,7 @@ void setFsio(int index, brain_pin_e pin, const char * exp DECLARE_ENGINE_PARAMET } void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_F) { + userPool.reset(); for (int i = 0; i < LE_COMMAND_COUNT; i++) { brain_pin_e brainPin = boardConfiguration->fsioPins[i];