virtual zero timer (#2426)
* virtual zero timer * it would help to call the correct function Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
c716e045ae
commit
5a4c24f9a5
|
@ -175,8 +175,8 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
|
|||
|
||||
tc->vvtCamCounter++;
|
||||
|
||||
efitick_t offsetNt = nowNt - tc->timeAtVirtualZeroNt;
|
||||
angle_t currentPosition = NT2US(offsetNt) / oneDegreeUs;
|
||||
float offsetUs = tc->virtualZeroTimer.getElapsedUs(nowNt);
|
||||
angle_t currentPosition = offsetUs / oneDegreeUs;
|
||||
// convert engine cycle angle into trigger cycle angle
|
||||
currentPosition -= tdcPosition();
|
||||
// https://github.com/rusefi/rusefi/issues/1713 currentPosition could be negative that's expected
|
||||
|
@ -503,7 +503,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
|||
triggerIndexForListeners = triggerState.getCurrentIndex() + (crankInternalIndex * getTriggerSize());
|
||||
}
|
||||
if (triggerIndexForListeners == 0) {
|
||||
timeAtVirtualZeroNt = timestamp;
|
||||
virtualZeroTimer.reset(timestamp);
|
||||
}
|
||||
reportEventToWaveChart(signal, triggerIndexForListeners PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
|
|
|
@ -67,10 +67,7 @@ public:
|
|||
// synchronization event position
|
||||
angle_t vvtPosition[BANKS_COUNT][CAMS_PER_BANK];
|
||||
|
||||
/**
|
||||
* this is similar to TriggerState#startOfCycleNt but with the crank-only sensor magic
|
||||
*/
|
||||
efitick_t timeAtVirtualZeroNt = 0;
|
||||
Timer virtualZeroTimer;
|
||||
|
||||
efitick_t vvtSyncTimeNt[BANKS_COUNT][CAMS_PER_BANK];
|
||||
|
||||
|
|
|
@ -35,6 +35,10 @@ float Timer::getElapsedSeconds() const {
|
|||
}
|
||||
|
||||
float Timer::getElapsedSeconds(efitick_t nowNt) const {
|
||||
return 1e-6 * getElapsedUs(nowNt);
|
||||
}
|
||||
|
||||
float Timer::getElapsedUs(efitick_t nowNt) const {
|
||||
auto delta = nowNt - m_lastReset;
|
||||
|
||||
// Yes, things can happen slightly in the future if we get a lucky interrupt between
|
||||
|
@ -50,7 +54,7 @@ float Timer::getElapsedSeconds(efitick_t nowNt) const {
|
|||
|
||||
auto delta32 = (uint32_t)delta;
|
||||
|
||||
return 1e-6 * NT2US(delta32);
|
||||
return NT2US(delta32);
|
||||
}
|
||||
|
||||
float Timer::getElapsedSecondsAndReset(efitick_t nowNt) {
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
// then a time period representing 2^32 counts will be returned.
|
||||
float getElapsedSeconds() const;
|
||||
float getElapsedSeconds(efitick_t nowNt) const;
|
||||
float getElapsedUs(efitick_t nowNt) const;
|
||||
|
||||
// Perform an atomic update event based on the passed timestamp,
|
||||
// returning the delta between the last reset and the provided timestamp
|
||||
|
|
Loading…
Reference in New Issue