diff --git a/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp b/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp index 60d47f3fee..9caed47181 100644 --- a/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp @@ -6,6 +6,7 @@ */ #include "trigger_mitsubishi.h" +#include "trigger_universal.h" void configureFordAspireTriggerWaveform(TriggerWaveform * s) { s->initialize(FOUR_STROKE_CAM_SENSOR); @@ -52,7 +53,33 @@ void initializeMitsubishi4g18(TriggerWaveform *s) { } void initialize36_2_1_1(TriggerWaveform *s) { + s->initialize(FOUR_STROKE_CRANK_SENSOR); + int totalTeethCount = 36; + float engineCycle = FOUR_STROKE_ENGINE_CYCLE; + float toothWidth = 0.5; + + float oneTooth = 720 / totalTeethCount; + + float offset = (36 - 11) * oneTooth; + + addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/offset, engineCycle, + NO_LEFT_FILTER, offset + 11 * oneTooth + 1); + + offset += (11 + 1) * oneTooth; + +// addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/offset, engineCycle, +// NO_LEFT_FILTER, offset + 11 * oneTooth); + + + offset += (11 + 1) * oneTooth; + +// addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/offset, engineCycle, +// NO_LEFT_FILTER, offset + 10 * oneTooth); + + s->shapeWithoutTdc = true; + + s->isSynchronizationNeeded = false; } void initializeVvt3A92(TriggerWaveform *s) { diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 2a4ba97792..011f1a5a93 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -173,7 +173,7 @@ void TriggerWaveform::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrig if (!useOnlyRisingEdgeForTrigger) { for (size_t i = 0; i < efi::size(expectedEventCount); i++) { if (getExpectedEventCount(i) % 2 != 0) { - firmwareError(ERROR_TRIGGER_DRAMA, "Trigger: should be even %d %d", i, getExpectedEventCount(i)); + firmwareError(ERROR_TRIGGER_DRAMA, "Trigger: should be even number of events index=%d count=%d", i, getExpectedEventCount(i)); } } } @@ -181,7 +181,7 @@ void TriggerWaveform::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrig bool isSingleToothOnPrimaryChannel = useOnlyRisingEdgeForTrigger ? getExpectedEventCount(0) == 1 : getExpectedEventCount(0) == 2; // todo: next step would be to set 'isSynchronizationNeeded' automatically based on the logic we have here if (!shapeWithoutTdc && isSingleToothOnPrimaryChannel != !isSynchronizationNeeded) { - firmwareError(ERROR_TRIGGER_DRAMA, "trigger sync constraint violation"); + firmwareError(ERROR_TRIGGER_DRAMA, "shapeWithoutTdc isSynchronizationNeeded isSingleToothOnPrimaryChannel constraint violation"); } if (isSingleToothOnPrimaryChannel) { useOnlyPrimaryForSync = true; @@ -237,7 +237,10 @@ void TriggerWaveform::addEvent(angle_t angle, trigger_wheel_e const channelIndex expectedEventCount[channelIndex]++; } - efiAssertVoid(CUSTOM_ERR_6599, angle > 0 && angle <= 1, "angle should be positive not above 1"); + if (angle <= 0 || angle > 1) { + firmwareError(CUSTOM_ERR_6599, "angle should be positive not above 1: index=%d angle %f", channelIndex, angle); + return; + } if (wave.phaseCount > 0) { if (angle <= previousAngle) { warning(CUSTOM_ERR_TRG_ANGLE_ORDER, "invalid angle order %s %s: new=%.2f/%f and prev=%.2f/%f, size=%d", @@ -599,8 +602,11 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e ambiguousOperat setToothedWheelConfiguration(this, 3, 0, ambiguousOperationMode); break; - case TT_36_2_1: case TT_36_2_1_1: + initialize36_2_1_1(this); + break; + + case TT_36_2_1: case TT_TOOTHED_WHEEL_32_2: setToothedWheelConfiguration(this, 32, 2, ambiguousOperationMode); // todo: add this second/third into 'setToothedWheelConfiguration' as long as we have enough tooth?