remove vvtSyncTimeNt (#3722)
* s * poke * poke again for science * kick for science * kick * kick * comment kick * s * don't try to compare the array decay pointer to 0 (!) * collateral damage * adjust miata sync * reset trigger states correctly on engine stop * s * check synchronized bit * now we don't need it at all?! * and *NOT* synced * start VVT sync earlier
This commit is contained in:
parent
9ff0dc335e
commit
c3b712aa3b
|
@ -198,18 +198,6 @@ static void doPeriodicSlowCallback() {
|
|||
|
||||
slowStartStopButtonCallback();
|
||||
|
||||
|
||||
efitick_t nowNt = getTimeNowNt();
|
||||
for (int bankIndex = 0; bankIndex < BANKS_COUNT; bankIndex++) {
|
||||
for (int camIndex = 0; camIndex < CAMS_PER_BANK; camIndex++) {
|
||||
if (nowNt - engine->triggerCentral.vvtSyncTimeNt[bankIndex][camIndex] >= NT_PER_SECOND) {
|
||||
// loss of VVT sync
|
||||
// todo: this code would get simpler if we convert vvtSyncTimeNt to Timer
|
||||
engine->triggerCentral.vvtSyncTimeNt[bankIndex][camIndex] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
engine->rpmCalculator.onSlowCallback();
|
||||
|
||||
if (engine->directSelfStimulation || engine->rpmCalculator.isStopped()) {
|
||||
|
|
|
@ -351,7 +351,8 @@ static bool noFiringUntilVvtSync(vvt_mode_e vvtMode) {
|
|||
void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
|
||||
ScopePerf perf(PE::MainTriggerCallback);
|
||||
|
||||
if (noFiringUntilVvtSync(engineConfiguration->vvtMode[0]) && engine->triggerCentral.vvtSyncTimeNt[0][0] == 0) {
|
||||
if (noFiringUntilVvtSync(engineConfiguration->vvtMode[0])
|
||||
&& !engine->triggerCentral.vvtState[0][0].getShaftSynchronized()) {
|
||||
// Any engine that requires cam-assistance for a full crank sync (symmetrical crank) can't schedule until we have cam sync
|
||||
// examples:
|
||||
// NB2, Nissan VQ/MR: symmetrical crank wheel and we need to make sure no spark happens out of sync
|
||||
|
|
|
@ -41,8 +41,7 @@ static scheduling_s debugToggleScheduling;
|
|||
TriggerCentral::TriggerCentral() :
|
||||
vvtEventRiseCounter(),
|
||||
vvtEventFallCounter(),
|
||||
vvtPosition(),
|
||||
vvtSyncTimeNt()
|
||||
vvtPosition()
|
||||
{
|
||||
memset(&hwEventCounters, 0, sizeof(hwEventCounters));
|
||||
triggerState.resetTriggerState();
|
||||
|
@ -264,14 +263,8 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
|
|||
|
||||
logFront(isImportantFront, nowNt, index);
|
||||
|
||||
|
||||
auto currentPhase = tc->getCurrentEnginePhase(nowNt);
|
||||
if (!currentPhase) {
|
||||
// todo: this code branch is slowing NB2 cranking since we require RPM sync for VVT sync!
|
||||
// todo: smarter code
|
||||
//
|
||||
// we are here if we are getting VVT position signals while engine is not running
|
||||
// for example if crank position sensor is broken :)
|
||||
// If the main trigger is not synchronized, don't decode VVT yet
|
||||
if (!tc->triggerState.getShaftSynchronized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -291,6 +284,13 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
|
|||
|
||||
tc->vvtCamCounter++;
|
||||
|
||||
auto currentPhase = tc->getCurrentEnginePhase(nowNt);
|
||||
if (!currentPhase) {
|
||||
// If we couldn't resolve engine speed (yet primary trigger is sync'd), this
|
||||
// probably means that we have partial crank sync, but not RPM information yet
|
||||
return;
|
||||
}
|
||||
|
||||
angle_t currentPosition = currentPhase.Value;
|
||||
// convert engine cycle angle into trigger cycle angle
|
||||
currentPosition -= tdcPosition();
|
||||
|
@ -332,8 +332,6 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
|
|||
break;
|
||||
}
|
||||
|
||||
tc->vvtSyncTimeNt[bankIndex][camIndex] = nowNt;
|
||||
|
||||
auto vvtPosition = engineConfiguration->vvtOffsets[bankIndex * CAMS_PER_BANK + camIndex] - currentPosition;
|
||||
|
||||
if (index != 0) {
|
||||
|
|
|
@ -93,9 +93,6 @@ public:
|
|||
// synchronization event position
|
||||
angle_t vvtPosition[BANKS_COUNT][CAMS_PER_BANK];
|
||||
|
||||
// todo: convert to Timer!
|
||||
efitick_t vvtSyncTimeNt[BANKS_COUNT][CAMS_PER_BANK];
|
||||
|
||||
TriggerStateWithRunningStatistics triggerState;
|
||||
TriggerWaveform triggerShape;
|
||||
|
||||
|
|
Loading…
Reference in New Issue