From a1421a45db8dea7f0841dc0e8ab8a44fe78165ce Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 21 Apr 2017 14:03:08 -0400 Subject: [PATCH] refactoring - following the pattern --- .../controllers/trigger/trigger_emulator_algo.cpp | 4 ++-- firmware/development/engine_emulator.cpp | 15 +++++++++------ firmware/development/trigger_emulator.cpp | 6 +++--- firmware/development/trigger_emulator.h | 4 ++-- simulator/simulator/rusEfiFunctionalTest.cpp | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index 25e64edc4d..1565c56e40 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -101,7 +101,7 @@ static LocalVersionHolder emulatorConfigVersion; extern WaveChart waveChart; #endif /* EFI_ENGINE_SNIFFER */ -void setTriggerEmulatorRPM(int rpm, Engine *engine) { +void setTriggerEmulatorRPM(int rpm DECLARE_ENGINE_PARAMETER_S) { engineConfiguration->bc.triggerSimulatorFrequency = rpm; /** * All we need to do here is to change the periodMs @@ -170,7 +170,7 @@ void initTriggerEmulatorLogic(Logging *sharedLogger, Engine *engine) { logger = sharedLogger; TriggerShape *s = &engine->triggerCentral.triggerShape; - setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency, engine); + setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency PASS_ENGINE_PARAMETER); pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates, s->wave.waves[2].pinStates }; triggerSignal.weComplexInit("position sensor", s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM, diff --git a/firmware/development/engine_emulator.cpp b/firmware/development/engine_emulator.cpp index 05dacc865b..4f9ea244ec 100644 --- a/firmware/development/engine_emulator.cpp +++ b/firmware/development/engine_emulator.cpp @@ -34,7 +34,9 @@ void setDiag(int value) { #define PERIOD 3000 -void emulate(Engine *engine) { +EXTERN_ENGINE; + +static void emulate(void) { print("Emulating...\r\n"); setDiag(1); chThdSleep(1); @@ -43,11 +45,11 @@ void emulate(Engine *engine) { for (int i = 400; i <= 1300; i++) { if (i % 50 != 0) continue; - setTriggerEmulatorRPM(i, engine); + setTriggerEmulatorRPM(i PASS_ENGINE_PARAMETER); chThdSleepMilliseconds(PERIOD); } - setTriggerEmulatorRPM(0, engine); + setTriggerEmulatorRPM(0 PASS_ENGINE_PARAMETER); setFullLog(0); setDiag(0); @@ -57,14 +59,15 @@ void emulate(Engine *engine) { static int flag = FALSE; -static msg_t eeThread(Engine *engine) { +static msg_t eeThread(void *arg) { + (void)arg; chRegSetThreadName("Engine"); while (TRUE) { while (!flag) chThdSleepMilliseconds(200); flag = FALSE; - emulate(engine); + emulate(); } #if defined __GNUC__ return (msg_t)NULL; @@ -102,5 +105,5 @@ void initEngineEmulator(Logging *sharedLogger, Engine *engine) { #endif /* EFI_POTENTIOMETER */ //initECUstimulator(); - initTriggerEmulator(sharedLogger, engine); + initTriggerEmulator(sharedLogger PASS_ENGINE_PARAMETER); } diff --git a/firmware/development/trigger_emulator.cpp b/firmware/development/trigger_emulator.cpp index ef8b10e482..905448499e 100644 --- a/firmware/development/trigger_emulator.cpp +++ b/firmware/development/trigger_emulator.cpp @@ -27,10 +27,10 @@ extern PwmConfig triggerSignal; static OutputPin emulatorOutputs[3]; -void initTriggerEmulator(Logging *sharedLogger, Engine *engine) { +EXTERN_ENGINE; + +void initTriggerEmulator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) { - engine_configuration_s *engineConfiguration = engine->engineConfiguration; - board_configuration_s *boardConfiguration = &engineConfiguration->bc; #if EFI_EMULATE_POSITION_SENSORS || defined(__DOXYGEN__) print("Emulating %s\r\n", getConfigurationName(engineConfiguration->engineType)); diff --git a/firmware/development/trigger_emulator.h b/firmware/development/trigger_emulator.h index 97310a7845..82363d513e 100644 --- a/firmware/development/trigger_emulator.h +++ b/firmware/development/trigger_emulator.h @@ -14,7 +14,7 @@ #include "trigger_structure.h" #include "engine.h" -void initTriggerEmulator(Logging *sharedLogger, Engine *engine); -void setTriggerEmulatorRPM(int value, Engine *engine); +void initTriggerEmulator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S); +void setTriggerEmulatorRPM(int value DECLARE_ENGINE_PARAMETER_S); #endif /* DIST_EMULATOR_H_ */ diff --git a/simulator/simulator/rusEfiFunctionalTest.cpp b/simulator/simulator/rusEfiFunctionalTest.cpp index f9651ec08f..4d884524d9 100644 --- a/simulator/simulator/rusEfiFunctionalTest.cpp +++ b/simulator/simulator/rusEfiFunctionalTest.cpp @@ -116,7 +116,7 @@ void rusEfiFunctionalTest(void) { initTriggerCentral(&sharedLogger, engine); - initTriggerEmulator(&sharedLogger, engine); + initTriggerEmulator(&sharedLogger PASS_ENGINE_PARAMETER); #if EFI_MAP_AVERAGING || defined(__DOXYGEN__) initMapAveraging(&sharedLogger, engine); @@ -130,7 +130,7 @@ void rusEfiFunctionalTest(void) { initPeriodicEvents(PASS_ENGINE_PARAMETER_F); - setTriggerEmulatorRPM(DEFAULT_SIM_RPM, engine); + setTriggerEmulatorRPM(DEFAULT_SIM_RPM PASS_ENGINE_PARAMETER); engineConfiguration->engineSnifferRpmThreshold = DEFAULT_SNIFFER_THR; }