simplify adjustCrankPhase
(cherry picked from commit 7ae11160d9bfb31a664130e66586e849b8201c8a)
This commit is contained in:
parent
103a537bdb
commit
7f67ecd02d
|
@ -161,25 +161,27 @@ static angle_t adjustCrankPhase(int camIndex) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerCentral *tc = getTriggerCentral();
|
|
||||||
operation_mode_e operationMode = getEngineRotationState()->getOperationMode();
|
operation_mode_e operationMode = getEngineRotationState()->getOperationMode();
|
||||||
|
|
||||||
|
auto crankDivider = getCrankDivider(operationMode);
|
||||||
|
if (crankDivider == 1) {
|
||||||
|
// Crank divider of 1 means there's no ambiguity, so don't try to resolve it
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TriggerCentral *tc = getTriggerCentral();
|
||||||
|
|
||||||
vvt_mode_e vvtMode = engineConfiguration->vvtMode[camIndex];
|
vvt_mode_e vvtMode = engineConfiguration->vvtMode[camIndex];
|
||||||
switch (vvtMode) {
|
switch (vvtMode) {
|
||||||
case VVT_FIRST_HALF:
|
case VVT_FIRST_HALF:
|
||||||
case VVT_MAP_V_TWIN:
|
case VVT_MAP_V_TWIN:
|
||||||
case VVT_MITSUBISHI_4G63:
|
case VVT_MITSUBISHI_4G63:
|
||||||
case VVT_MITSUBISHI_4G9x:
|
case VVT_MITSUBISHI_4G9x:
|
||||||
return tc->syncAndReport(getCrankDivider(operationMode), 1);
|
return tc->syncAndReport(crankDivider, 1);
|
||||||
case VVT_SECOND_HALF:
|
case VVT_SECOND_HALF:
|
||||||
case VVT_NISSAN_VQ:
|
case VVT_NISSAN_VQ:
|
||||||
case VVT_BOSCH_QUICK_START:
|
case VVT_BOSCH_QUICK_START:
|
||||||
return tc->syncAndReport(getCrankDivider(operationMode), 0);
|
|
||||||
case VVT_MIATA_NB:
|
case VVT_MIATA_NB:
|
||||||
/**
|
|
||||||
* NB2 is a symmetrical crank, there are four phases total
|
|
||||||
*/
|
|
||||||
return tc->syncAndReport(getCrankDivider(operationMode), 0);
|
|
||||||
case VVT_2JZ:
|
case VVT_2JZ:
|
||||||
case VVT_TOYOTA_4_1:
|
case VVT_TOYOTA_4_1:
|
||||||
case VVT_FORD_COYOTE:
|
case VVT_FORD_COYOTE:
|
||||||
|
@ -190,7 +192,7 @@ static angle_t adjustCrankPhase(int camIndex) {
|
||||||
case VVT_MITSUBISHI_3A92:
|
case VVT_MITSUBISHI_3A92:
|
||||||
case VVT_MITSUBISHI_6G75:
|
case VVT_MITSUBISHI_6G75:
|
||||||
case VVT_HONDA_K_EXHAUST:
|
case VVT_HONDA_K_EXHAUST:
|
||||||
return tc->syncAndReport(getCrankDivider(operationMode), engineConfiguration->vvtBooleanForVerySpecialCases ? 1 : 0);
|
return tc->syncAndReport(crankDivider, 0);
|
||||||
case VVT_HONDA_K_INTAKE:
|
case VVT_HONDA_K_INTAKE:
|
||||||
// with 4 evenly spaced tooth we cannot use this wheel for engine sync
|
// with 4 evenly spaced tooth we cannot use this wheel for engine sync
|
||||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Honda K Intake is not suitable for engine sync");
|
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Honda K Intake is not suitable for engine sync");
|
||||||
|
|
|
@ -221,7 +221,8 @@ int TriggerDecoderBase::getCurrentIndex() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
angle_t PrimaryTriggerDecoder::syncEnginePhase(int divider, int remainder, angle_t engineCycle) {
|
angle_t PrimaryTriggerDecoder::syncEnginePhase(int divider, int remainder, angle_t engineCycle) {
|
||||||
efiAssert(ObdCode::OBD_PCM_Processor_Fault, remainder < divider, "syncEnginePhase", false);
|
efiAssert(ObdCode::OBD_PCM_Processor_Fault, divider > 1, "syncEnginePhase divider", false);
|
||||||
|
efiAssert(ObdCode::OBD_PCM_Processor_Fault, remainder < divider, "syncEnginePhase remainder", false);
|
||||||
angle_t totalShift = 0;
|
angle_t totalShift = 0;
|
||||||
while (getCrankSynchronizationCounter() % divider != remainder) {
|
while (getCrankSynchronizationCounter() % divider != remainder) {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -79,7 +79,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
||||||
eth.assertEvent5("inj end#2", 1, (void*)endSimultaneousInjection, 149999);
|
eth.assertEvent5("inj end#2", 1, (void*)endSimultaneousInjection, 149999);
|
||||||
|
|
||||||
// Now perform a fake VVT sync and check that ignition mode changes to sequential
|
// Now perform a fake VVT sync and check that ignition mode changes to sequential
|
||||||
engine->triggerCentral.syncAndReport(1, 0);
|
engine->triggerCentral.syncAndReport(2, 0);
|
||||||
ASSERT_EQ(IM_SEQUENTIAL, getCurrentIgnitionMode());
|
ASSERT_EQ(IM_SEQUENTIAL, getCurrentIgnitionMode());
|
||||||
|
|
||||||
// skip, clear & advance 1 more revolution at higher RPM
|
// skip, clear & advance 1 more revolution at higher RPM
|
||||||
|
|
|
@ -1017,7 +1017,7 @@ TEST(big, testSparkReverseOrderBug319) {
|
||||||
|
|
||||||
setConstantDwell(45);
|
setConstantDwell(45);
|
||||||
|
|
||||||
engine->triggerCentral.syncAndReport(1, 0);
|
engine->triggerCentral.syncAndReport(2, 0);
|
||||||
|
|
||||||
// this is needed to update injectorLag
|
// this is needed to update injectorLag
|
||||||
engine->updateSlowSensors();
|
engine->updateSlowSensors();
|
||||||
|
@ -1030,7 +1030,7 @@ TEST(big, testSparkReverseOrderBug319) {
|
||||||
eth.fireRise(20);
|
eth.fireRise(20);
|
||||||
eth.fireFall(20);
|
eth.fireFall(20);
|
||||||
|
|
||||||
engine->triggerCentral.syncAndReport(1, 0);
|
engine->triggerCentral.syncAndReport(2, 0);
|
||||||
|
|
||||||
eth.executeActions();
|
eth.executeActions();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue