trigger refactoring: instance RPM #4740

This commit is contained in:
Andrey 2022-11-06 11:05:57 -05:00
parent b5796c121d
commit a5136a0eae
4 changed files with 10 additions and 9 deletions

View File

@ -124,10 +124,10 @@ static bool vvtWithRealDecoder(vvt_mode_e vvtMode) {
&& vvtMode != VVT_FIRST_HALF; && vvtMode != VVT_FIRST_HALF;
} }
static angle_t syncAndReport(TriggerCentral *tc, int divider, int remainder) { angle_t TriggerCentral::syncAndReport(int divider, int remainder) {
angle_t engineCycle = getEngineCycle(getEngineRotationState()->getOperationMode()); angle_t engineCycle = getEngineCycle(getEngineRotationState()->getOperationMode());
return tc->triggerState.syncEnginePhase(divider, remainder, engineCycle); return triggerState.syncEnginePhase(divider, remainder, engineCycle);
} }
static void turnOffAllDebugFields(void *arg) { static void turnOffAllDebugFields(void *arg) {
@ -162,16 +162,16 @@ static angle_t adjustCrankPhase(int camIndex) {
switch (vvtMode) { switch (vvtMode) {
case VVT_FIRST_HALF: case VVT_FIRST_HALF:
case VVT_MAP_V_TWIN: case VVT_MAP_V_TWIN:
return syncAndReport(tc, getCrankDivider(operationMode), 1); return tc->syncAndReport(getCrankDivider(operationMode), 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 syncAndReport(tc, getCrankDivider(operationMode), 0); return tc->syncAndReport(getCrankDivider(operationMode), 0);
case VVT_MIATA_NB: case VVT_MIATA_NB:
/** /**
* NB2 is a symmetrical crank, there are four phases total * NB2 is a symmetrical crank, there are four phases total
*/ */
return syncAndReport(tc, getCrankDivider(operationMode), 0); 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_ST170: case VVT_FORD_ST170:
@ -181,7 +181,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 syncAndReport(tc, getCrankDivider(operationMode), engineConfiguration->vvtBooleanForVerySpecialCases ? 1 : 0); return tc->syncAndReport(getCrankDivider(operationMode), engineConfiguration->vvtBooleanForVerySpecialCases ? 1 : 0);
case VVT_HONDA_K_INTAKE: case VVT_HONDA_K_INTAKE:
case VVT_INACTIVE: case VVT_INACTIVE:
// do nothing // do nothing

View File

@ -48,6 +48,7 @@ public:
class TriggerCentral final : public trigger_central_s { class TriggerCentral final : public trigger_central_s {
public: public:
TriggerCentral(); TriggerCentral();
angle_t syncAndReport(int divider, int remainder);
void handleShaftSignal(trigger_event_e signal, efitick_t timestamp); void handleShaftSignal(trigger_event_e signal, efitick_t timestamp);
int getHwEventCounter(int index) const; int getHwEventCounter(int index) const;
void resetCounters(); void resetCounters();

View File

@ -78,7 +78,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.triggerState.syncEnginePhase(1, 0, 720); engine->triggerCentral.syncAndReport(1, 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

View File

@ -1056,7 +1056,7 @@ TEST(big, testSparkReverseOrderBug319) {
setConstantDwell(45); setConstantDwell(45);
engine->triggerCentral.triggerState.syncEnginePhase(1, 0, 720); engine->triggerCentral.syncAndReport(1, 0);
// this is needed to update injectorLag // this is needed to update injectorLag
engine->updateSlowSensors(); engine->updateSlowSensors();
@ -1069,7 +1069,7 @@ TEST(big, testSparkReverseOrderBug319) {
eth.fireRise(20); eth.fireRise(20);
eth.fireFall(20); eth.fireFall(20);
engine->triggerCentral.triggerState.syncEnginePhase(1, 0, 720); engine->triggerCentral.syncAndReport(1, 0);
eth.executeActions(); eth.executeActions();