auto-sync

This commit is contained in:
rusEfi 2014-10-29 16:03:10 -05:00
parent ff55c3f11a
commit ea18487b54
4 changed files with 22 additions and 3 deletions

View File

@ -13,6 +13,8 @@ void configureNeon2003TriggerShape(trigger_shape_s *s) {
// voodoo magic - we always need 720 at the end // voodoo magic - we always need 720 at the end
int base = 10; int base = 10;
s->gapBothDirections = true;
setTriggerSynchronizationGap(s, 2.5); setTriggerSynchronizationGap(s, 2.5);
s->addEvent(base + 26, T_PRIMARY, TV_HIGH); s->addEvent(base + 26, T_PRIMARY, TV_HIGH);

View File

@ -89,6 +89,12 @@ float TriggerState::getTriggerDutyCycle(int index) {
static trigger_wheel_e eventIndex[6] = { T_PRIMARY, T_PRIMARY, T_SECONDARY, T_SECONDARY, T_CHANNEL_3, T_CHANNEL_3 }; static trigger_wheel_e eventIndex[6] = { T_PRIMARY, T_PRIMARY, T_SECONDARY, T_SECONDARY, T_CHANNEL_3, T_CHANNEL_3 };
static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW, TV_HIGH }; static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW, TV_HIGH };
uint64_t TriggerState::getCurrentGapDuration(uint64_t nowUs) {
int64_t currentDuration = isFirstEvent ? 0 : nowUs - toothed_previous_time;
isFirstEvent = false;
return currentDuration;
}
/** /**
* @brief Trigger decoding happens here * @brief Trigger decoding happens here
* 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
@ -110,11 +116,14 @@ 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, nowUs);
if (triggerShape->gapBothDirections) {
// toothed_previous_duration = getCurrentGapDuration(nowUs);
// toothed_previous_time = nowUs;
}
return; return;
} }
int64_t currentDuration = isFirstEvent ? 0 : nowUs - toothed_previous_time; int64_t currentDuration = getCurrentGapDuration(nowUs);
isFirstEvent = false;
efiAssertVoid(currentDuration >= 0, "decode: negative duration?"); efiAssertVoid(currentDuration >= 0, "decode: negative duration?");
// todo: skip a number of signal from the beginning // todo: skip a number of signal from the beginning

View File

@ -50,6 +50,7 @@ public:
private: private:
void clear(); void clear();
uint64_t getCurrentGapDuration(uint64_t nowUs);
/** /**
* index within trigger revolution, from 0 to trigger event count * index within trigger revolution, from 0 to trigger event count
*/ */

View File

@ -39,7 +39,14 @@ public:
float syncRatioFrom; float syncRatioFrom;
float syncRatioTo; float syncRatioTo;
/**
* Should we use falls or rises for gap ratio detection?
*/
bool_t useRiseEdge; bool_t useRiseEdge;
/**
* Should we measure gaps with events of both kinds?
*/
bool_t gapBothDirections;
/** /**
* This is used for signal validation * This is used for signal validation