diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 6839c92f42..201ab80fb9 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -7,11 +7,13 @@ */ #include "global.h" +#include "engine_configuration.h" +#include "engine_math.h" + #if !EFI_UNIT_TEST #include "os_access.h" #include "settings.h" #include "eficonsole.h" -#include "engine_configuration.h" #include "adc_inputs.h" #include "engine_controller.h" #include "thermistors.h" @@ -22,7 +24,6 @@ #include "console_io.h" #include "engine.h" #include "efi_gpio.h" -#include "engine_math.h" #include "idle_thread.h" #include "allsensors.h" #include "alternator_controller.h" @@ -183,22 +184,6 @@ static void setTimingMode(int value) { incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } -void setEngineType(int value DECLARE_ENGINE_PARAMETER_SUFFIX) { - { - chibios_rt::CriticalSectionLocker csl; - - engineConfiguration->engineType = (engine_type_e)value; - resetConfigurationExt((engine_type_e)value PASS_ENGINE_PARAMETER_SUFFIX); - engine->resetEngineSnifferIfInTestMode(); - - #if EFI_INTERNAL_FLASH - writeToFlashNow(); - #endif /* EFI_INTERNAL_FLASH */ - } - incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); - doPrintConfiguration(); -} - static void setIdleSolenoidFrequency(int value) { engineConfiguration->idle.solenoidFrequency = value; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -1372,3 +1357,23 @@ const char* getConfigurationName(engine_type_e engineType) { return getEngine_type_e(engineType); } } + +void setEngineType(int value DECLARE_ENGINE_PARAMETER_SUFFIX) { + { +#if EFI_PROD_CODE + chibios_rt::CriticalSectionLocker csl; +#endif /* EFI_PROD_CODE */ + + engineConfiguration->engineType = (engine_type_e)value; + resetConfigurationExt((engine_type_e)value PASS_ENGINE_PARAMETER_SUFFIX); + engine->resetEngineSnifferIfInTestMode(); + + #if EFI_INTERNAL_FLASH + writeToFlashNow(); + #endif /* EFI_INTERNAL_FLASH */ + } + incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); +#if ! EFI_UNIT_TEST + doPrintConfiguration(); +#endif /* EFI_UNIT_TEST */ +} diff --git a/unit_tests/tests/test_change_engine_type.cpp b/unit_tests/tests/test_change_engine_type.cpp index 34a3c6cd4f..2ad20724fe 100644 --- a/unit_tests/tests/test_change_engine_type.cpp +++ b/unit_tests/tests/test_change_engine_type.cpp @@ -6,9 +6,11 @@ */ #include "engine_test_helper.h" +#include "settings.h" TEST(misc, changeEngineType) { WITH_ENGINE_TEST_HELPER (FORD_ASPIRE_1996); + setEngineType((int)CITROEN_TU3JP PASS_ENGINE_PARAMETER_SUFFIX); }