diff --git a/firmware/controllers/map_averaging.cpp b/firmware/controllers/map_averaging.cpp
index a565331f9c..a41756b7e1 100644
--- a/firmware/controllers/map_averaging.cpp
+++ b/firmware/controllers/map_averaging.cpp
@@ -215,10 +215,10 @@ float getMap(void) {
void initMapAveraging(Logging *sharedLogger, Engine *engine) {
logger = sharedLogger;
- startTimer[0].name = "map start0";
- startTimer[1].name = "map start1";
- endTimer[0].name = "map end0";
- endTimer[1].name = "map end1";
+// startTimer[0].name = "map start0";
+// startTimer[1].name = "map start1";
+// endTimer[0].name = "map end0";
+// endTimer[1].name = "map end1";
addTriggerEventListener(&mapAveragingCallback, "MAP averaging", engine);
addConsoleAction("faststat", showMapStats);
diff --git a/firmware/controllers/system/SingleTimerExecutor.cpp b/firmware/controllers/system/SingleTimerExecutor.cpp
index 01c5d81e48..3c4383322a 100644
--- a/firmware/controllers/system/SingleTimerExecutor.cpp
+++ b/firmware/controllers/system/SingleTimerExecutor.cpp
@@ -153,12 +153,12 @@ void Executor::scheduleTimerCallback() {
* @param [in] dwell the number of ticks of output duration.
*/
void scheduleTask(const char *prefix, scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
- scheduling->name = prefix;
+// scheduling->name = prefix;
instance.scheduleByTime(scheduling, getTimeNowUs() + delayUs, callback, param);
}
void scheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param) {
- scheduling->name = prefix;
+// scheduling->name = prefix;
instance.scheduleByTime(scheduling, time, callback, param);
}
diff --git a/firmware/controllers/system/event_queue.cpp b/firmware/controllers/system/event_queue.cpp
index f2effa9e41..74c13dcb83 100644
--- a/firmware/controllers/system/event_queue.cpp
+++ b/firmware/controllers/system/event_queue.cpp
@@ -16,6 +16,12 @@
#include "efitime.h"
#include "efilib2.h"
+scheduling_s::scheduling_s() {
+ callback = NULL;
+ next = NULL;
+ isScheduled = false;
+}
+
EventQueue::EventQueue() {
head = NULL;
setLateDelay(100);
@@ -34,13 +40,13 @@ bool_t EventQueue::insertTask(scheduling_s *scheduling, uint64_t timeX, schfunc_
#endif
efiAssert(callback != NULL, "NULL callback", false);
- int alreadyPending = checkIfPending(scheduling);
- if (alreadyPending)
+ if (scheduling->isScheduled)
return false;
scheduling->momentX = timeX;
scheduling->callback = callback;
scheduling->param = param;
+ scheduling->isScheduled = true;
if (head == NULL || timeX < head->momentX) {
LL_PREPEND(head, scheduling);
@@ -139,6 +145,7 @@ int EventQueue::executeAll(uint64_t now) {
LL_FOREACH_SAFE(executionList, current, tmp)
{
uint32_t before = GET_TIMESTAMP();
+ current->isScheduled = false;
current->callback(current->param);
// even with overflow it's safe to substract here
lastEventQueueTime = GET_TIMESTAMP() - before;
diff --git a/firmware/controllers/system/event_queue.h b/firmware/controllers/system/event_queue.h
index 0f31462995..2f8e2275d9 100644
--- a/firmware/controllers/system/event_queue.h
+++ b/firmware/controllers/system/event_queue.h
@@ -35,7 +35,7 @@ bool assertNotInList(T *head, T*element) {
* was not scheduled by angle but was scheduled by time. In case of scheduling
* by time with slow RPM the whole next fast revolution might be within the wait period
*/
- warning(OBD_PCM_Processor_Fault, "re-adding element into event_queue: [%s]", element->name);
+ warning(OBD_PCM_Processor_Fault, "re-adding element into event_queue");
return true;
}
}
diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp
index 48e9879746..a4888f692e 100644
--- a/firmware/controllers/system/pwm_generator_logic.cpp
+++ b/firmware/controllers/system/pwm_generator_logic.cpp
@@ -26,7 +26,6 @@ void PwmConfig::baseConstructor() {
memset(&scheduling, 0, sizeof(scheduling));
memset(&safe, 0, sizeof(safe));
dbgNestingLevel = 0;
- scheduling.name = "PwmConfig";
periodNt = NAN;
memset(&outputPins, 0, sizeof(outputPins));
phaseCount = 0;
diff --git a/firmware/controllers/system/scheduler.h b/firmware/controllers/system/scheduler.h
index b21de938e9..d6ae4370ae 100644
--- a/firmware/controllers/system/scheduler.h
+++ b/firmware/controllers/system/scheduler.h
@@ -23,8 +23,7 @@ public:
schfunc_t callback;
void *param;
scheduling_s *next;
- const char *name;
-// bool_t isScheduled;
+ bool_t isScheduled;
};
void scheduleTask(const char *prefix, scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param);
diff --git a/firmware/controllers/trigger/rpm_calculator.cpp b/firmware/controllers/trigger/rpm_calculator.cpp
index 727a2b3eca..4547ed652c 100644
--- a/firmware/controllers/trigger/rpm_calculator.cpp
+++ b/firmware/controllers/trigger/rpm_calculator.cpp
@@ -236,8 +236,8 @@ float getCrankshaftAngleNt(uint64_t timeNt DECLARE_ENGINE_PARAMETER_S) {
void initRpmCalculator(Engine *engine) {
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
- tdcScheduler[0].name = "tdc0";
- tdcScheduler[1].name = "tdc1";
+// tdcScheduler[0].name = "tdc0";
+// tdcScheduler[1].name = "tdc1";
addTriggerEventListener(tdcMarkCallback, "chart TDC mark", engine);
#endif
diff --git a/firmware/hw_layer/stepper.cpp b/firmware/hw_layer/stepper.cpp
index ea825bd0c6..40e7657904 100644
--- a/firmware/hw_layer/stepper.cpp
+++ b/firmware/hw_layer/stepper.cpp
@@ -68,10 +68,14 @@ void StepperMotor::setTargetPosition(int targetPosition) {
}
void StepperMotor::pulse() {
+ palWritePad(enablePort, enablePin, false); // ebable stepper
+
palWritePad(stepPort, stepPin, true);
chThdSleepMilliseconds(ST_DELAY_MS);
palWritePad(stepPort, stepPin, false);
chThdSleepMilliseconds(ST_DELAY_MS);
+
+ palWritePad(enablePort, enablePin, true); // disable stepper
}
void StepperMotor::initialize(brain_pin_e stepPin, brain_pin_e directionPin, float reactionTime, int totalSteps,
@@ -88,9 +92,13 @@ void StepperMotor::initialize(brain_pin_e stepPin, brain_pin_e directionPin, flo
directionPort = getHwPort(directionPin);
this->directionPin = getHwPin(directionPin);
+ enablePort = getHwPort(enablePin);
+ this->enablePin = getHwPin(enablePin);
+
mySetPadMode2("stepper step", stepPin, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("stepper dir", directionPin, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("stepper enable", enablePin, PAL_MODE_OUTPUT_PUSHPULL);
+ palWritePad(this->enablePort, enablePin, true); // disable stepper
chThdCreateStatic(stThreadStack, sizeof(stThreadStack), NORMALPRIO, (tfunc_t) stThread, this);
}
diff --git a/firmware/hw_layer/stepper.h b/firmware/hw_layer/stepper.h
index d1508076f1..c97c87b7ef 100644
--- a/firmware/hw_layer/stepper.h
+++ b/firmware/hw_layer/stepper.h
@@ -28,6 +28,9 @@ private:
GPIO_TypeDef * stepPort;
ioportmask_t stepPin;
+ GPIO_TypeDef * enablePort;
+ ioportmask_t enablePin;
+
THD_WORKING_AREA(stThreadStack, UTILITY_THREAD_STACK_SIZE);
};
diff --git a/firmware/iar/ch.ewp b/firmware/iar/ch.ewp
index 4952195cbd..6a1264234d 100644
--- a/firmware/iar/ch.ewp
+++ b/firmware/iar/ch.ewp
@@ -2728,7 +2728,7 @@
$PROJ_DIR$\..\hw_layer\mcp3208.h
- $PROJ_DIR$\..\hw_layer\microsecond_timer.c
+ $PROJ_DIR$\..\hw_layer\microsecond_timer.cpp
$PROJ_DIR$\..\hw_layer\microsecond_timer.h
diff --git a/unit_tests/test_signal_executor.cpp b/unit_tests/test_signal_executor.cpp
index 08c684243b..20f0154a52 100644
--- a/unit_tests/test_signal_executor.cpp
+++ b/unit_tests/test_signal_executor.cpp
@@ -107,22 +107,24 @@ void testSignalExecutor(void) {
callbackCounter = 0;
eq.executeAll(10);
- assertEqualsM("callbackCounter", 2, callbackCounter);
+ assertEqualsM("callbackCounter/2", 2, callbackCounter);
callbackCounter = 0;
eq.executeAll(11);
- assertEquals(1, callbackCounter);
- eq.clear();
+ assertEqualsM("callbackCounter/1#1", 1, callbackCounter);
+ eq.executeAll(100);
+ assertEquals(0, eq.size());
eq.insertTask(&s1, 12, callback, NULL);
eq.insertTask(&s2, 11, callback, NULL);
eq.insertTask(&s3, 10, callback, NULL);
callbackCounter = 0;
eq.executeAll(10);
- assertEquals(1, callbackCounter);
+ assertEqualsM("callbackCounter/1#2", 1, callbackCounter);
callbackCounter = 0;
eq.executeAll(11);
assertEquals(1, callbackCounter);
- eq.clear();
+ eq.executeAll(100);
+ assertEquals(0, eq.size());
callbackCounter = 0;
eq.insertTask(&s1, 10, callback, NULL);
@@ -143,7 +145,8 @@ void testSignalExecutor(void) {
eq.executeAll(1);
assertEquals(10, eq.getNextEventTime(0));
- eq.clear();
+ eq.executeAll(100);
+ assertEquals(0, eq.size());
callbackCounter = 0;
// both events are scheduled for the same time
eq.insertTask(&s1, 10, callback, NULL);