VVT support for VAG trigger #883
This commit is contained in:
parent
3a2670d5de
commit
a98c622b54
|
@ -291,7 +291,8 @@ void hwHandleShaftSignal(trigger_event_e signal, efitick_t timestamp) {
|
|||
// for effective noise filtering, we need both signal edges,
|
||||
// so we pass them to handleShaftSignal() and defer this test
|
||||
if (!CONFIG(useNoiselessTriggerDecoder)) {
|
||||
if (!isUsefulSignal(signal PASS_CONFIG_PARAMETER_SUFFIX)) {
|
||||
const TriggerConfiguration * triggerConfiguration = &engine->primaryTriggerConfiguration;
|
||||
if (!isUsefulSignal(signal, triggerConfiguration)) {
|
||||
/**
|
||||
* no need to process VR falls further
|
||||
*/
|
||||
|
@ -435,8 +436,9 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
|||
if (!noiseFilter.noiseFilter(timestamp, &triggerState, signal PASS_ENGINE_PARAMETER_SUFFIX)) {
|
||||
return;
|
||||
}
|
||||
const TriggerConfiguration * triggerConfiguration = &engine->primaryTriggerConfiguration;
|
||||
// moved here from hwHandleShaftSignal()
|
||||
if (!isUsefulSignal(signal PASS_CONFIG_PARAMETER_SUFFIX)) {
|
||||
if (!isUsefulSignal(signal, triggerConfiguration)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -691,7 +691,7 @@ uint32_t TriggerState::findTriggerZeroEventIndex(TriggerWaveform * shape,
|
|||
|
||||
uint32_t syncIndex = helper.findTriggerSyncPoint(shape,
|
||||
triggerConfiguration,
|
||||
this PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
this);
|
||||
if (syncIndex == EFI_ERROR_CODE) {
|
||||
return syncIndex;
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ uint32_t TriggerState::findTriggerZeroEventIndex(TriggerWaveform * shape,
|
|||
*/
|
||||
|
||||
helper.assertSyncPositionAndSetDutyCycle(onFindIndexCallback, triggerConfiguration,
|
||||
syncIndex, this, shape PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
syncIndex, this, shape);
|
||||
|
||||
return syncIndex % shape->getSize();
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ static const bool isRisingEdge[HW_EVENT_TYPES] = { false, true, false, true, fal
|
|||
* todo: should this method be invoked somewhere deeper? at the moment we have too many usages too high
|
||||
* @return true if front should be decoded further, false if we are not interested
|
||||
*/
|
||||
bool isUsefulSignal(trigger_event_e signal DECLARE_CONFIG_PARAMETER_SUFFIX) {
|
||||
return !engineConfiguration->useOnlyRisingEdgeForTrigger || isRisingEdge[(int) signal];
|
||||
bool isUsefulSignal(trigger_event_e signal, const TriggerConfiguration * triggerConfiguration) {
|
||||
return !triggerConfiguration->isUseOnlyRisingEdgeForTrigger() || isRisingEdge[(int) signal];
|
||||
}
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
|
@ -32,7 +32,7 @@ extern bool printTriggerDebug;
|
|||
void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback,
|
||||
const TriggerConfiguration * triggerConfiguration,
|
||||
TriggerState *state, TriggerWaveform * shape, int i
|
||||
DECLARE_CONFIG_PARAMETER_SUFFIX) {
|
||||
) {
|
||||
efiAssertVoid(CUSTOM_ERR_6593, shape->getSize() > 0, "size not zero");
|
||||
int stateIndex = i % shape->getSize();
|
||||
int size = shape->getSize();
|
||||
|
@ -67,7 +67,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback trig
|
|||
if (needEvent(stateIndex, size, multiChannelStateSequence, 0)) {
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/0, stateIndex);
|
||||
trigger_event_e s = currentValue ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING;
|
||||
if (isUsefulSignal(s PASS_CONFIG_PARAMETER_SUFFIX)) {
|
||||
if (isUsefulSignal(s, triggerConfiguration)) {
|
||||
state->decodeTriggerEvent(shape,
|
||||
triggerCycleCallback,
|
||||
/* override */ nullptr,
|
||||
|
@ -79,7 +79,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback trig
|
|||
if (needEvent(stateIndex, size, multiChannelStateSequence, 1)) {
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/1, stateIndex);
|
||||
trigger_event_e s = currentValue ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING;
|
||||
if (isUsefulSignal(s PASS_CONFIG_PARAMETER_SUFFIX)) {
|
||||
if (isUsefulSignal(s, triggerConfiguration)) {
|
||||
state->decodeTriggerEvent(shape,
|
||||
triggerCycleCallback,
|
||||
/* override */ nullptr,
|
||||
|
@ -91,7 +91,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback trig
|
|||
if (needEvent(stateIndex, size, multiChannelStateSequence, 2)) {
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/2, stateIndex);
|
||||
trigger_event_e s = currentValue ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING;
|
||||
if (isUsefulSignal(s PASS_CONFIG_PARAMETER_SUFFIX)) {
|
||||
if (isUsefulSignal(s, triggerConfiguration)) {
|
||||
state->decodeTriggerEvent(shape,
|
||||
triggerCycleCallback,
|
||||
/* override */ nullptr,
|
||||
|
@ -104,7 +104,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback trig
|
|||
void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerStateCallback triggerCycleCallback,
|
||||
const TriggerConfiguration * triggerConfiguration,
|
||||
const uint32_t syncIndex, TriggerState *state, TriggerWaveform * shape
|
||||
DECLARE_CONFIG_PARAMETER_SUFFIX) {
|
||||
) {
|
||||
|
||||
/**
|
||||
* let's feed two more cycles to validate shape definition
|
||||
|
@ -112,11 +112,11 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerSta
|
|||
for (uint32_t i = syncIndex + 1; i <= syncIndex + GAP_TRACKING_LENGTH * shape->getSize(); i++) {
|
||||
feedSimulatedEvent(triggerCycleCallback,
|
||||
triggerConfiguration,
|
||||
state, shape, i PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
state, shape, i);
|
||||
}
|
||||
int revolutionCounter = state->getTotalRevolutionCounter();
|
||||
if (revolutionCounter != GAP_TRACKING_LENGTH + 1) {
|
||||
warning(CUSTOM_OBD_TRIGGER_WAVEFORM, "sync failed/wrong gap parameters trigger=%s rc=%d", getTrigger_type_e(engineConfiguration->trigger.type), revolutionCounter);
|
||||
warning(CUSTOM_OBD_TRIGGER_WAVEFORM, "sync failed/wrong gap parameters trigger=%s rc=%d", getTrigger_type_e(triggerConfiguration->getType()), revolutionCounter);
|
||||
shape->setShapeDefinitionError(true);
|
||||
return;
|
||||
}
|
||||
|
@ -132,11 +132,11 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerSta
|
|||
*/
|
||||
uint32_t TriggerStimulatorHelper::findTriggerSyncPoint(TriggerWaveform * shape,
|
||||
const TriggerConfiguration * triggerConfiguration,
|
||||
TriggerState *state DECLARE_CONFIG_PARAMETER_SUFFIX) {
|
||||
TriggerState *state) {
|
||||
for (int i = 0; i < 4 * PWM_PHASE_MAX_COUNT; i++) {
|
||||
feedSimulatedEvent(nullptr,
|
||||
triggerConfiguration,
|
||||
state, shape, i PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
state, shape, i);
|
||||
|
||||
if (state->shaft_is_synchronized) {
|
||||
return i;
|
||||
|
|
|
@ -15,19 +15,19 @@ public:
|
|||
|
||||
uint32_t findTriggerSyncPoint(TriggerWaveform * shape,
|
||||
const TriggerConfiguration * triggerConfiguration,
|
||||
TriggerState *state DECLARE_CONFIG_PARAMETER_SUFFIX);
|
||||
TriggerState *state);
|
||||
|
||||
void assertSyncPositionAndSetDutyCycle(const TriggerStateCallback triggerCycleCallback,
|
||||
const TriggerConfiguration * triggerConfiguration,
|
||||
const uint32_t index, TriggerState *state, TriggerWaveform * shape
|
||||
DECLARE_CONFIG_PARAMETER_SUFFIX);
|
||||
);
|
||||
|
||||
private:
|
||||
// send next event so that we can see how state reacts
|
||||
void feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback,
|
||||
const TriggerConfiguration * triggerConfiguration,
|
||||
TriggerState *state,
|
||||
TriggerWaveform * shape, int i DECLARE_CONFIG_PARAMETER_SUFFIX);
|
||||
TriggerWaveform * shape, int i);
|
||||
};
|
||||
|
||||
bool isUsefulSignal(trigger_event_e signal DECLARE_CONFIG_PARAMETER_SUFFIX);
|
||||
bool isUsefulSignal(trigger_event_e signal, const TriggerConfiguration * triggerConfiguration);
|
||||
|
|
Loading…
Reference in New Issue