From 6b2d542455ef98bed1c78add50db76d9611df7e8 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 10 Nov 2014 13:06:23 -0600 Subject: [PATCH] auto-sync --- firmware/.cproject | 1 + firmware/Makefile | 3 +- firmware/config/engines/bmw_e34.cpp | 4 ++ firmware/controllers/settings.cpp | 43 ++++++++++--------- .../system/SingleTimerExecutor.cpp | 18 ++++---- .../system/pwm_generator_logic.cpp | 2 +- .../controllers/trigger/trigger_central.cpp | 18 ++++++-- firmware/svnversion.h | 4 +- 8 files changed, 57 insertions(+), 36 deletions(-) diff --git a/firmware/.cproject b/firmware/.cproject index 64ff352e68..32080a898e 100644 --- a/firmware/.cproject +++ b/firmware/.cproject @@ -209,6 +209,7 @@ + diff --git a/firmware/Makefile b/firmware/Makefile index dd4f5e4c1b..a23a35075e 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -8,7 +8,8 @@ CHIBIOS = chibios # Compiler options here. ifeq ($(USE_OPT),) - USE_OPT = $(RFLAGS) -O1 -fgnu89-inline -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers +# USE_OPT = $(RFLAGS) -O1 -fgnu89-inline -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers + USE_OPT = $(RFLAGS) -O1 -fgnu89-inline -fomit-frame-pointer -falign-functions=16 -std=gnu99 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers endif # C specific options here (added to USE_OPT). diff --git a/firmware/config/engines/bmw_e34.cpp b/firmware/config/engines/bmw_e34.cpp index 86e5fc97a9..ef1478a035 100644 --- a/firmware/config/engines/bmw_e34.cpp +++ b/firmware/config/engines/bmw_e34.cpp @@ -24,6 +24,10 @@ void setBmwE43(engine_configuration_s *engineConfiguration) { engineConfiguration->injectionMode = IM_SIMULTANEOUS; engineConfiguration->ignitionMode = IM_WASTED_SPARK; + // emulating this 60-0 takes some resources, let's keep it slow by default + // rpm 200 + boardConfiguration->triggerSimulatorFrequency = 200; + setConstantDwell(engineConfiguration, 3); // a bit shorter dwell engineConfiguration->useConstantDwellDuringCranking = true; engineConfiguration->ignitionDwellForCrankingMs = 5; diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 4544f318c5..b031322806 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -62,6 +62,28 @@ void printSpiState(Logging *logger, board_configuration_s *boardConfiguration) { extern board_configuration_s *boardConfiguration; +static void printOutputs(engine_configuration_s *engineConfiguration, engine_configuration2_s *engineConfiguration2) { + scheduleMsg(&logger, "injectionPins: mode %s", pinModeToString(boardConfiguration->injectionPinMode)); + for (int i = 0; i < engineConfiguration->cylindersCount; i++) { + brain_pin_e brainPin = boardConfiguration->injectionPins[i]; + scheduleMsg(&logger, "injection #%d @ %s", (1 + i), hwPortname(brainPin)); + } + + scheduleMsg(&logger, "ignitionPins: mode %s", pinModeToString(boardConfiguration->ignitionPinMode)); + for (int i = 0; i < engineConfiguration->cylindersCount; i++) { + brain_pin_e brainPin = boardConfiguration->ignitionPins[i]; + scheduleMsg(&logger, "ignition #%d @ %s", (1 + i), hwPortname(brainPin)); + } + + scheduleMsg(&logger, "idlePin: mode %s @ %s freq=%d", getPin_output_mode_e(boardConfiguration->idleValvePinMode), + hwPortname(boardConfiguration->idleValvePin), boardConfiguration->idleSolenoidFrequency); + scheduleMsg(&logger, "malfunctionIndicatorn: %s mode=%s", hwPortname(boardConfiguration->malfunctionIndicatorPin), + pinModeToString(boardConfiguration->malfunctionIndicatorPinMode)); + + scheduleMsg(&logger, "fuelPumpPin: mode %s @ %s", getPin_output_mode_e(boardConfiguration->fuelPumpPinMode), + hwPortname(boardConfiguration->fuelPumpPin)); +} + /** * @brief Prints current engine configuration to human-readable console. */ @@ -133,26 +155,7 @@ void printConfiguration(engine_configuration_s *engineConfiguration, engine_conf scheduleMsg(&logger, "analogInputDividerCoefficient: %f", engineConfiguration->analogInputDividerCoefficient); - scheduleMsg(&logger, "idlePin: mode %s @ %s freq=%d", getPin_output_mode_e(boardConfiguration->idleValvePinMode), - hwPortname(boardConfiguration->idleValvePin), boardConfiguration->idleSolenoidFrequency); - scheduleMsg(&logger, "malfunctionIndicatorn: %s mode=%s", hwPortname(boardConfiguration->malfunctionIndicatorPin), - pinModeToString(boardConfiguration->malfunctionIndicatorPinMode)); - - scheduleMsg(&logger, "fuelPumpPin: mode %s @ %s", getPin_output_mode_e(boardConfiguration->fuelPumpPinMode), - hwPortname(boardConfiguration->fuelPumpPin)); - - scheduleMsg(&logger, "injectionPins: mode %s", pinModeToString(boardConfiguration->injectionPinMode)); - for (int i = 0; i < engineConfiguration->cylindersCount; i++) { - brain_pin_e brainPin = boardConfiguration->injectionPins[i]; - - scheduleMsg(&logger, "injection #%d @ %s", (1 + i), hwPortname(brainPin)); - } - - scheduleMsg(&logger, "ignitionPins: mode %s", pinModeToString(boardConfiguration->ignitionPinMode)); - for (int i = 0; i < engineConfiguration->cylindersCount; i++) { - brain_pin_e brainPin = boardConfiguration->ignitionPins[i]; - scheduleMsg(&logger, "ignition #%d @ %s", (1 + i), hwPortname(brainPin)); - } + printOutputs(engineConfiguration, engineConfiguration2); scheduleMsg(&logger, "boardTestModeJumperPin: %s", hwPortname(boardConfiguration->boardTestModeJumperPin)); diff --git a/firmware/controllers/system/SingleTimerExecutor.cpp b/firmware/controllers/system/SingleTimerExecutor.cpp index fbe0b6d84a..476f677817 100644 --- a/firmware/controllers/system/SingleTimerExecutor.cpp +++ b/firmware/controllers/system/SingleTimerExecutor.cpp @@ -35,6 +35,7 @@ static void executorCallback(void *arg) { Executor::Executor() { reentrantLock = false; + queue.setLateDelay(US2NT(100)); } void Executor::lock(void) { @@ -59,7 +60,7 @@ void Executor::schedule2(const char *prefix, scheduling_s *scheduling, uint64_t // this would guard the queue and disable interrupts lock(); } - queue.insertTask(scheduling, timeUs, callback, param); + queue.insertTask(scheduling, US2NT(timeUs), callback, param); if (!reentrantLock) { doExecute(); unlock(); @@ -97,14 +98,14 @@ void Executor::doExecute() { /** * It's worth noting that that the actions might be adding new actions into the queue */ - uint64_t nowUs = getTimeNowUs(); - shouldExecute = queue.executeAll(nowUs); + uint64_t nowNt = getTimeNowNt(); + shouldExecute = queue.executeAll(nowNt); } if (!isLocked()) { firmwareError("Someone has stolen my lock"); return; } - uint64_t nowUs = getTimeNowUs(); + uint64_t nowNt = getTimeNowNt(); reentrantLock = false; /** * 'executeAll' is potentially invoking heavy callbacks, let's grab fresh time value? @@ -112,11 +113,12 @@ void Executor::doExecute() { /** * Let's set up the timer for the next execution */ - uint64_t nextEventTime = queue.getNextEventTime(nowUs); - efiAssertVoid(nextEventTime > nowUs, "setTimer constraint"); - if (nextEventTime == EMPTY_QUEUE) + uint64_t nextEventTimeNt = queue.getNextEventTime(nowNt); + efiAssertVoid(nextEventTimeNt > nowNt, "setTimer constraint"); + if (nextEventTimeNt == EMPTY_QUEUE) return; // no pending events in the queue - setHardwareUsTimer(nextEventTime - nowUs); + uint64_t delayUs = NT2US(nextEventTimeNt - nowNt); + setHardwareUsTimer(delayUs == 0 ? 1 : delayUs); } /** diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index 509dc00457..d390e8b263 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -15,7 +15,7 @@ * We need to limit the number of iterations in order to avoid precision loss while calculating * next toggle time */ -#define ITERATION_LIMIT 10000 +#define ITERATION_LIMIT 1000 SimplePwm::SimplePwm() { wave.init(pinStates); diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 945ac2ccce..8e965887cf 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -14,6 +14,7 @@ #include "data_buffer.h" #include "histogram.h" #include "wave_chart.h" +#include "pwm_generator_logic.h" #include "rpm_calculator.h" #if EFI_PROD_CODE @@ -188,6 +189,10 @@ static void triggerShapeInfo(Engine *engine) { #endif } +#if EFI_PROD_CODE +extern PwmConfig triggerSignal; +#endif /* #if EFI_PROD_CODE */ + static void triggerInfo(Engine *engine) { #if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__) @@ -211,13 +216,18 @@ static void triggerInfo(Engine *engine) { engineConfiguration2->triggerShape.dutyCycle[1]); scheduleMsg(&logger, "isError %d", isTriggerDecoderError()); + #endif #if EFI_PROD_CODE - scheduleMsg(&logger, "primary trigger simulator: %s %s", hwPortname(boardConfiguration->triggerSimulatorPins[0]), - pinModeToString(boardConfiguration->triggerSimulatorPinModes[0])); - scheduleMsg(&logger, "secondary trigger simulator: %s %s", hwPortname(boardConfiguration->triggerSimulatorPins[1]), - pinModeToString(boardConfiguration->triggerSimulatorPinModes[1])); + scheduleMsg(&logger, "primary trigger simulator: %s %s freq=%d", hwPortname(boardConfiguration->triggerSimulatorPins[0]), + pinModeToString(boardConfiguration->triggerSimulatorPinModes[0]), + boardConfiguration->triggerSimulatorFrequency + ); + scheduleMsg(&logger, "secondary trigger simulator: %s %s phase=%d", hwPortname(boardConfiguration->triggerSimulatorPins[1]), + pinModeToString(boardConfiguration->triggerSimulatorPinModes[1]), + triggerSignal.safe.phaseIndex + ); scheduleMsg(&logger, "3rd trigger simulator: %s %s", hwPortname(boardConfiguration->triggerSimulatorPins[2]), pinModeToString(boardConfiguration->triggerSimulatorPinModes[2])); diff --git a/firmware/svnversion.h b/firmware/svnversion.h index 5b1c1ce569..9c0e2fdaf7 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,5 +1,5 @@ // This file was generated by Version2Header -// Mon Nov 10 08:51:36 EST 2014 +// Mon Nov 10 13:43:19 EST 2014 #ifndef VCS_VERSION -#define VCS_VERSION "5255" +#define VCS_VERSION "5261" #endif