From b9eb97d485bc320aef25d4e8eb040dcb6d1c2285 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 2 Feb 2015 23:04:02 -0600 Subject: [PATCH] auto-sync --- firmware/config/engines/GY6_139QMB.cpp | 2 +- firmware/config/engines/dodge_neon.cpp | 1 - firmware/config/engines/mazda_miata.cpp | 2 -- firmware/config/engines/sachs.cpp | 2 +- firmware/controllers/algo/engine_configuration.cpp | 1 - .../algo/engine_configuration_generated_structures.h | 8 ++++---- firmware/controllers/trigger/trigger_bmw.cpp | 3 +-- firmware/controllers/trigger/trigger_central.cpp | 6 +++--- firmware/controllers/trigger/trigger_chrysler.cpp | 4 ++-- firmware/controllers/trigger/trigger_decoder.cpp | 4 ++-- firmware/controllers/trigger/trigger_gm.cpp | 2 +- firmware/controllers/trigger/trigger_mazda.cpp | 8 ++++---- firmware/controllers/trigger/trigger_mitsubishi.cpp | 4 ++-- firmware/controllers/trigger/trigger_structure.cpp | 8 ++++---- firmware/controllers/trigger/trigger_structure.h | 3 ++- firmware/hw_layer/trigger_input.cpp | 5 +++-- firmware/rusefi_config.ini | 4 ++-- firmware/tunerstudio/rusefi.ini | 6 +++--- unit_tests/test_fuel_map.cpp | 2 +- 19 files changed, 36 insertions(+), 39 deletions(-) diff --git a/firmware/config/engines/GY6_139QMB.cpp b/firmware/config/engines/GY6_139QMB.cpp index 85c35c092f..e0fef8ea49 100644 --- a/firmware/config/engines/GY6_139QMB.cpp +++ b/firmware/config/engines/GY6_139QMB.cpp @@ -29,5 +29,5 @@ void setGy6139qmbDefaultEngineConfiguration(engine_configuration_s *engineConfig engineConfiguration->trigger.customTotalToothCount = 1; engineConfiguration->trigger.customSkippedToothCount = 0; engineConfiguration->trigger.customIsSynchronizationNeeded = false; - engineConfiguration->needSecondTriggerInput = false; + engineConfiguration->trigger.customNeedSecondTriggerInput = false; } diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index d6aa519c33..1cf1a58239 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -189,7 +189,6 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat // set_global_trigger_offset_angle 46 engineConfiguration->globalTriggerAngleOffset = 46; - engineConfiguration->needSecondTriggerInput = false; engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_SEQUENTIAL; diff --git a/firmware/config/engines/mazda_miata.cpp b/firmware/config/engines/mazda_miata.cpp index bc8d538aec..09523efdcb 100644 --- a/firmware/config/engines/mazda_miata.cpp +++ b/firmware/config/engines/mazda_miata.cpp @@ -249,12 +249,10 @@ void setFordEscortGt(engine_configuration_s *engineConfiguration) { // in case of SOHC distributor we only have one signal // boardConfiguration->triggerInputPins[0] = GPIOA_5; // 2E White CKP // boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; -// engineConfiguration->needSecondTriggerInput = false; // in case of SOHC distributor we only have one signal boardConfiguration->triggerInputPins[0] = GPIOC_6; boardConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP - engineConfiguration->needSecondTriggerInput = true; engineConfiguration->map.sensor.type = MT_DENSO183; diff --git a/firmware/config/engines/sachs.cpp b/firmware/config/engines/sachs.cpp index 92c276484f..97a6e1dcca 100644 --- a/firmware/config/engines/sachs.cpp +++ b/firmware/config/engines/sachs.cpp @@ -25,7 +25,7 @@ void setSachs(engine_configuration_s *engineConfiguration) { engineConfiguration->trigger.customTotalToothCount = 1; engineConfiguration->trigger.customSkippedToothCount = 0; engineConfiguration->trigger.customIsSynchronizationNeeded = false; - engineConfiguration->needSecondTriggerInput = false; + engineConfiguration->trigger.customNeedSecondTriggerInput = false; engineConfiguration->hasIatSensor = false; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 350f7bcf82..131446b7db 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -290,7 +290,6 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_ engineConfiguration->logFormat = LF_NATIVE; engineConfiguration->directSelfStimulation = false; - engineConfiguration->needSecondTriggerInput = true; engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2; engineConfiguration->HD44780width = 20; diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index d1263ad2dc..2edb0f0bb8 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated by config_definition.jar on Mon Feb 02 22:40:26 EST 2015 +// this section was generated by config_definition.jar on Mon Feb 02 22:51:59 EST 2015 // begin #include "rusefi_types.h" typedef struct { @@ -169,7 +169,7 @@ typedef struct { bool_t customIsSynchronizationNeeded : 1; /** offset 4 bit 1 */ - bool_t customUseSecondChannel : 1; + bool_t customNeedSecondTriggerInput : 1; /** * offset 8 */ @@ -988,7 +988,7 @@ typedef struct { bool_t secondTriggerChannelEnabled : 1; /** offset 9496 bit 4 */ - bool_t needSecondTriggerInput : 1; + bool_t needSecondTriggerInputDeprecated : 1; /** offset 9496 bit 5 */ bool_t isMapAveragingEnabled : 1; @@ -1130,4 +1130,4 @@ typedef struct { } engine_configuration_s; // end -// this section was generated by config_definition.jar on Mon Feb 02 22:40:26 EST 2015 +// this section was generated by config_definition.jar on Mon Feb 02 22:51:59 EST 2015 diff --git a/firmware/controllers/trigger/trigger_bmw.cpp b/firmware/controllers/trigger/trigger_bmw.cpp index 70d24cd20a..ed83959913 100644 --- a/firmware/controllers/trigger/trigger_bmw.cpp +++ b/firmware/controllers/trigger/trigger_bmw.cpp @@ -16,8 +16,7 @@ static inline float addPair(TriggerShape *s, float a, float w) { } void configureMiniCooperTriggerShape(TriggerShape *s) { - - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); // s->initialState[0] = 1; diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 05ed4da8a1..ad731463dc 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -242,7 +242,7 @@ void triggerInfo(Engine *engine) { scheduleMsg(logger, "trigger#1 event counters up=%d/down=%d", triggerCentral.getHwEventCounter(0), triggerCentral.getHwEventCounter(1)); - if (engineConfiguration->needSecondTriggerInput) { + if (engine->triggerShape.needSecondTriggerInput) { scheduleMsg(logger, "trigger#2 event counters up=%d/down=%d", triggerCentral.getHwEventCounter(2), triggerCentral.getHwEventCounter(3)); } @@ -250,7 +250,7 @@ void triggerInfo(Engine *engine) { engine->triggerShape.expectedEventCount[1], ts->expectedEventCount[2]); scheduleMsg(logger, "trigger type=%d/need2ndChannel=%s", engineConfiguration->trigger.type, - boolToString(engineConfiguration->needSecondTriggerInput)); + boolToString(engine->triggerShape.needSecondTriggerInput)); scheduleMsg(logger, "expected duty #0=%f/#1=%f", ts->dutyCycle[0], ts->dutyCycle[1]); scheduleMsg(logger, "isError %s/total errors=%d ord_err=%d/total revolutions=%d/self=%s", @@ -281,7 +281,7 @@ void triggerInfo(Engine *engine) { boardConfiguration->triggerSimulatorFrequency); - if (engineConfiguration->needSecondTriggerInput) { + if (engine->triggerShape.needSecondTriggerInput) { scheduleMsg(logger, "secondary trigger input: %s", hwPortname(boardConfiguration->triggerInputPins[1])); scheduleMsg(logger, "secondary trigger simulator: %s %s phase=%d", hwPortname(boardConfiguration->triggerSimulatorPins[1]), diff --git a/firmware/controllers/trigger/trigger_chrysler.cpp b/firmware/controllers/trigger/trigger_chrysler.cpp index 4f4795643e..464a1a1654 100644 --- a/firmware/controllers/trigger/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/trigger_chrysler.cpp @@ -8,7 +8,7 @@ #include "trigger_chrysler.h" void configureNeon2003TriggerShape(TriggerShape *s) { - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); // voodoo magic - we always need 720 at the end int base = 10; @@ -43,7 +43,7 @@ void configureNeon2003TriggerShape(TriggerShape *s) { } void configureNeon1995TriggerShape(TriggerShape *s) { - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); setTriggerSynchronizationGap(s, 0.72); diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index a3ed08a864..4910d0e17e 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -230,7 +230,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t now static void initializeSkippedToothTriggerShape(TriggerShape *s, int totalTeethCount, int skippedCount, operation_mode_e operationMode) { efiAssertVoid(s != NULL, "TriggerShape is NULL"); - s->reset(operationMode); + s->reset(operationMode, false); float toothWidth = 0.5; @@ -256,7 +256,7 @@ void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, } static void configureOnePlusOne(TriggerShape *s) { - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); s->addEvent(180, T_PRIMARY, TV_HIGH); s->addEvent(360, T_PRIMARY, TV_LOW); diff --git a/firmware/controllers/trigger/trigger_gm.cpp b/firmware/controllers/trigger/trigger_gm.cpp index 31396687fd..58fb3fb5f4 100644 --- a/firmware/controllers/trigger/trigger_gm.cpp +++ b/firmware/controllers/trigger/trigger_gm.cpp @@ -8,7 +8,7 @@ #include "trigger_gm.h" void configureGmTriggerShape(TriggerShape *s) { - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, false); // all angles are x2 here - so, 5 degree width is 10 float w = 10; diff --git a/firmware/controllers/trigger/trigger_mazda.cpp b/firmware/controllers/trigger/trigger_mazda.cpp index 298eaf6736..3a1d46909e 100644 --- a/firmware/controllers/trigger/trigger_mazda.cpp +++ b/firmware/controllers/trigger/trigger_mazda.cpp @@ -21,7 +21,7 @@ #include "trigger_mazda.h" void initializeMazdaMiataNaShape(TriggerShape *s) { - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); setTriggerSynchronizationGap(s, MIATA_NA_GAP); s->useRiseEdge = false; @@ -51,7 +51,7 @@ void initializeMazdaMiataNbShape(TriggerShape *s) { setTriggerSynchronizationGap(s, 0.11f); s->useRiseEdge = false; - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); /** * cam sensor is primary, crank sensor is secondary @@ -89,7 +89,7 @@ void configureMazdaProtegeSOHC(TriggerShape *s) { // todo: move to into configuration definition s->needSecondTriggerInput = FALSE; - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, false); // s->initialState[0] = 1; // float w = 720 / 4 * 0.215; @@ -115,7 +115,7 @@ void configureMazdaProtegeSOHC(TriggerShape *s) { void configureMazdaProtegeLx(TriggerShape *s) { // todo: move to into configuration definition s->needSecondTriggerInput = FALSE; - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); /** * based on https://svn.code.sf.net/p/rusefi/code/trunk/misc/logs/1993_escort_gt/MAIN_rfi_report_2015-02-01%2017_39.csv diff --git a/firmware/controllers/trigger/trigger_mitsubishi.cpp b/firmware/controllers/trigger/trigger_mitsubishi.cpp index 57518a09f9..93a7285ed5 100644 --- a/firmware/controllers/trigger/trigger_mitsubishi.cpp +++ b/firmware/controllers/trigger/trigger_mitsubishi.cpp @@ -9,7 +9,7 @@ void configureFordAspireTriggerShape(TriggerShape * s) { s->isSynchronizationNeeded = false; - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); float x = 121.90; @@ -29,7 +29,7 @@ void configureFordAspireTriggerShape(TriggerShape * s) { } void initializeMitsubishi4g18(TriggerShape *s) { - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); s->useRiseEdge = false; setTriggerSynchronizationGap(s, 1.6666); diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 1c8874ca75..98b48e03b6 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -34,7 +34,7 @@ trigger_shape_helper::trigger_shape_helper() { TriggerShape::TriggerShape() : wave(switchTimesBuffer, NULL) { - reset(OM_NONE); + reset(OM_NONE, false); wave.waves = h.waves; useRiseEdge = false; gapBothDirections = false; @@ -75,7 +75,7 @@ void TriggerShape::setTriggerShapeSynchPointIndex(engine_configuration_s *engine } } -void TriggerShape::reset(operation_mode_e operationMode) { +void TriggerShape::reset(operation_mode_e operationMode, bool needSecondTriggerInput) { this->operationMode = operationMode; size = 0; triggerShapeSynchPointIndex = 0; @@ -320,7 +320,7 @@ static float addAccordPair3(TriggerShape *s, float sb) { * http://forum.pgmfi.org/viewtopic.php?f=2&t=15570start=210#p139007 */ void configureHondaAccordCDDip(TriggerShape *s) { - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); s->initialState[T_SECONDARY] = TV_HIGH; float sb = 0; @@ -383,7 +383,7 @@ void configureHondaAccordCDDip(TriggerShape *s) { } void configureHondaAccordCD(TriggerShape *s, bool with3rdSignal) { - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); float sb = 5.0f; diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index a1933ca5ee..1035404569 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -32,6 +32,7 @@ class TriggerShape { public: TriggerShape(); bool_t isSynchronizationNeeded; + bool_t needSecondTriggerInput; int totalToothCount; int skippedToothCount; @@ -67,7 +68,7 @@ public: uint32_t expectedEventCount[PWM_PHASE_MAX_WAVE_PER_PWM]; void addEvent(float angle, trigger_wheel_e const waveIndex, trigger_value_e const state); - void reset(operation_mode_e operationMode); + void reset(operation_mode_e operationMode, bool needSecondTriggerInput); int getSize() const; multi_wave_s wave; diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index 570c9fd184..e2f132cb86 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -21,6 +21,7 @@ static WaveReaderHw primaryCrankInput; static WaveReaderHw secondaryCrankInput; +EXTERN_ENGINE; extern engine_configuration_s *engineConfiguration; extern engine_configuration2_s *engineConfiguration2; extern board_configuration_s *boardConfiguration; @@ -33,7 +34,7 @@ static void shaft_icu_width_callback(ICUDriver *icup) { // todo: support for 3rd trigger input channel // todo: start using real event time from HW event, not just software timer? int isPrimary = icup == primaryCrankInput.driver; - if (!isPrimary && !engineConfiguration->needSecondTriggerInput) { + if (!isPrimary && !engine->triggerShape.needSecondTriggerInput) { return; } // icucnt_t last_width = icuGetWidth(icup); so far we are fine with system time @@ -45,7 +46,7 @@ static void shaft_icu_width_callback(ICUDriver *icup) { static void shaft_icu_period_callback(ICUDriver *icup) { int isPrimary = icup == primaryCrankInput.driver; - if (!isPrimary && !engineConfiguration->needSecondTriggerInput) { + if (!isPrimary && !engine->triggerShape.needSecondTriggerInput) { return; } diff --git a/firmware/rusefi_config.ini b/firmware/rusefi_config.ini index 06ede864d4..b77e6962cc 100644 --- a/firmware/rusefi_config.ini +++ b/firmware/rusefi_config.ini @@ -216,7 +216,7 @@ custom trigger_type_e 4 bits, U32, @OFFSET@, [0:4], "custom toothed wheel", trigger_type_e type; bit customIsSynchronizationNeeded; - bit customUseSecondChannel; + bit customNeedSecondTriggerInput; int customTotalToothCount;;"number", 1, 0.0, 0, 1000.0, 2 int customSkippedToothCount;;"number", 1, 0.0, 0, 1000.0, 2 @@ -433,7 +433,7 @@ bit hasMapSensor;@see isMapAveragingEnabled bit isIgnitionEnabled bit isCylinderCleanupEnabled bit secondTriggerChannelEnabled - bit needSecondTriggerInput + bit needSecondTriggerInputDeprecated bit isMapAveragingEnabled bit isMilEnabled bit isFuelPumpEnabled diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 818038c55e..4d39a21e32 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -37,7 +37,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated by ConfigDefinition.jar on Mon Feb 02 22:40:27 EST 2015 +; this section was generated by ConfigDefinition.jar on Mon Feb 02 22:52:00 EST 2015 pageSize = 11832 page = 1 @@ -128,7 +128,7 @@ page = 1 analogChartFrequency = scalar, S32, 1024, "index", 1, 0, 0, 300, 0 ; size 4 trigger_type = bits, U32, 1028, [0:4], "custom toothed wheel", "ford aspire", "dodge neon", "Miata NA", "Miata NB", "GM_7X", "Cooper", "Mazda SOHC 4", "60/2", "36/1", "Accord CD", "MITSU", "ACCORD 2", "ACCORD DIP", "Neon 2003", "MAZDA D 4+1", "1+1", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" trigger_customIsSynchronizationNeeded= bits, U32, 1032, [0:0], "false", "true" - trigger_customUseSecondChannel= bits, U32, 1032, [1:1], "false", "true" + trigger_customNeedSecondTriggerInput= bits, U32, 1032, [1:1], "false", "true" trigger_customTotalToothCount = scalar, S32, 1036, "number", 1, 0.0, 0, 1000.0, 2 trigger_customSkippedToothCount = scalar, S32, 1040, "number", 1, 0.0, 0, 1000.0, 2 trigger_customSyncRatioFrom = scalar, F32, 1044, "number", 1, 0.0, 0, 1000.0, 2 @@ -407,7 +407,7 @@ page = 1 isIgnitionEnabled = bits, U32, 9496, [1:1], "false", "true" isCylinderCleanupEnabled= bits, U32, 9496, [2:2], "false", "true" secondTriggerChannelEnabled= bits, U32, 9496, [3:3], "false", "true" - needSecondTriggerInput = bits, U32, 9496, [4:4], "false", "true" + needSecondTriggerInputDeprecated= bits, U32, 9496, [4:4], "false", "true" isMapAveragingEnabled = bits, U32, 9496, [5:5], "false", "true" isMilEnabled = bits, U32, 9496, [6:6], "false", "true" isFuelPumpEnabled = bits, U32, 9496, [7:7], "false", "true" diff --git a/unit_tests/test_fuel_map.cpp b/unit_tests/test_fuel_map.cpp index 1c01716048..b72aae010e 100644 --- a/unit_tests/test_fuel_map.cpp +++ b/unit_tests/test_fuel_map.cpp @@ -104,7 +104,7 @@ void testFuelMap(void) { extern engine_configuration_s *engineConfiguration; static void confgiureFordAspireTriggerShape(TriggerShape * s) { - s->reset(FOUR_STROKE_CAM_SENSOR); + s->reset(FOUR_STROKE_CAM_SENSOR, true); s->addEvent(53.747, T_SECONDARY, TV_HIGH); s->addEvent(121.90, T_SECONDARY, TV_LOW);