VVT support for VAG trigger #883

This commit is contained in:
rusefi 2020-08-27 00:06:10 -04:00
parent 10a6661fa5
commit 2b77901e53
5 changed files with 18 additions and 9 deletions

View File

@ -102,27 +102,23 @@ void Engine::initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_
* 'initState' instance of TriggerState is used only to initialize 'this' TriggerWaveform instance
* #192 BUG real hardware trigger events could be coming even while we are initializing trigger
*/
initState.resetTriggerState();
calculateTriggerSynchPoint(&ENGINE(triggerCentral.triggerShape),
&initState PASS_ENGINE_PARAMETER_SUFFIX);
if (engine->triggerCentral.triggerShape.getSize() == 0) {
firmwareError(CUSTOM_ERR_TRIGGER_ZERO, "triggerShape size is zero");
}
engine->engineCycleEventCount = TRIGGER_WAVEFORM(getLength());
}
if (engineConfiguration->vvtMode != VVT_INACTIVE) {
trigger_config_s config;
config.type = getVvtTriggerType(engineConfiguration->vvtMode);
ENGINE(triggerCentral).vvtTriggerType = config.type = getVvtTriggerType(engineConfiguration->vvtMode);
ENGINE(triggerCentral).vvtShape.initializeTriggerWaveform(logger,
engineConfiguration->ambiguousOperationMode,
engineConfiguration->useOnlyRisingEdgeForTrigger, &config);
engine->engineConfigurationPtr->vvtCamSensorUseRise, &config);
ENGINE(triggerCentral).vvtShape.initializeSyncPoint(&initState,
&engine->primaryTriggerConfiguration,
&engine->vvtTriggerConfiguration,
&config);
}

View File

@ -310,7 +310,7 @@ VvtTriggerConfiguration::VvtTriggerConfiguration(Engine *engine) {
}
bool VvtTriggerConfiguration::isUseOnlyRisingEdgeForTrigger() const {
return engine->engineConfigurationPtr->useOnlyRisingEdgeForTrigger;
return engine->engineConfigurationPtr->vvtCamSensorUseRise;
}
debug_mode_e VvtTriggerConfiguration::getDebugMode() const {
@ -318,7 +318,7 @@ debug_mode_e VvtTriggerConfiguration::getDebugMode() const {
}
trigger_type_e VvtTriggerConfiguration::getType() const {
return engine->engineConfigurationPtr->trigger.type;
return engine->triggerCentral.vvtTriggerType;
}
bool VvtTriggerConfiguration::isSilentTriggerError() const {

View File

@ -145,6 +145,14 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt DECLARE_ENGINE_
return;
}
ENGINE(triggerCentral).vvtState.decodeTriggerEvent(
&ENGINE(triggerCentral).vvtShape,
nullptr,
nullptr,
&engine->vvtTriggerConfiguration,
front == TV_RISE ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING, nowNt);
tc->vvtCamCounter++;
efitick_t offsetNt = nowNt - tc->timeAtVirtualZeroNt;

View File

@ -45,6 +45,7 @@ public:
TriggerNoiseFilter noiseFilter;
trigger_type_e vvtTriggerType;
angle_t getVVTPosition();
// latest VVT event position (could be not synchronization event)

View File

@ -126,6 +126,7 @@ void TriggerWaveform::initializeSyncPoint(TriggerState *state,
*/
void calculateTriggerSynchPoint(TriggerWaveform *shape,
TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) {
state->resetTriggerState();
#if EFI_PROD_CODE
efiAssertVoid(CUSTOM_TRIGGER_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "calc s");
#endif
@ -144,6 +145,9 @@ void calculateTriggerSynchPoint(TriggerWaveform *shape,
shape->setShapeDefinitionError(true);
return;
}
if (shape->getSize() == 0) {
firmwareError(CUSTOM_ERR_TRIGGER_ZERO, "triggerShape size is zero");
}
}
void prepareEventAngles(TriggerWaveform *shape,