vvt/cam events to pass index
This commit is contained in:
parent
d116101e1a
commit
869e4cfc49
|
@ -90,7 +90,7 @@ static bool vvtWithRealDecoder(vvt_mode_e vvtMode) {
|
|||
|| vvtMode == VVT_4_1;
|
||||
}
|
||||
|
||||
void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
int bankIndex = 0;
|
||||
TriggerCentral *tc = &engine->triggerCentral;
|
||||
if (front == TV_RISE) {
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
|
||||
void triggerInfo(void);
|
||||
void hwHandleShaftSignal(trigger_event_e signal, efitick_t timestamp);
|
||||
void hwHandleVvtCamSignal(trigger_value_e front, efitick_t timestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void hwHandleVvtCamSignal(trigger_value_e front, efitick_t timestamp, int index DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
void initTriggerCentral(Logging *sharedLogger);
|
||||
|
||||
|
|
|
@ -83,9 +83,9 @@ static void comp_cam_callback(COMPDriver *comp) {
|
|||
efitick_t stamp = getTimeNowNt();
|
||||
|
||||
if (isRising) {
|
||||
hwHandleVvtCamSignal(TV_RISE, stamp);
|
||||
hwHandleVvtCamSignal(TV_RISE, stamp, index);
|
||||
} else {
|
||||
hwHandleVvtCamSignal(TV_FALL, stamp);
|
||||
hwHandleVvtCamSignal(TV_FALL, stamp, index);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -73,9 +73,9 @@ static void cam_callback(void *arg) {
|
|||
bool rise = (palReadLine(pal_line) == PAL_HIGH);
|
||||
|
||||
if (rise ^ engineConfiguration->invertCamVVTSignal) {
|
||||
hwHandleVvtCamSignal(TV_RISE, stamp);
|
||||
hwHandleVvtCamSignal(TV_RISE, stamp, index);
|
||||
} else {
|
||||
hwHandleVvtCamSignal(TV_FALL, stamp);
|
||||
hwHandleVvtCamSignal(TV_FALL, stamp, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,31 +27,34 @@ EXTERN_ENGINE;
|
|||
|
||||
static Logging *logger;
|
||||
|
||||
static void vvtRisingCallback(void *) {
|
||||
static void vvtRisingCallback(void *arg) {
|
||||
efitick_t now = getTimeNowNt();
|
||||
if (!engine->hwTriggerInputEnabled) {
|
||||
return;
|
||||
}
|
||||
int index = (int)arg;
|
||||
|
||||
#if EFI_TOOTH_LOGGER
|
||||
if (!CONFIG(displayLogicLevelsInEngineSniffer)) {
|
||||
// real physical fronts go into engine sniffer
|
||||
LogTriggerTooth(SHAFT_SECONDARY_RISING, now);
|
||||
}
|
||||
#endif /* EFI_TOOTH_LOGGER */
|
||||
hwHandleVvtCamSignal(engineConfiguration->invertCamVVTSignal ? TV_FALL : TV_RISE, now);
|
||||
hwHandleVvtCamSignal(engineConfiguration->invertCamVVTSignal ? TV_FALL : TV_RISE, now, index);
|
||||
}
|
||||
|
||||
static void vvtFallingCallback(void *) {
|
||||
static void vvtFallingCallback(void * arg) {
|
||||
efitick_t now = getTimeNowNt();
|
||||
if (!engine->hwTriggerInputEnabled) {
|
||||
return;
|
||||
}
|
||||
int index = (int)arg;
|
||||
#if EFI_TOOTH_LOGGER
|
||||
if (!CONFIG(displayLogicLevelsInEngineSniffer)) {
|
||||
LogTriggerTooth(SHAFT_SECONDARY_FALLING, now);
|
||||
}
|
||||
#endif /* EFI_TOOTH_LOGGER */
|
||||
hwHandleVvtCamSignal(engineConfiguration->invertCamVVTSignal ? TV_RISE : TV_FALL, now);
|
||||
hwHandleVvtCamSignal(engineConfiguration->invertCamVVTSignal ? TV_RISE : TV_FALL, now, index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,8 +120,9 @@ int icuTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft) {
|
|||
input->setWidthCallback((VoidInt)(void*)shaftRisingCallback, arg);
|
||||
input->setPeriodCallback((VoidInt)(void*)shaftFallingCallback, arg);
|
||||
} else {
|
||||
input->setWidthCallback((VoidInt)(void*)vvtRisingCallback, NULL);
|
||||
input->setPeriodCallback((VoidInt)(void*)vvtFallingCallback, NULL);
|
||||
void * arg = (void *)index;
|
||||
input->setWidthCallback((VoidInt)(void*)vvtRisingCallback, arg);
|
||||
input->setPeriodCallback((VoidInt)(void*)vvtFallingCallback, arg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -28,8 +28,8 @@ TEST(sensors, test2jz) {
|
|||
|
||||
eth.moveTimeForwardUs(MS2US(3)); // shifting VVT phase a few angles
|
||||
|
||||
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
// currentPosition
|
||||
ASSERT_NEAR(608.2 - 720, engine->triggerCentral.currentVVTEventPosition, EPS3D);
|
||||
|
|
|
@ -107,7 +107,7 @@ TEST(sensors, testCamInput) {
|
|||
|
||||
for (int i = 0; i < 600;i++) {
|
||||
eth.moveTimeForwardUs(MS2US(10));
|
||||
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
eth.moveTimeForwardUs(MS2US(40));
|
||||
eth.firePrimaryTriggerRise();
|
||||
}
|
||||
|
@ -143,21 +143,21 @@ TEST(sensors, testNB2CamInput) {
|
|||
eth.moveTimeForwardUs(MS2US(3)); // shifting VVT phase a few angles
|
||||
|
||||
// this would be ignored since we only consume the other kind of fronts here
|
||||
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
eth.moveTimeForwardUs(MS2US(20));
|
||||
// this would be be first VVT signal - gap duration would be calculated against 'DEEP_IN_THE_PAST_SECONDS' initial value
|
||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
eth.moveTimeForwardUs(MS2US(20));
|
||||
// this second important front would give us first real VVT gap duration
|
||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, engine->triggerCentral.getVVTPosition());
|
||||
ASSERT_EQ(totalRevolutionCountBeforeVvtSync, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
|
||||
|
||||
eth.moveTimeForwardUs(MS2US(130));
|
||||
// this third important front would give us first comparison between two real gaps
|
||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
ASSERT_NEAR(-67.6 - 720 - 720, engine->triggerCentral.getVVTPosition(), EPS3D);
|
||||
// actually position based on VVT!
|
||||
|
|
Loading…
Reference in New Issue