auto-sync

This commit is contained in:
rusEfi 2014-11-14 15:03:52 -06:00
parent 9e79c4859c
commit 9cc4efd454
3 changed files with 13 additions and 13 deletions

View File

@ -127,7 +127,7 @@ void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) {
/** /**
* This invocation changes the state of triggerState * This invocation changes the state of triggerState
*/ */
triggerState.decodeTriggerEvent(triggerShape, &engine->engineConfiguration->triggerConfig, signal, nowUs); triggerState.decodeTriggerEvent(triggerShape, &engine->engineConfiguration->triggerConfig, signal, nowNt);
if (!triggerState.shaft_is_synchronized) { if (!triggerState.shaft_is_synchronized) {
// we should not propagate event if we do not know where we are // we should not propagate event if we do not know where we are

View File

@ -102,7 +102,7 @@ static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW
* This method changes the state of trigger_state_s data structure according to the trigger event * This method changes the state of trigger_state_s data structure according to the trigger event
*/ */
void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigger_config_s const*triggerConfig, void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigger_config_s const*triggerConfig,
trigger_event_e const signal, uint64_t nowUs) { trigger_event_e const signal, uint64_t nowNt) {
(void) triggerConfig; // we might want this for logging? (void) triggerConfig; // we might want this for logging?
efiAssertVoid(signal <= SHAFT_3RD_UP, "unexpected signal"); efiAssertVoid(signal <= SHAFT_3RD_UP, "unexpected signal");
@ -117,16 +117,16 @@ void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigge
/** /**
* For less important events we simply increment the index. * For less important events we simply increment the index.
*/ */
nextTriggerEvent(triggerWheel, nowUs); nextTriggerEvent(triggerWheel, nowNt);
if (triggerShape->gapBothDirections) { if (triggerShape->gapBothDirections) {
toothed_previous_duration = getCurrentGapDuration(nowUs); toothed_previous_duration = getCurrentGapDuration(nowNt);
isFirstEvent = false; isFirstEvent = false;
toothed_previous_time = nowUs; toothed_previous_time = nowNt;
} }
return; return;
} }
int64_t currentDuration = getCurrentGapDuration(nowUs); int64_t currentDuration = getCurrentGapDuration(nowNt);
isFirstEvent = false; isFirstEvent = false;
efiAssertVoid(currentDuration >= 0, "decode: negative duration?"); efiAssertVoid(currentDuration >= 0, "decode: negative duration?");
@ -164,15 +164,15 @@ void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigge
shaft_is_synchronized = true; shaft_is_synchronized = true;
// this call would update duty cycle values // this call would update duty cycle values
nextTriggerEvent(triggerWheel, nowUs); nextTriggerEvent(triggerWheel, nowNt);
nextRevolution(triggerShape->shaftPositionEventCount, nowUs); nextRevolution(triggerShape->shaftPositionEventCount, nowNt);
} else { } else {
nextTriggerEvent(triggerWheel, nowUs); nextTriggerEvent(triggerWheel, nowNt);
} }
toothed_previous_duration = currentDuration; toothed_previous_duration = currentDuration;
toothed_previous_time = nowUs; toothed_previous_time = nowNt;
} }
static void initializeSkippedToothTriggerShape(trigger_shape_s *s, int totalTeethCount, int skippedCount, static void initializeSkippedToothTriggerShape(trigger_shape_s *s, int totalTeethCount, int skippedCount,

View File

@ -137,13 +137,13 @@ uint64_t TriggerState::getTotalEventCounter() {
return totalEventCountBase + current_index; return totalEventCountBase + current_index;
} }
void TriggerState::nextRevolution(int triggerEventCount, uint64_t nowUs) { void TriggerState::nextRevolution(int triggerEventCount, uint64_t nowNt) {
if (cycleCallback != NULL) { if (cycleCallback != NULL) {
cycleCallback(this); cycleCallback(this);
} }
memcpy(prevTotalTime, totalTime, sizeof(prevTotalTime)); memcpy(prevTotalTime, totalTime, sizeof(prevTotalTime));
prevCycleDuration = nowUs - startOfCycle; prevCycleDuration = nowNt - startOfCycle;
startOfCycle = nowUs; startOfCycle = nowNt;
clear(); clear();
totalRevolutionCounter++; totalRevolutionCounter++;
totalEventCountBase += triggerEventCount; totalEventCountBase += triggerEventCount;