From 9cc4efd454a877f11f208cc1afd028856fad7363 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Fri, 14 Nov 2014 15:03:52 -0600 Subject: [PATCH] auto-sync --- .../controllers/trigger/trigger_central.cpp | 2 +- .../controllers/trigger/trigger_decoder.cpp | 18 +++++++++--------- .../controllers/trigger/trigger_structure.cpp | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 7b6eea79ac..a4d46951f1 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -127,7 +127,7 @@ void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) { /** * 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) { // we should not propagate event if we do not know where we are diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 805b225c3a..69638a2af4 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -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 */ 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? 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. */ - nextTriggerEvent(triggerWheel, nowUs); + nextTriggerEvent(triggerWheel, nowNt); if (triggerShape->gapBothDirections) { - toothed_previous_duration = getCurrentGapDuration(nowUs); + toothed_previous_duration = getCurrentGapDuration(nowNt); isFirstEvent = false; - toothed_previous_time = nowUs; + toothed_previous_time = nowNt; } return; } - int64_t currentDuration = getCurrentGapDuration(nowUs); + int64_t currentDuration = getCurrentGapDuration(nowNt); isFirstEvent = false; efiAssertVoid(currentDuration >= 0, "decode: negative duration?"); @@ -164,15 +164,15 @@ void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigge shaft_is_synchronized = true; // this call would update duty cycle values - nextTriggerEvent(triggerWheel, nowUs); + nextTriggerEvent(triggerWheel, nowNt); - nextRevolution(triggerShape->shaftPositionEventCount, nowUs); + nextRevolution(triggerShape->shaftPositionEventCount, nowNt); } else { - nextTriggerEvent(triggerWheel, nowUs); + nextTriggerEvent(triggerWheel, nowNt); } toothed_previous_duration = currentDuration; - toothed_previous_time = nowUs; + toothed_previous_time = nowNt; } static void initializeSkippedToothTriggerShape(trigger_shape_s *s, int totalTeethCount, int skippedCount, diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index f22ff705ab..34f77c60ad 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -137,13 +137,13 @@ uint64_t TriggerState::getTotalEventCounter() { return totalEventCountBase + current_index; } -void TriggerState::nextRevolution(int triggerEventCount, uint64_t nowUs) { +void TriggerState::nextRevolution(int triggerEventCount, uint64_t nowNt) { if (cycleCallback != NULL) { cycleCallback(this); } memcpy(prevTotalTime, totalTime, sizeof(prevTotalTime)); - prevCycleDuration = nowUs - startOfCycle; - startOfCycle = nowUs; + prevCycleDuration = nowNt - startOfCycle; + startOfCycle = nowNt; clear(); totalRevolutionCounter++; totalEventCountBase += triggerEventCount;