diff --git a/firmware/controllers/system/SingleTimerExecutor.cpp b/firmware/controllers/system/SingleTimerExecutor.cpp index 4dd515bb3e..dda2b9b962 100644 --- a/firmware/controllers/system/SingleTimerExecutor.cpp +++ b/firmware/controllers/system/SingleTimerExecutor.cpp @@ -156,15 +156,6 @@ void SingleTimerExecutor::scheduleTimerCallback() { hwSetTimerDuration = GET_TIMESTAMP() - beforeHwSetTimer; } -/** - * @brief Schedule an event at specified timestamp - * - * @param [in] timeUs absolute time of the event, since ECU boot - */ -void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param) { - _engine.executor.scheduleByTimestamp(scheduling, time, callback, param); -} - void initSignalExecutorImpl(void) { globalTimerCallback = executorCallback; initMicrosecondTimer(); diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index 473813d077..67123402f4 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -223,10 +223,10 @@ static void timerCallback(PwmConfig *state) { efiAssertVoid(CUSTOM_ERR_6581, state->dbgNestingLevel < 25, "PWM nesting issue"); efitimeus_t switchTimeUs = state->togglePwmState(); -// if (state->executor == NULL) { -// firmwareError(CUSTOM_ERR_6695, "exec on %s", state->name); -// return; -// } + if (state->executor == NULL) { + firmwareError(CUSTOM_ERR_6695, "exec on %s", state->name); + return; + } state->executor->scheduleByTimestamp(&state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state); state->dbgNestingLevel--; diff --git a/unit_tests/global_execution_queue.cpp b/unit_tests/global_execution_queue.cpp index 350377e76a..6bd3ecf574 100644 --- a/unit_tests/global_execution_queue.cpp +++ b/unit_tests/global_execution_queue.cpp @@ -14,6 +14,10 @@ EventQueue schedulingQueue; bool_t debugSignalExecutor = false; +TestExecutor::TestExecutor() { + +} + void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) { if (debugSignalExecutor) { printf("scheduleTask %d\r\n", delayUs); @@ -21,6 +25,11 @@ void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfu scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, callback, param); } + +void TestExecutor::clear() { + schedulingQueue.clear(); +} + void TestExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) { if (debugSignalExecutor) { printf("scheduleByTime %d\r\n", timeUs); @@ -28,14 +37,6 @@ void TestExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t tim schedulingQueue.insertTask(scheduling, timeUs, callback, param); } -void scheduleByTimestamp(scheduling_s *scheduling, - efitimeus_t timeUs, schfunc_t callback, void *param) { - if (debugSignalExecutor) { - printf("scheduleByTime %d\r\n", timeUs); - } - schedulingQueue.insertTask(scheduling, timeUs, callback, param); -} - void initSignalExecutorImpl(void) { } diff --git a/unit_tests/global_execution_queue.h b/unit_tests/global_execution_queue.h index 71f099d406..bed194eaca 100644 --- a/unit_tests/global_execution_queue.h +++ b/unit_tests/global_execution_queue.h @@ -12,8 +12,10 @@ class TestExecutor : public ExecutorInterface { public: + TestExecutor(); void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param); void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param); + void clear(); }; #endif /* GLOBAL_EXECUTION_QUEUE_H_ */ diff --git a/unit_tests/tests/test_trigger_decoder.cpp b/unit_tests/tests/test_trigger_decoder.cpp index b3223fe624..656f3c016f 100644 --- a/unit_tests/tests/test_trigger_decoder.cpp +++ b/unit_tests/tests/test_trigger_decoder.cpp @@ -381,7 +381,7 @@ void testRpmCalculator(void) { } - schedulingQueue.clear(); + engine->executor.clear(); eth.fireFall(5); eth.fireRise(5); @@ -391,7 +391,7 @@ void testRpmCalculator(void) { assertEqualsM("ev 3", start + 13333 - 1515, schedulingQueue.getForUnitText(0)->momentX); assertEqualsM2("ev 5", start + 14277, schedulingQueue.getForUnitText(1)->momentX, 2); assertEqualsM("3/3", start + 14777, schedulingQueue.getForUnitText(2)->momentX); - schedulingQueue.clear(); + engine->executor.clear(); assertEquals(5, TRIGGER_SHAPE(triggerIndexByAngle[240])); assertEquals(5, TRIGGER_SHAPE(triggerIndexByAngle[241]));