auto-sync
This commit is contained in:
parent
9b5a79680b
commit
0c5c82a8a4
|
@ -215,10 +215,10 @@ float getMap(void) {
|
||||||
void initMapAveraging(Logging *sharedLogger, Engine *engine) {
|
void initMapAveraging(Logging *sharedLogger, Engine *engine) {
|
||||||
logger = sharedLogger;
|
logger = sharedLogger;
|
||||||
|
|
||||||
startTimer[0].name = "map start0";
|
// startTimer[0].name = "map start0";
|
||||||
startTimer[1].name = "map start1";
|
// startTimer[1].name = "map start1";
|
||||||
endTimer[0].name = "map end0";
|
// endTimer[0].name = "map end0";
|
||||||
endTimer[1].name = "map end1";
|
// endTimer[1].name = "map end1";
|
||||||
|
|
||||||
addTriggerEventListener(&mapAveragingCallback, "MAP averaging", engine);
|
addTriggerEventListener(&mapAveragingCallback, "MAP averaging", engine);
|
||||||
addConsoleAction("faststat", showMapStats);
|
addConsoleAction("faststat", showMapStats);
|
||||||
|
|
|
@ -153,12 +153,12 @@ void Executor::scheduleTimerCallback() {
|
||||||
* @param [in] dwell the number of ticks of output duration.
|
* @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) {
|
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);
|
instance.scheduleByTime(scheduling, getTimeNowUs() + delayUs, callback, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *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);
|
instance.scheduleByTime(scheduling, time, callback, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,12 @@
|
||||||
#include "efitime.h"
|
#include "efitime.h"
|
||||||
#include "efilib2.h"
|
#include "efilib2.h"
|
||||||
|
|
||||||
|
scheduling_s::scheduling_s() {
|
||||||
|
callback = NULL;
|
||||||
|
next = NULL;
|
||||||
|
isScheduled = false;
|
||||||
|
}
|
||||||
|
|
||||||
EventQueue::EventQueue() {
|
EventQueue::EventQueue() {
|
||||||
head = NULL;
|
head = NULL;
|
||||||
setLateDelay(100);
|
setLateDelay(100);
|
||||||
|
@ -34,13 +40,13 @@ bool_t EventQueue::insertTask(scheduling_s *scheduling, uint64_t timeX, schfunc_
|
||||||
#endif
|
#endif
|
||||||
efiAssert(callback != NULL, "NULL callback", false);
|
efiAssert(callback != NULL, "NULL callback", false);
|
||||||
|
|
||||||
int alreadyPending = checkIfPending(scheduling);
|
if (scheduling->isScheduled)
|
||||||
if (alreadyPending)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
scheduling->momentX = timeX;
|
scheduling->momentX = timeX;
|
||||||
scheduling->callback = callback;
|
scheduling->callback = callback;
|
||||||
scheduling->param = param;
|
scheduling->param = param;
|
||||||
|
scheduling->isScheduled = true;
|
||||||
|
|
||||||
if (head == NULL || timeX < head->momentX) {
|
if (head == NULL || timeX < head->momentX) {
|
||||||
LL_PREPEND(head, scheduling);
|
LL_PREPEND(head, scheduling);
|
||||||
|
@ -139,6 +145,7 @@ int EventQueue::executeAll(uint64_t now) {
|
||||||
LL_FOREACH_SAFE(executionList, current, tmp)
|
LL_FOREACH_SAFE(executionList, current, tmp)
|
||||||
{
|
{
|
||||||
uint32_t before = GET_TIMESTAMP();
|
uint32_t before = GET_TIMESTAMP();
|
||||||
|
current->isScheduled = false;
|
||||||
current->callback(current->param);
|
current->callback(current->param);
|
||||||
// even with overflow it's safe to substract here
|
// even with overflow it's safe to substract here
|
||||||
lastEventQueueTime = GET_TIMESTAMP() - before;
|
lastEventQueueTime = GET_TIMESTAMP() - before;
|
||||||
|
|
|
@ -35,7 +35,7 @@ bool assertNotInList(T *head, T*element) {
|
||||||
* was not scheduled by angle but was scheduled by time. In case of scheduling
|
* 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
|
* 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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ void PwmConfig::baseConstructor() {
|
||||||
memset(&scheduling, 0, sizeof(scheduling));
|
memset(&scheduling, 0, sizeof(scheduling));
|
||||||
memset(&safe, 0, sizeof(safe));
|
memset(&safe, 0, sizeof(safe));
|
||||||
dbgNestingLevel = 0;
|
dbgNestingLevel = 0;
|
||||||
scheduling.name = "PwmConfig";
|
|
||||||
periodNt = NAN;
|
periodNt = NAN;
|
||||||
memset(&outputPins, 0, sizeof(outputPins));
|
memset(&outputPins, 0, sizeof(outputPins));
|
||||||
phaseCount = 0;
|
phaseCount = 0;
|
||||||
|
|
|
@ -23,8 +23,7 @@ public:
|
||||||
schfunc_t callback;
|
schfunc_t callback;
|
||||||
void *param;
|
void *param;
|
||||||
scheduling_s *next;
|
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);
|
void scheduleTask(const char *prefix, scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param);
|
||||||
|
|
|
@ -236,8 +236,8 @@ float getCrankshaftAngleNt(uint64_t timeNt DECLARE_ENGINE_PARAMETER_S) {
|
||||||
void initRpmCalculator(Engine *engine) {
|
void initRpmCalculator(Engine *engine) {
|
||||||
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
||||||
|
|
||||||
tdcScheduler[0].name = "tdc0";
|
// tdcScheduler[0].name = "tdc0";
|
||||||
tdcScheduler[1].name = "tdc1";
|
// tdcScheduler[1].name = "tdc1";
|
||||||
addTriggerEventListener(tdcMarkCallback, "chart TDC mark", engine);
|
addTriggerEventListener(tdcMarkCallback, "chart TDC mark", engine);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -68,10 +68,14 @@ void StepperMotor::setTargetPosition(int targetPosition) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StepperMotor::pulse() {
|
void StepperMotor::pulse() {
|
||||||
|
palWritePad(enablePort, enablePin, false); // ebable stepper
|
||||||
|
|
||||||
palWritePad(stepPort, stepPin, true);
|
palWritePad(stepPort, stepPin, true);
|
||||||
chThdSleepMilliseconds(ST_DELAY_MS);
|
chThdSleepMilliseconds(ST_DELAY_MS);
|
||||||
palWritePad(stepPort, stepPin, false);
|
palWritePad(stepPort, stepPin, false);
|
||||||
chThdSleepMilliseconds(ST_DELAY_MS);
|
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,
|
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);
|
directionPort = getHwPort(directionPin);
|
||||||
this->directionPin = getHwPin(directionPin);
|
this->directionPin = getHwPin(directionPin);
|
||||||
|
|
||||||
|
enablePort = getHwPort(enablePin);
|
||||||
|
this->enablePin = getHwPin(enablePin);
|
||||||
|
|
||||||
mySetPadMode2("stepper step", stepPin, PAL_MODE_OUTPUT_PUSHPULL);
|
mySetPadMode2("stepper step", stepPin, PAL_MODE_OUTPUT_PUSHPULL);
|
||||||
mySetPadMode2("stepper dir", directionPin, PAL_MODE_OUTPUT_PUSHPULL);
|
mySetPadMode2("stepper dir", directionPin, PAL_MODE_OUTPUT_PUSHPULL);
|
||||||
mySetPadMode2("stepper enable", enablePin, 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);
|
chThdCreateStatic(stThreadStack, sizeof(stThreadStack), NORMALPRIO, (tfunc_t) stThread, this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@ private:
|
||||||
GPIO_TypeDef * stepPort;
|
GPIO_TypeDef * stepPort;
|
||||||
ioportmask_t stepPin;
|
ioportmask_t stepPin;
|
||||||
|
|
||||||
|
GPIO_TypeDef * enablePort;
|
||||||
|
ioportmask_t enablePin;
|
||||||
|
|
||||||
THD_WORKING_AREA(stThreadStack, UTILITY_THREAD_STACK_SIZE);
|
THD_WORKING_AREA(stThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2728,7 +2728,7 @@
|
||||||
<name>$PROJ_DIR$\..\hw_layer\mcp3208.h</name>
|
<name>$PROJ_DIR$\..\hw_layer\mcp3208.h</name>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\hw_layer\microsecond_timer.c</name>
|
<name>$PROJ_DIR$\..\hw_layer\microsecond_timer.cpp</name>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\hw_layer\microsecond_timer.h</name>
|
<name>$PROJ_DIR$\..\hw_layer\microsecond_timer.h</name>
|
||||||
|
|
|
@ -107,22 +107,24 @@ void testSignalExecutor(void) {
|
||||||
|
|
||||||
callbackCounter = 0;
|
callbackCounter = 0;
|
||||||
eq.executeAll(10);
|
eq.executeAll(10);
|
||||||
assertEqualsM("callbackCounter", 2, callbackCounter);
|
assertEqualsM("callbackCounter/2", 2, callbackCounter);
|
||||||
callbackCounter = 0;
|
callbackCounter = 0;
|
||||||
eq.executeAll(11);
|
eq.executeAll(11);
|
||||||
assertEquals(1, callbackCounter);
|
assertEqualsM("callbackCounter/1#1", 1, callbackCounter);
|
||||||
eq.clear();
|
eq.executeAll(100);
|
||||||
|
assertEquals(0, eq.size());
|
||||||
|
|
||||||
eq.insertTask(&s1, 12, callback, NULL);
|
eq.insertTask(&s1, 12, callback, NULL);
|
||||||
eq.insertTask(&s2, 11, callback, NULL);
|
eq.insertTask(&s2, 11, callback, NULL);
|
||||||
eq.insertTask(&s3, 10, callback, NULL);
|
eq.insertTask(&s3, 10, callback, NULL);
|
||||||
callbackCounter = 0;
|
callbackCounter = 0;
|
||||||
eq.executeAll(10);
|
eq.executeAll(10);
|
||||||
assertEquals(1, callbackCounter);
|
assertEqualsM("callbackCounter/1#2", 1, callbackCounter);
|
||||||
callbackCounter = 0;
|
callbackCounter = 0;
|
||||||
eq.executeAll(11);
|
eq.executeAll(11);
|
||||||
assertEquals(1, callbackCounter);
|
assertEquals(1, callbackCounter);
|
||||||
eq.clear();
|
eq.executeAll(100);
|
||||||
|
assertEquals(0, eq.size());
|
||||||
|
|
||||||
callbackCounter = 0;
|
callbackCounter = 0;
|
||||||
eq.insertTask(&s1, 10, callback, NULL);
|
eq.insertTask(&s1, 10, callback, NULL);
|
||||||
|
@ -143,7 +145,8 @@ void testSignalExecutor(void) {
|
||||||
eq.executeAll(1);
|
eq.executeAll(1);
|
||||||
assertEquals(10, eq.getNextEventTime(0));
|
assertEquals(10, eq.getNextEventTime(0));
|
||||||
|
|
||||||
eq.clear();
|
eq.executeAll(100);
|
||||||
|
assertEquals(0, eq.size());
|
||||||
callbackCounter = 0;
|
callbackCounter = 0;
|
||||||
// both events are scheduled for the same time
|
// both events are scheduled for the same time
|
||||||
eq.insertTask(&s1, 10, callback, NULL);
|
eq.insertTask(&s1, 10, callback, NULL);
|
||||||
|
|
Loading…
Reference in New Issue