diff --git a/firmware/controllers/trigger/spark_logic.cpp b/firmware/controllers/trigger/spark_logic.cpp index 08c2336722..bf6bf253f1 100644 --- a/firmware/controllers/trigger/spark_logic.cpp +++ b/firmware/controllers/trigger/spark_logic.cpp @@ -5,7 +5,7 @@ * @author Andrey Belomutskiy, (c) 2012-2019 */ -#include "global.h" +#include "spark_logic.h" #include "os_access.h" #include "engine_math.h" @@ -224,7 +224,11 @@ static bool assertNotInIgnitionList(AngleBasedEvent *head, AngleBasedEvent *elem * @return true if event corresponds to current tooth and was time-based scheduler * false if event was put into queue for scheduling at a later tooth */ -static bool scheduleOrQueue(AngleBasedEvent *event, uint32_t trgEventIndex, angle_t angle, schfunc_t callback, void *param DECLARE_ENGINE_PARAMETER_SUFFIX) { +bool scheduleOrQueue(AngleBasedEvent *event, + uint32_t trgEventIndex, + angle_t angle, + schfunc_t callback, + void *param DECLARE_ENGINE_PARAMETER_SUFFIX) { event->position.setAngle(angle PASS_ENGINE_PARAMETER_SUFFIX); /** @@ -240,7 +244,7 @@ static bool scheduleOrQueue(AngleBasedEvent *event, uint32_t trgEventIndex, angl * time-based schedule. This case we would be firing events with best possible angle precision. * */ - if (event->position.triggerEventIndex == trgEventIndex) { + if (trgEventIndex != TRIGGER_EVENT_UNDEFINED && event->position.triggerEventIndex == trgEventIndex) { /** * Spark should be fired before the next trigger event - time-based delay is best precision possible */ diff --git a/firmware/controllers/trigger/spark_logic.h b/firmware/controllers/trigger/spark_logic.h index 818855aee9..914bf332ae 100644 --- a/firmware/controllers/trigger/spark_logic.h +++ b/firmware/controllers/trigger/spark_logic.h @@ -5,8 +5,7 @@ * @author Andrey Belomutskiy, (c) 2012-2017 */ -#ifndef CONTROLLERS_TRIGGER_SPARK_LOGIC_H_ -#define CONTROLLERS_TRIGGER_SPARK_LOGIC_H_ +#pragma once #include "engine.h" @@ -19,4 +18,9 @@ int getNumberOfSparks(ignition_mode_e mode DECLARE_ENGINE_PARAMETER_SUFFIX); percent_t getCoilDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX); void initializeIgnitionActions(DECLARE_ENGINE_PARAMETER_SIGNATURE); -#endif /* CONTROLLERS_TRIGGER_SPARK_LOGIC_H_ */ +#define TRIGGER_EVENT_UNDEFINED -1 +bool scheduleOrQueue(AngleBasedEvent *event, + uint32_t trgEventIndex, + angle_t angle, + schfunc_t callback, + void *param DECLARE_ENGINE_PARAMETER_SUFFIX);