auto-sync

This commit is contained in:
rusEfi 2014-11-15 10:05:13 -06:00
parent 332bd7a9cc
commit 9b8af9e9f1
2 changed files with 23 additions and 4 deletions

View File

@ -11,7 +11,12 @@
#include "test_engine.h"
void setTestEngineConfiguration(engine_configuration_s *engineConfiguration) {
engineConfiguration->triggerConfig.triggerType = TT_TOOTHED_WHEEL_60_2;
// engineConfiguration->triggerConfig.triggerType = TT_TOOTHED_WHEEL;
trigger_config_s *triggerConfig = &engineConfiguration->triggerConfig;
triggerConfig->customIsSynchronizationNeeded = false;
triggerConfig->customTotalToothCount = 60;
triggerConfig->customSkippedToothCount = 0;
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);

View File

@ -27,9 +27,23 @@ static Executor instance;
extern schfunc_t globalTimerCallback;
static int timerIsLate = 0;
/**
* these fields are global in order to facilitate debugging
*/
static uint64_t nextEventTimeNt = 0;
static uint64_t hwAlarmTime = 0;
static uint64_t callbackTime = 0;
static void executorCallback(void *arg) {
(void)arg;
efiAssertVoid(getRemainingStack(chThdSelf()) > 256, "lowstck#2y");
// callbackTime = getTimeNowNt();
// if((callbackTime > nextEventTimeNt) && (callbackTime - nextEventTimeNt > US2NT(5000))) {
// timerIsLate++;
// }
instance.onTimerCallback();
}
@ -113,12 +127,12 @@ void Executor::doExecute() {
/**
* Let's set up the timer for the next execution
*/
uint64_t nextEventTimeNt = queue.getNextEventTime(nowNt);
nextEventTimeNt = queue.getNextEventTime(nowNt);
efiAssertVoid(nextEventTimeNt > nowNt, "setTimer constraint");
if (nextEventTimeNt == EMPTY_QUEUE)
return; // no pending events in the queue
uint64_t delayUs = NT2US(nextEventTimeNt - nowNt);
setHardwareUsTimer(delayUs == 0 ? 1 : delayUs);
hwAlarmTime = NT2US(nextEventTimeNt - nowNt);
setHardwareUsTimer(hwAlarmTime == 0 ? 1 : hwAlarmTime);
}
/**