From b3c7fc04656397bcca62010ec7ca880ad834f034 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 8 Feb 2015 17:08:14 -0600 Subject: [PATCH] auto-sync --- firmware/config/engines/GY6_139QMB.cpp | 2 -- .../config/engines/ford_1995_inline_6.cpp | 1 - firmware/config/engines/sachs.cpp | 4 ---- firmware/config/engines/subaru.cpp | 5 ++++ firmware/config/engines/test_engine.cpp | 1 - .../controllers/trigger/trigger_decoder.cpp | 23 ++++++++----------- .../controllers/trigger/trigger_structure.cpp | 8 ++----- 7 files changed, 16 insertions(+), 28 deletions(-) diff --git a/firmware/config/engines/GY6_139QMB.cpp b/firmware/config/engines/GY6_139QMB.cpp index d637d56fe1..3d4ab0d4cc 100644 --- a/firmware/config/engines/GY6_139QMB.cpp +++ b/firmware/config/engines/GY6_139QMB.cpp @@ -33,8 +33,6 @@ void setGy6139qmbDefaultEngineConfiguration( engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; engineConfiguration->trigger.customTotalToothCount = 8; engineConfiguration->trigger.customSkippedToothCount = 1; - engineConfiguration->trigger.customIsSynchronizationNeeded = true; - engineConfiguration->trigger.customNeedSecondTriggerInput = false; boardConfiguration->injectionPins[0] = GPIOC_9; boardConfiguration->ignitionPins[0] = GPIOC_8; diff --git a/firmware/config/engines/ford_1995_inline_6.cpp b/firmware/config/engines/ford_1995_inline_6.cpp index ffb108e68c..f6d32496c8 100644 --- a/firmware/config/engines/ford_1995_inline_6.cpp +++ b/firmware/config/engines/ford_1995_inline_6.cpp @@ -44,7 +44,6 @@ void setFordInline6(engine_configuration_s *engineConfiguration, board_configura engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; engineConfiguration->trigger.customTotalToothCount = 6; engineConfiguration->trigger.customSkippedToothCount = 0; - engineConfiguration->trigger.customIsSynchronizationNeeded = false; engineConfiguration->globalTriggerAngleOffset = 0; engineConfiguration->ignitionBaseAngle = 13; diff --git a/firmware/config/engines/sachs.cpp b/firmware/config/engines/sachs.cpp index 97a6e1dcca..38e7a3c9b8 100644 --- a/firmware/config/engines/sachs.cpp +++ b/firmware/config/engines/sachs.cpp @@ -24,9 +24,6 @@ void setSachs(engine_configuration_s *engineConfiguration) { engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; engineConfiguration->trigger.customTotalToothCount = 1; engineConfiguration->trigger.customSkippedToothCount = 0; - engineConfiguration->trigger.customIsSynchronizationNeeded = false; - engineConfiguration->trigger.customNeedSecondTriggerInput = false; - engineConfiguration->hasIatSensor = false; engineConfiguration->hasMapSensor = false; @@ -34,7 +31,6 @@ void setSachs(engine_configuration_s *engineConfiguration) { engineConfiguration->hasAfrSensor = false; engineConfiguration->hasCltSensor = false; - // Frankenstein analog input #1: PA1 adc1 // Frankenstein analog input #2: PA3 adc3 TPS // Frankenstein analog input #3: PC3 adc13 diff --git a/firmware/config/engines/subaru.cpp b/firmware/config/engines/subaru.cpp index 94ace6bc84..aa71024dcb 100644 --- a/firmware/config/engines/subaru.cpp +++ b/firmware/config/engines/subaru.cpp @@ -18,4 +18,9 @@ void setSubaru2003Wrx(engine_configuration_s *engineConfiguration) { setFrankenso_01_LCD(boardConfiguration); setFrankenso0_1_joystick(engineConfiguration); + engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; + engineConfiguration->trigger.customTotalToothCount = 5; + engineConfiguration->trigger.customSkippedToothCount = 1; + + } diff --git a/firmware/config/engines/test_engine.cpp b/firmware/config/engines/test_engine.cpp index 8294589136..d0d9ae97e9 100644 --- a/firmware/config/engines/test_engine.cpp +++ b/firmware/config/engines/test_engine.cpp @@ -14,7 +14,6 @@ void setTestEngineConfiguration(engine_configuration_s *engineConfiguration) { engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; trigger_config_s *triggerConfig = &engineConfiguration->trigger; - triggerConfig->customIsSynchronizationNeeded = false; triggerConfig->customTotalToothCount = 60; triggerConfig->customSkippedToothCount = 0; diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index e9489f385b..733545f10e 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -227,8 +227,16 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t now toothed_previous_time = nowNt; } -static void initializeSkippedToothTriggerShape(TriggerShape *s, int totalTeethCount, int skippedCount, +void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount, operation_mode_e operationMode) { + efiAssertVoid(totalTeethCount > 0, "totalTeethCount is zero"); + + s->totalToothCount = totalTeethCount; + s->skippedToothCount = skippedCount; + + s->setTriggerSynchronizationGap(skippedCount + 1); + s->isSynchronizationNeeded = (skippedCount != 0); + efiAssertVoid(s != NULL, "TriggerShape is NULL"); s->reset(operationMode, false); @@ -244,15 +252,7 @@ static void initializeSkippedToothTriggerShape(TriggerShape *s, int totalTeethCo float angleDown = 720.0 / totalTeethCount * (totalTeethCount - skippedCount - 1 + toothWidth); s->addEvent(angleDown, T_PRIMARY, TV_HIGH); s->addEvent(720, T_PRIMARY, TV_LOW); -} -void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount, - operation_mode_e operationMode) { - efiAssertVoid(totalTeethCount > 0, "totalTeethCount is zero"); - - s->totalToothCount = totalTeethCount; - s->skippedToothCount = skippedCount; - initializeSkippedToothTriggerShape(s, totalTeethCount, skippedCount, operationMode); } static void configureOnePlusOne(TriggerShape *s) { @@ -282,9 +282,6 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin switch (triggerConfig->type) { case TT_TOOTHED_WHEEL: - // todo: for toothed wheel isSynchronizationNeeded is a function of customSkippedToothCount I guess - triggerShape->isSynchronizationNeeded = engineConfiguration->trigger.customIsSynchronizationNeeded; - initializeSkippedToothTriggerShapeExt(triggerShape, triggerConfig->customTotalToothCount, triggerConfig->customSkippedToothCount, getOperationMode(engineConfiguration)); break; @@ -331,8 +328,6 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin case TT_TOOTHED_WHEEL_60_2: setToothedWheelConfiguration(triggerShape, 60, 2, engineConfiguration); - // todo: gap ratio is a function of skipped tooth I guess? - triggerShape->setTriggerSynchronizationGap(3); break; case TT_TOOTHED_WHEEL_36_1: diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 61424b4b49..ac72a957b6 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -280,15 +280,11 @@ void multi_wave_s::checkSwitchTimes(int size) { void setToothedWheelConfiguration(TriggerShape *s, int total, int skipped, engine_configuration_s const *engineConfiguration) { - s->isSynchronizationNeeded = (skipped != 0); +#if EFI_ENGINE_CONTROL - s->totalToothCount = total; - s->skippedToothCount = skipped; - // todo: move to into configuration definition s->needSecondTriggerInput = false; s->useRiseEdge = true; -#if EFI_ENGINE_CONTROL - initializeSkippedToothTriggerShapeExt(s, s->totalToothCount, s->skippedToothCount, + initializeSkippedToothTriggerShapeExt(s, total, skipped, getOperationMode(engineConfiguration)); #endif }