diff --git a/firmware/controllers/system/SingleTimerExecutor.cpp b/firmware/controllers/system/SingleTimerExecutor.cpp index 5e17fc46f4..4dd515bb3e 100644 --- a/firmware/controllers/system/SingleTimerExecutor.cpp +++ b/firmware/controllers/system/SingleTimerExecutor.cpp @@ -67,7 +67,14 @@ void SingleTimerExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs } /** + * @brief Schedule an event at specific delay after now + * + * Invokes event callback after the specified amount of time. * callback would be executed either on ISR thread or current thread if we would need to execute right away + * + * @param [in, out] scheduling Data structure to keep this event in the collection. + * @param [in] delayUs the number of microseconds before the output signal immediate output if delay is zero. + * @param [in] dwell the number of ticks of output duration. */ void SingleTimerExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) { @@ -149,19 +156,6 @@ void SingleTimerExecutor::scheduleTimerCallback() { hwSetTimerDuration = GET_TIMESTAMP() - beforeHwSetTimer; } -/** - * @brief Schedule an event at specific delay after now - * - * Invokes event callback after the specified amount of time. - * - * @param [in, out] scheduling Data structure to keep this event in the collection. - * @param [in] delayUs the number of microseconds before the output signal immediate output if delay is zero. - * @param [in] dwell the number of ticks of output duration. - */ -void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) { - _engine.executor.scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, callback, param); -} - /** * @brief Schedule an event at specified timestamp * diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index 6d113d7300..9b0c60cb46 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -226,9 +226,9 @@ static void timerCallback(PwmConfig *state) { // if (state->executor == NULL) { // firmwareError(CUSTOM_ERR_6695, "exec on %s", state->name); // return; -// } + } - scheduleByTimestamp(&state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state); + state->executor->scheduleByTimestamp(&state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state); state->dbgNestingLevel--; } diff --git a/firmware/controllers/system/scheduler.h b/firmware/controllers/system/scheduler.h index fc2efb1fc2..89416b2d69 100644 --- a/firmware/controllers/system/scheduler.h +++ b/firmware/controllers/system/scheduler.h @@ -26,15 +26,11 @@ public: bool isScheduled; }; -/** - * see also scheduleByAngle - */ -// Deprecated see https://github.com/rusefi/rusefi/issues/655 -void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param); -// Deprecated see https://github.com/rusefi/rusefi/issues/655 -void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param); - class ExecutorInterface { +public: + /** + * see also scheduleByAngle + */ virtual void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) = 0; virtual void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) = 0; }; diff --git a/firmware/controllers/system/signal_executor_sleep.cpp b/firmware/controllers/system/signal_executor_sleep.cpp index d2958b744b..f5f26c1be4 100644 --- a/firmware/controllers/system/signal_executor_sleep.cpp +++ b/firmware/controllers/system/signal_executor_sleep.cpp @@ -34,10 +34,6 @@ #if EFI_SIGNAL_EXECUTOR_SLEEP || defined(__DOXYGEN__) -void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) { - scheduleForLater(scheduling, timeUs - getTimeNowUs(), callback, param); -} - void SleepExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) { scheduleForLater(scheduling, timeUs - getTimeNowUs(), callback, param); } @@ -56,7 +52,7 @@ static void timerCallback(scheduling_s *scheduling) { } -void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) { +static void doScheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) { int delaySt = MY_US2ST(delayUs); if (delaySt <= 0) { /** @@ -92,7 +88,7 @@ void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, } void SleepExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) { - ::scheduleForLater(scheduling, delayUs, callback, param); + doScheduleForLater(scheduling, delayUs, callback, param); } void initSignalExecutorImpl(void) { diff --git a/firmware/controllers/trigger/rpm_calculator.cpp b/firmware/controllers/trigger/rpm_calculator.cpp index 012c119041..dff177090b 100644 --- a/firmware/controllers/trigger/rpm_calculator.cpp +++ b/firmware/controllers/trigger/rpm_calculator.cpp @@ -375,12 +375,12 @@ void initRpmCalculator(Logging *sharedLogger, Engine *engine) { * it takes the crankshaft to rotate to the specified angle. */ void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle, - schfunc_t callback, void *param, RpmCalculator *calc) { + schfunc_t callback, void *param, RpmCalculator *calc DECLARE_ENGINE_PARAMETER_SUFFIX) { efiAssertVoid(CUSTOM_ANGLE_NAN, !cisnan(angle), "NaN angle?"); efiAssertVoid(CUSTOM_ERR_6634, isValidRpm(rpm), "RPM check expected"); float delayUs = calc->oneDegreeUs * angle; efiAssertVoid(CUSTOM_ERR_6635, !cisnan(delayUs), "NaN delay?"); - scheduleForLater(timer, (int) delayUs, callback, param); + engine->executor.scheduleForLater(timer, (int) delayUs, callback, param); } #endif diff --git a/firmware/controllers/trigger/rpm_calculator.h b/firmware/controllers/trigger/rpm_calculator.h index 052714edcd..23929cd85c 100644 --- a/firmware/controllers/trigger/rpm_calculator.h +++ b/firmware/controllers/trigger/rpm_calculator.h @@ -182,6 +182,6 @@ int getRevolutionCounter(void); #define addEngineSnifferEvent(n, msg) {} #endif /* EFI_ENGINE_SNIFFER */ -void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle, schfunc_t callback, void *param, RpmCalculator *calc); +void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle, schfunc_t callback, void *param, RpmCalculator *calc DECLARE_ENGINE_PARAMETER_SUFFIX); #endif /* RPM_REPORTER_H_ */ diff --git a/unit_tests/global_execution_queue.cpp b/unit_tests/global_execution_queue.cpp index c3486cef0b..350377e76a 100644 --- a/unit_tests/global_execution_queue.cpp +++ b/unit_tests/global_execution_queue.cpp @@ -14,14 +14,6 @@ EventQueue schedulingQueue; bool_t debugSignalExecutor = false; -void scheduleForLater(scheduling_s *scheduling, int delayUs, - schfunc_t callback, void *param) { - if (debugSignalExecutor) { - printf("scheduleTask %d\r\n", delayUs); - } - scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, callback, param); -} - void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) { if (debugSignalExecutor) { printf("scheduleTask %d\r\n", delayUs);