Nissan VVT trigger decoder #2887
This commit is contained in:
parent
0af1e8ee59
commit
e5a1b68eb2
|
@ -133,7 +133,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
|
||||||
tooth = front == TV_RISE ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING;
|
tooth = front == TV_RISE ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING;
|
||||||
} else {
|
} else {
|
||||||
// todo: nicer solution is needed
|
// todo: nicer solution is needed
|
||||||
tooth = front == TV_RISE ? SHAFT_3RD_FALLING : SHAFT_3RD_FALLING;
|
tooth = front == TV_RISE ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogTriggerTooth(tooth, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
LogTriggerTooth(tooth, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
int toothIndex;
|
int toothIndex;
|
||||||
TriggerWaveform *form;
|
TriggerWaveform *form;
|
||||||
bool isVvt;
|
bool isVvt;
|
||||||
|
int vvtIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
void func(TriggerCallback *callback) {
|
void func(TriggerCallback *callback) {
|
||||||
|
@ -25,14 +26,17 @@ void func(TriggerCallback *callback) {
|
||||||
efitick_t nowNt = getTimeNowNt();
|
efitick_t nowNt = getTimeNowNt();
|
||||||
if (callback->isVvt) {
|
if (callback->isVvt) {
|
||||||
trigger_value_e v = value ? TV_RISE : TV_FALL;
|
trigger_value_e v = value ? TV_RISE : TV_FALL;
|
||||||
hwHandleVvtCamSignal(v, nowNt, 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
hwHandleVvtCamSignal(v, nowNt, callback->vvtIndex PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
} else {
|
} else {
|
||||||
handleShaftSignal(0, value, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
handleShaftSignal(0, value, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void scheduleTriggerEvents(TriggerWaveform *shape, int count, bool isVvt DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
static void scheduleTriggerEvents(TriggerWaveform *shape, int count, bool isVvt,
|
||||||
|
int vvtIndex,
|
||||||
|
int vvtOffset
|
||||||
|
DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
int totalIndex = 0;
|
int totalIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,12 +45,13 @@ static void scheduleTriggerEvents(TriggerWaveform *shape, int count, bool isVvt
|
||||||
*/
|
*/
|
||||||
for (int r = 0; r < count; r++) {
|
for (int r = 0; r < count; r++) {
|
||||||
for (int i = 0; i < shape->getSize(); i++) {
|
for (int i = 0; i < shape->getSize(); i++) {
|
||||||
float angle = shape->getAngle(totalIndex);
|
float angle = vvtOffset + shape->getAngle(totalIndex);
|
||||||
TriggerCallback *param = new TriggerCallback();
|
TriggerCallback *param = new TriggerCallback();
|
||||||
param->engine = engine;
|
param->engine = engine;
|
||||||
param->toothIndex = totalIndex;
|
param->toothIndex = totalIndex;
|
||||||
param->form = shape;
|
param->form = shape;
|
||||||
param->isVvt = isVvt;
|
param->isVvt = isVvt;
|
||||||
|
param->vvtIndex = vvtIndex;
|
||||||
|
|
||||||
scheduling_s *sch = new scheduling_s();
|
scheduling_s *sch = new scheduling_s();
|
||||||
engine->executor.scheduleByTimestamp(sch, 1000 * angle, { func, param });
|
engine->executor.scheduleByTimestamp(sch, 1000 * angle, { func, param });
|
||||||
|
@ -67,16 +72,28 @@ TEST(nissan, vq_vvt) {
|
||||||
static TriggerWaveform crank;
|
static TriggerWaveform crank;
|
||||||
initializeNissanVQcrank(&crank);
|
initializeNissanVQcrank(&crank);
|
||||||
|
|
||||||
scheduleTriggerEvents(&crank, cyclesCount, false PASS_ENGINE_PARAMETER_SUFFIX);
|
scheduleTriggerEvents(&crank, cyclesCount, false, -1, 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
static TriggerWaveform vvt;
|
static TriggerWaveform vvt;
|
||||||
initializeNissanVQvvt(&vvt);
|
initializeNissanVQvvt(&vvt);
|
||||||
|
|
||||||
scheduleTriggerEvents(&vvt, cyclesCount / 6, true PASS_ENGINE_PARAMETER_SUFFIX);
|
scheduleTriggerEvents(&vvt, cyclesCount / 6, true,
|
||||||
|
/* vvtIndex */ 0,
|
||||||
|
/* vvtOffset */ 0
|
||||||
|
PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
static TriggerWaveform vvt;
|
||||||
|
initializeNissanVQvvt(&vvt);
|
||||||
|
|
||||||
|
scheduleTriggerEvents(&vvt, cyclesCount / 6, true,
|
||||||
|
/* vvtIndex */1,
|
||||||
|
/* vvtOffset */ 360
|
||||||
|
PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
}
|
||||||
|
|
||||||
scheduling_s *head;
|
scheduling_s *head;
|
||||||
while ((head = engine->executor.getHead()) != nullptr) {
|
while ((head = engine->executor.getHead()) != nullptr) {
|
||||||
|
|
Loading…
Reference in New Issue