auto-sync
This commit is contained in:
parent
ff55c3f11a
commit
ea18487b54
|
@ -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);
|
||||||
|
|
|
@ -55,7 +55,7 @@ static inline bool isSynchronizationGap(TriggerState const *shaftPositionState,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ! EFI_PROD_CODE
|
#if ! EFI_PROD_CODE
|
||||||
if(printGapRatio) {
|
if (printGapRatio) {
|
||||||
|
|
||||||
float gap = 1.0 * currentDuration / shaftPositionState->toothed_previous_duration;
|
float gap = 1.0 * currentDuration / shaftPositionState->toothed_previous_duration;
|
||||||
print("current gap %f\r\n", gap);
|
print("current gap %f\r\n", gap);
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue