auto-sync
This commit is contained in:
parent
344374457a
commit
92dc1cc061
|
@ -54,7 +54,7 @@ char hexChar(int v) {
|
||||||
return 'A' - 10 + v;
|
return 'A' - 10 + v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: why does it not compile if I make this function 'inline'?
|
// todo: make this a macro?
|
||||||
int isIsrContext(void) {
|
int isIsrContext(void) {
|
||||||
/**
|
/**
|
||||||
* Unfortunately ChibiOS has two versions of methods for different
|
* Unfortunately ChibiOS has two versions of methods for different
|
||||||
|
@ -63,6 +63,7 @@ int isIsrContext(void) {
|
||||||
return dbg_isr_cnt > 0;
|
return dbg_isr_cnt > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: make this a macro?
|
||||||
int isLocked(void) {
|
int isLocked(void) {
|
||||||
return dbg_lock_cnt > 0;
|
return dbg_lock_cnt > 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,17 +48,12 @@ static void executorCallback(void *arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Executor::Executor() {
|
Executor::Executor() {
|
||||||
reentrantLock = false;
|
reentrantFlag = false;
|
||||||
queue.setLateDelay(US2NT(100));
|
queue.setLateDelay(US2NT(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Executor::lock(void) {
|
#define lock() lockAnyContext()
|
||||||
lockAnyContext();
|
#define unlock() unlockAnyContext()
|
||||||
}
|
|
||||||
|
|
||||||
void Executor::unlock(void) {
|
|
||||||
unlockAnyContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Executor::schedule2(scheduling_s *scheduling, uint64_t timeUs, schfunc_t callback,
|
void Executor::schedule2(scheduling_s *scheduling, uint64_t timeUs, schfunc_t callback,
|
||||||
void *param) {
|
void *param) {
|
||||||
|
@ -70,12 +65,12 @@ void Executor::schedule2(scheduling_s *scheduling, uint64_t timeUs, schfunc_t ca
|
||||||
// callback(param);
|
// callback(param);
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
if (!reentrantLock) {
|
if (!reentrantFlag) {
|
||||||
// this would guard the queue and disable interrupts
|
// this would guard the queue and disable interrupts
|
||||||
lock();
|
lock();
|
||||||
}
|
}
|
||||||
queue.insertTask(scheduling, US2NT(timeUs), callback, param);
|
queue.insertTask(scheduling, US2NT(timeUs), callback, param);
|
||||||
if (!reentrantLock) {
|
if (!reentrantFlag) {
|
||||||
doExecute();
|
doExecute();
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
@ -98,10 +93,10 @@ void Executor::onTimerCallback() {
|
||||||
void Executor::doExecute() {
|
void Executor::doExecute() {
|
||||||
/**
|
/**
|
||||||
* Let's execute actions we should execute at this point.
|
* Let's execute actions we should execute at this point.
|
||||||
* reentrantLock takes care of the use case where the actions we are executing are scheduling
|
* reentrantFlag takes care of the use case where the actions we are executing are scheduling
|
||||||
* further invocations
|
* further invocations
|
||||||
*/
|
*/
|
||||||
reentrantLock = TRUE;
|
reentrantFlag = true;
|
||||||
bool shouldExecute = true;
|
bool shouldExecute = true;
|
||||||
/**
|
/**
|
||||||
* in real life it could be that while we executing listeners time passes and it's already time to execute
|
* in real life it could be that while we executing listeners time passes and it's already time to execute
|
||||||
|
@ -120,7 +115,7 @@ void Executor::doExecute() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint64_t nowNt = getTimeNowNt();
|
uint64_t nowNt = getTimeNowNt();
|
||||||
reentrantLock = false;
|
reentrantFlag = false;
|
||||||
/**
|
/**
|
||||||
* 'executeAll' is potentially invoking heavy callbacks, let's grab fresh time value?
|
* 'executeAll' is potentially invoking heavy callbacks, let's grab fresh time value?
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,10 +19,8 @@ public:
|
||||||
void onTimerCallback();
|
void onTimerCallback();
|
||||||
private:
|
private:
|
||||||
EventQueue queue;
|
EventQueue queue;
|
||||||
bool reentrantLock;
|
bool reentrantFlag;
|
||||||
void doExecute();
|
void doExecute();
|
||||||
void lock(void);
|
|
||||||
void unlock(void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "event_queue.h"
|
#include "event_queue.h"
|
||||||
#include "efitime.h"
|
#include "efitime.h"
|
||||||
|
#include "efilib2.h"
|
||||||
|
|
||||||
EventQueue::EventQueue() {
|
EventQueue::EventQueue() {
|
||||||
head = NULL;
|
head = NULL;
|
||||||
|
@ -76,7 +77,8 @@ uint64_t EventQueue::getNextEventTime(uint64_t nowX) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static scheduling_s * longScheduling;
|
// static scheduling_s * longScheduling;
|
||||||
// static uint32_t cost;
|
uint32_t maxEventQueueTime = 0;
|
||||||
|
uint32_t lastEventQueueTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke all pending actions prior to specified timestamp
|
* Invoke all pending actions prior to specified timestamp
|
||||||
|
@ -109,10 +111,12 @@ bool EventQueue::executeAll(uint64_t now) {
|
||||||
bool result = (executionList != NULL);
|
bool result = (executionList != NULL);
|
||||||
LL_FOREACH_SAFE(executionList, current, tmp)
|
LL_FOREACH_SAFE(executionList, current, tmp)
|
||||||
{
|
{
|
||||||
// uint32_t before = hal_lld_get_counter_value();
|
uint32_t before = GET_TIMESTAMP();
|
||||||
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
|
||||||
// cost = hal_lld_get_counter_value() - before;
|
lastEventQueueTime = GET_TIMESTAMP() - before;
|
||||||
|
if (lastEventQueueTime > maxEventQueueTime)
|
||||||
|
maxEventQueueTime = lastEventQueueTime;
|
||||||
// if (cost > 2000) {
|
// if (cost > 2000) {
|
||||||
// longScheduling = current;
|
// longScheduling = current;
|
||||||
// cost++;
|
// cost++;
|
||||||
|
|
|
@ -212,6 +212,7 @@ extern PwmConfig triggerSignal;
|
||||||
#endif /* #if EFI_PROD_CODE */
|
#endif /* #if EFI_PROD_CODE */
|
||||||
|
|
||||||
extern uint32_t maxLockTime;
|
extern uint32_t maxLockTime;
|
||||||
|
extern uint32_t maxEventQueueTime;
|
||||||
|
|
||||||
static void triggerInfo(Engine *engine) {
|
static void triggerInfo(Engine *engine) {
|
||||||
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
||||||
|
@ -221,11 +222,6 @@ static void triggerInfo(Engine *engine) {
|
||||||
scheduleMsg(&logger, "Template %s/%d trigger %d", getConfigurationName(engineConfiguration->engineType),
|
scheduleMsg(&logger, "Template %s/%d trigger %d", getConfigurationName(engineConfiguration->engineType),
|
||||||
engineConfiguration->engineType, engineConfiguration->triggerConfig.triggerType);
|
engineConfiguration->engineType, engineConfiguration->triggerConfig.triggerType);
|
||||||
|
|
||||||
scheduleMsg(&logger, "sn=%d ignitionMathTime=%d schTime=%d",
|
|
||||||
ts->isSynchronizationNeeded,
|
|
||||||
engine->ignitionMathTime,
|
|
||||||
engine->ignitionSchTime);
|
|
||||||
|
|
||||||
scheduleMsg(&logger, "trigger event counters %d/%d/%d/%d", triggerCentral.getHwEventCounter(0),
|
scheduleMsg(&logger, "trigger event counters %d/%d/%d/%d", triggerCentral.getHwEventCounter(0),
|
||||||
triggerCentral.getHwEventCounter(1), triggerCentral.getHwEventCounter(2),
|
triggerCentral.getHwEventCounter(1), triggerCentral.getHwEventCounter(2),
|
||||||
triggerCentral.getHwEventCounter(3));
|
triggerCentral.getHwEventCounter(3));
|
||||||
|
@ -245,7 +241,13 @@ static void triggerInfo(Engine *engine) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
scheduleMsg(&logger, "sn=%s ignitionMathTime=%d schTime=%d",
|
||||||
|
boolToString(ts->isSynchronizationNeeded),
|
||||||
|
engine->ignitionMathTime,
|
||||||
|
engine->ignitionSchTime);
|
||||||
scheduleMsg(&logger, "maxLockTime=%d / maxTriggerReentraint=%d", maxLockTime, maxTriggerReentraint);
|
scheduleMsg(&logger, "maxLockTime=%d / maxTriggerReentraint=%d", maxLockTime, maxTriggerReentraint);
|
||||||
|
scheduleMsg(&logger, "maxEventQueueTime=%d", maxEventQueueTime);
|
||||||
|
|
||||||
scheduleMsg(&logger, "primary trigger simulator: %s %s freq=%d",
|
scheduleMsg(&logger, "primary trigger simulator: %s %s freq=%d",
|
||||||
hwPortname(boardConfiguration->triggerSimulatorPins[0]),
|
hwPortname(boardConfiguration->triggerSimulatorPins[0]),
|
||||||
pinModeToString(boardConfiguration->triggerSimulatorPinModes[0]),
|
pinModeToString(boardConfiguration->triggerSimulatorPinModes[0]),
|
||||||
|
|
|
@ -31,11 +31,7 @@ class Engine;
|
||||||
class trigger_shape_s {
|
class trigger_shape_s {
|
||||||
public:
|
public:
|
||||||
trigger_shape_s();
|
trigger_shape_s();
|
||||||
/**
|
bool_t isSynchronizationNeeded;
|
||||||
* todo: something really weird - unit test fail on Linux build server
|
|
||||||
* if I change this type to bool_t? WAT?
|
|
||||||
*/
|
|
||||||
int isSynchronizationNeeded;
|
|
||||||
|
|
||||||
int totalToothCount;
|
int totalToothCount;
|
||||||
int skippedToothCount;
|
int skippedToothCount;
|
||||||
|
|
Loading…
Reference in New Issue