diff --git a/firmware/chibios/os/kernel/src/chdebug.c b/firmware/chibios/os/kernel/src/chdebug.c index bc04540d3a..034cf9837e 100644 --- a/firmware/chibios/os/kernel/src/chdebug.c +++ b/firmware/chibios/os/kernel/src/chdebug.c @@ -162,8 +162,8 @@ void firmwareError(const char *fmt, ...); * @notapi */ void dbg_check_enter_isr(void) { - if (dbg_isr_cnt > 2) - firmwareError("nesting3"); + if (dbg_isr_cnt > 1) + firmwareError("nesting2"); port_lock_from_isr(); if ((dbg_isr_cnt < 0) || (dbg_lock_cnt != 0)) chDbgPanic("SV#8"); diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index 313cb187d3..e3f5c02531 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -46,11 +46,11 @@ float getBaseAdvance(int rpm, float engineLoad) { float getAdvance(int rpm, float engineLoad DECLATE_ENGINE_PARAMETER) { float angle; if (isCrankingR(rpm)) { - angle = engineConfiguration->crankingTimingAngle; + angle = -engineConfiguration->crankingTimingAngle; } else { - angle = -getBaseAdvance(rpm, engineLoad); + angle = getBaseAdvance(rpm, engineLoad); } - return fixAngle(engineConfiguration, angle + engineConfiguration->ignitionOffset); + return fixAngle(engineConfiguration, angle - engineConfiguration->ignitionOffset); } void prepareTimingMap(void) { diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index e6859658a0..4544f318c5 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -793,7 +793,7 @@ void initSettings(engine_configuration_s *engineConfiguration) { addConsoleActionI("set_rpm_hard_limit", setRpmHardLimit); addConsoleActionI("set_firing_order", setFiringOrder); addConsoleActionI("set_algorithm", setAlgorithm); - addConsoleActionI("stopengine", stopEngine); + addConsoleAction("stopengine", stopEngine); // todo: refactor this - looks like all boolean flags should be controlled with less code duplication addConsoleAction("enable_injection", enableInjection); diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 7fea7c724b..dd311e5749 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -303,6 +303,7 @@ void onTriggerEvent(trigger_event_e ckpSignalType, uint32_t eventIndex, MainTrig return; } float advance = getAdvance(rpm, getEngineLoadT(engine) PASS_ENGINE_PARAMETER); + if (cisnan(advance)) { // error should already be reported return; @@ -310,7 +311,7 @@ void onTriggerEvent(trigger_event_e ckpSignalType, uint32_t eventIndex, MainTrig float dwellAngle = dwellMs / getOneDegreeTimeMs(rpm); - initializeIgnitionActions(advance, dwellAngle, engine->engineConfiguration2, + initializeIgnitionActions(fixAngle(engineConfiguration, -advance), dwellAngle, engine->engineConfiguration2, &engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER); }