diff --git a/firmware/controllers/PwmTester.cpp b/firmware/controllers/PwmTester.cpp index b62511f287..1bff95773a 100644 --- a/firmware/controllers/PwmTester.cpp +++ b/firmware/controllers/PwmTester.cpp @@ -20,7 +20,7 @@ static LoggingWithStorage logger; static SimplePwm pwmTest[5]; -extern OutputPin warningPin; +extern OutputPin warningLedPin; extern EnginePins enginePins; EXTERN_ENGINE; @@ -31,7 +31,7 @@ static void startPwmTest(int freq) { engine->isRunningPwmTest = true; // PD13 pin is initialized elsewhere already - startSimplePwm(&pwmTest[0], "tester", &warningPin, 10, 0.5f, applyPinState); + startSimplePwm(&pwmTest[0], "tester", &warningLedPin, 10, 0.5f, applyPinState); /** * See custom_engine.cpp for pinout */ diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 97fd020ca1..a9dc269685 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -733,5 +733,5 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 20180723; + return 20180724; } diff --git a/firmware/controllers/trigger/spark_logic.cpp b/firmware/controllers/trigger/spark_logic.cpp index df4a36845e..91c00a16e8 100644 --- a/firmware/controllers/trigger/spark_logic.cpp +++ b/firmware/controllers/trigger/spark_logic.cpp @@ -74,6 +74,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngle, IgnitionEvent *e assertAngleRange(ignitionPositionWithinEngineCycle, "aPWEC", CUSTOM_ERR_6566); cfg_float_t_1f timing_offset_cylinder = CONFIG(timing_offset_cylinder[event->cylinderIndex]); const angle_t localAdvance = -ENGINE(engineState.timingAdvance) + ignitionPositionWithinEngineCycle + timing_offset_cylinder; + efiAssertVoid(CUSTOM_ERR_6689, !cisnan(localAdvance), "findAngle#9"); efiAssertVoid(CUSTOM_ERR_6589, !cisnan(localAdvance), "localAdvance#1"); const int index = ENGINE(ignitionPin[event->cylinderIndex]); @@ -176,11 +177,16 @@ static int globalSparkIdCoutner = 0; static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventIndex, IgnitionEvent *iEvent, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { + angle_t advance = iEvent->advance; const floatms_t dwellMs = ENGINE(engineState.sparkDwell); if (cisnan(dwellMs) || dwellMs <= 0) { warning(CUSTOM_DWELL, "invalid dwell to handle: %.2f at %d", dwellMs, rpm); return; } + if (cisnan(advance)) { + warning(CUSTOM_ERR_6688, "NaN advance"); + return; + } floatus_t chargeDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * iEvent->dwellPosition.angleOffset; int isIgnitionError = chargeDelayUs < 0; @@ -224,7 +230,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI * Spark event is often happening during a later trigger event timeframe * TODO: improve precision */ - float advance = iEvent->advance; + efiAssertVoid(CUSTOM_ERR_6591, !cisnan(advance), "findAngle#4"); assertAngleRange(advance, "findAngle#a5", CUSTOM_ERR_6549); TRIGGER_SHAPE(findTriggerPosition(&iEvent->sparkPosition, advance PASS_ENGINE_PARAMETER_SUFFIX));