From 26dcdc05041f4ffdf61bd912eb109ed76b381ad8 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 27 Feb 2016 23:03:34 -0500 Subject: [PATCH] auto-sync --- firmware/config/engines/bmw_e34.cpp | 2 +- firmware/config/engines/dodge_neon.cpp | 3 +- firmware/config/engines/ford_aspire.cpp | 2 +- firmware/config/engines/ford_festiva.cpp | 39 +++++++++- firmware/config/engines/mazda_626.cpp | 2 +- firmware/config/engines/test_engine.cpp | 2 +- .../controllers/algo/auto_generated_enums.cpp | 24 +++---- .../controllers/algo/engine_configuration.cpp | 2 +- ...ngine_configuration_generated_structures.h | 6 +- firmware/controllers/algo/rusefi_enums.h | 13 ++-- firmware/controllers/algo/rusefi_generated.h | 2 +- firmware/controllers/math/engine_math.cpp | 2 +- firmware/controllers/settings.cpp | 2 +- .../trigger/main_trigger_callback.cpp | 2 +- .../controllers/trigger/trigger_central.cpp | 6 +- .../controllers/trigger/trigger_decoder.cpp | 8 +-- .../controllers/trigger/trigger_decoder.h | 4 +- .../trigger/trigger_emulator_algo.cpp | 8 +-- .../controllers/trigger/trigger_simulator.cpp | 8 +-- .../controllers/trigger/trigger_structure.cpp | 8 +-- firmware/hw_layer/trigger_input.cpp | 10 +-- firmware/integration/rusefi_config.txt | 2 +- unit_tests/engine_test_helper.cpp | 4 +- unit_tests/test_trigger_decoder.cpp | 72 +++++++++---------- 24 files changed, 132 insertions(+), 101 deletions(-) diff --git a/firmware/config/engines/bmw_e34.cpp b/firmware/config/engines/bmw_e34.cpp index 1dda358d4c..7c1dc5f13c 100644 --- a/firmware/config/engines/bmw_e34.cpp +++ b/firmware/config/engines/bmw_e34.cpp @@ -36,7 +36,7 @@ void setBmwE34(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->injectionMode = IM_BATCH; engineConfiguration->twoWireBatchInjection = true; engineConfiguration->ignitionMode = IM_WASTED_SPARK; - engineConfiguration->useOnlyFrontForTrigger = true; + engineConfiguration->useOnlyRisingEdgeForTrigger = true; boardConfiguration->tachOutputPin = GPIOC_8; diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 3a30bb9f1b..8204d70584 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -151,8 +151,7 @@ void setDodgeNeon1995EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { // set_cranking_fuel 5 engineConfiguration->cranking.baseFuel = 5; -// todo: finish implementation for 'useRiseEdge' -// engineConfiguration->useOnlyFrontForTrigger = true; +// engineConfiguration->useOnlyRisingEdgeForTrigger = true; /** * that's 1995 config diff --git a/firmware/config/engines/ford_aspire.cpp b/firmware/config/engines/ford_aspire.cpp index b13d98daed..b1f36ec88d 100644 --- a/firmware/config/engines/ford_aspire.cpp +++ b/firmware/config/engines/ford_aspire.cpp @@ -117,7 +117,7 @@ void setFordAspireEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { setSingleCoilDwell(engineConfiguration); engineConfiguration->ignitionMode = IM_ONE_COIL; setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR); - engineConfiguration->useOnlyFrontForTrigger = true; + engineConfiguration->useOnlyRisingEdgeForTrigger = true; engineConfiguration->trigger.type = TT_FORD_ASPIRE; boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED; diff --git a/firmware/config/engines/ford_festiva.cpp b/firmware/config/engines/ford_festiva.cpp index e47f251ed4..22c8bb745b 100644 --- a/firmware/config/engines/ford_festiva.cpp +++ b/firmware/config/engines/ford_festiva.cpp @@ -76,10 +76,27 @@ void setFordEscortGt(DECLARE_ENGINE_PARAMETER_F) { // engineConfiguration->algorithm = LM_PLAIN_MAF; setAlgorithm(LM_SPEED_DENSITY PASS_ENGINE_PARAMETER); // engineConfiguration->algorithm = LM_REAL_MAF; - boardConfiguration->tunerStudioSerialSpeed = 14400; setFuelLoadBin(1.2, 4.4 PASS_ENGINE_PARAMETER); setFuelRpmBin(800, 7000 PASS_ENGINE_PARAMETER); + + config->veRpmBins[0] = 800; + config->veRpmBins[1] = 1200; + config->veRpmBins[2] = 1600; + config->veRpmBins[3] = 2000; + config->veRpmBins[4] = 2400; + config->veRpmBins[5] = 2800; + config->veRpmBins[6] = 3200; + config->veRpmBins[7] = 3600; + config->veRpmBins[8] = 4100; + config->veRpmBins[9] = 4500; + config->veRpmBins[10] = 4900; + config->veRpmBins[11] = 5300; + config->veRpmBins[12] = 5700; + config->veRpmBins[13] = 6100; + config->veRpmBins[14] = 6500; + config->veRpmBins[15] = 7000; + copyFuelTable(racingFestivaVeTable, config->veTable); // boardConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU @@ -173,7 +190,7 @@ void setFordEscortGt(DECLARE_ENGINE_PARAMETER_F) { boardConfiguration->malfunctionIndicatorPin = GPIOE_5; boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; - boardConfiguration->tunerStudioSerialSpeed = 9600; + boardConfiguration->tunerStudioSerialSpeed = 19200; commonFrankensoAnalogInputs(engineConfiguration); setCommonNTCSensor(&engineConfiguration->clt); @@ -204,7 +221,23 @@ void setFordEscortGt(DECLARE_ENGINE_PARAMETER_F) { // set_fsio_expression 1 "rpm 0 fsio_setting >" setFsioExt(0, GPIOE_3, "rpm 0 fsio_setting >", 150 PASS_ENGINE_PARAMETER); - copyTimingTable(racingFestivaIgnitionTable, config->veTable); + config->ignitionRpmBins[0] = 800; + config->ignitionRpmBins[1] = 1200; + config->ignitionRpmBins[2] = 1600; + config->ignitionRpmBins[3] = 2000; + config->ignitionRpmBins[4] = 2400; + config->ignitionRpmBins[5] = 2800; + config->ignitionRpmBins[6] = 3200; + config->ignitionRpmBins[7] = 3600; + config->ignitionRpmBins[8] = 4100; + config->ignitionRpmBins[9] = 4500; + config->ignitionRpmBins[10] = 4900; + config->ignitionRpmBins[11] = 5300; + config->ignitionRpmBins[12] = 5700; + config->ignitionRpmBins[13] = 6100; + config->ignitionRpmBins[14] = 6500; + config->ignitionRpmBins[15] = 7000; + copyTimingTable(racingFestivaIgnitionTable, config->ignitionTable); // end of Ford Escort GT config } diff --git a/firmware/config/engines/mazda_626.cpp b/firmware/config/engines/mazda_626.cpp index 1e2ddb7bfc..ac7e4282b8 100644 --- a/firmware/config/engines/mazda_626.cpp +++ b/firmware/config/engines/mazda_626.cpp @@ -29,7 +29,7 @@ void setMazda626EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { // with this complex trigger we do not need this by default boardConfiguration->sensorChartMode = SC_OFF; - engineConfiguration->useOnlyFrontForTrigger = true; + engineConfiguration->useOnlyRisingEdgeForTrigger = true; engineConfiguration->injectionMode = IM_BATCH; // enable two_wire_batch_injection diff --git a/firmware/config/engines/test_engine.cpp b/firmware/config/engines/test_engine.cpp index 0d2f856f01..33992e2aa6 100644 --- a/firmware/config/engines/test_engine.cpp +++ b/firmware/config/engines/test_engine.cpp @@ -22,7 +22,7 @@ void setTestEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { trigger_config_s *triggerConfig = &engineConfiguration->trigger; triggerConfig->customTotalToothCount = 60; triggerConfig->customSkippedToothCount = 0; - engineConfiguration->useOnlyFrontForTrigger = true; + engineConfiguration->useOnlyRisingEdgeForTrigger = true; engineConfiguration->mafAdcChannel = EFI_ADC_NONE; engineConfiguration->vbattAdcChannel = EFI_ADC_NONE; diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index 7ede74ebaa..3862af41f9 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -207,18 +207,18 @@ case T_SECONDARY: } const char *getTrigger_event_e(trigger_event_e value){ switch(value) { -case SHAFT_3RD_DOWN: - return "SHAFT_3RD_DOWN"; -case SHAFT_3RD_UP: - return "SHAFT_3RD_UP"; -case SHAFT_PRIMARY_DOWN: - return "SHAFT_PRIMARY_DOWN"; -case SHAFT_PRIMARY_UP: - return "SHAFT_PRIMARY_UP"; -case SHAFT_SECONDARY_DOWN: - return "SHAFT_SECONDARY_DOWN"; -case SHAFT_SECONDARY_UP: - return "SHAFT_SECONDARY_UP"; +case SHAFT_3RD_FALLING: + return "SHAFT_3RD_FALLING"; +case SHAFT_3RD_RISING: + return "SHAFT_3RD_RISING"; +case SHAFT_PRIMARY_FALLING: + return "SHAFT_PRIMARY_FALLING"; +case SHAFT_PRIMARY_RISING: + return "SHAFT_PRIMARY_RISING"; +case SHAFT_SECONDARY_FALLING: + return "SHAFT_SECONDARY_FALLING"; +case SHAFT_SECONDARY_RISING: + return "SHAFT_SECONDARY_RISING"; } return NULL; } diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 2fec0e3a52..dc424170a3 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -547,7 +547,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->hasBaroSensor = false; engineConfiguration->isEngineChartEnabled = true; - engineConfiguration->useOnlyFrontForTrigger = false; + engineConfiguration->useOnlyRisingEdgeForTrigger = false; boardConfiguration->idle.solenoidFrequency = 200; // set_idle_position 50 diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index f20edfa873..7ec38f1be6 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 automatically by ConfigDefinition.jar based on rusefi_config.txt Wed Feb 10 12:21:21 EST 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Feb 27 22:02:38 EST 2016 // begin #ifndef ENGINE_CONFIGURATION_GENERATED_H_ #define ENGINE_CONFIGURATION_GENERATED_H_ @@ -1167,7 +1167,7 @@ typedef struct { /** * See #172 offset 1500 bit 14 */ - bool useOnlyFrontForTrigger : 1; + bool useOnlyRisingEdgeForTrigger : 1; /** * This is needed if batched igniton (waster spark) and individual coil wiring offset 1500 bit 15 */ @@ -1640,4 +1640,4 @@ typedef struct { #endif // end -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Wed Feb 10 12:21:21 EST 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Feb 27 22:02:38 EST 2016 diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 37f3ead4d7..825c9cb0db 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -191,14 +191,13 @@ typedef enum { T_CHANNEL_3 = 2 } trigger_wheel_e; -// todo: better names? typedef enum { - SHAFT_PRIMARY_DOWN = 0, - SHAFT_PRIMARY_UP = 1, - SHAFT_SECONDARY_DOWN = 2, - SHAFT_SECONDARY_UP = 3, - SHAFT_3RD_DOWN = 4, - SHAFT_3RD_UP = 5, + SHAFT_PRIMARY_FALLING = 0, + SHAFT_PRIMARY_RISING = 1, + SHAFT_SECONDARY_FALLING = 2, + SHAFT_SECONDARY_RISING = 3, + SHAFT_3RD_FALLING = 4, + SHAFT_3RD_RISING = 5, } trigger_event_e; /** diff --git a/firmware/controllers/algo/rusefi_generated.h b/firmware/controllers/algo/rusefi_generated.h index 8bf8839ba5..067dbe472f 100644 --- a/firmware/controllers/algo/rusefi_generated.h +++ b/firmware/controllers/algo/rusefi_generated.h @@ -588,7 +588,7 @@ #define isPrintTriggerSynchDetails_offset 1500 #define isManualSpinningMode_offset 1500 #define twoWireBatchInjection_offset 1500 -#define useOnlyFrontForTrigger_offset 1500 +#define useOnlyRisingEdgeForTrigger_offset 1500 #define twoWireBatchIgnition_offset 1500 #define engineChartSize_offset 1504 #define targetIdleRpm_offset 1508 diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index a4d79a389b..38ce310515 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -406,7 +406,7 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F) { int engineCycleInt = (int) ENGINE(engineCycle); for (int angle = 0; angle < engineCycleInt; angle++) { int triggerShapeIndex = findAngleIndex(angle PASS_ENGINE_PARAMETER); - if (engineConfiguration->useOnlyFrontForTrigger) + if (engineConfiguration->useOnlyRisingEdgeForTrigger) triggerShapeIndex = triggerShapeIndex & 0xFFFFFFFE; // we need even index for front_only TRIGGER_SHAPE(triggerIndexByAngle[angle]) = triggerShapeIndex; } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index b48f061ef4..9d13bfe6bf 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -839,7 +839,7 @@ static void enableOrDisable(const char *param, bool isEnabled) { } else if (strEqualCaseInsensitive(param, "stepperidle")) { boardConfiguration->useStepperIdle = isEnabled; } else if (strEqualCaseInsensitive(param, "trigger_only_front")) { - engineConfiguration->useOnlyFrontForTrigger = isEnabled; + engineConfiguration->useOnlyRisingEdgeForTrigger = isEnabled; incrementGlobalConfigurationVersion(); } else if (strEqualCaseInsensitive(param, "use_only_first_channel")) { engineConfiguration->trigger.useOnlyFirstChannel = isEnabled; diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 594c7ebbbb..4e11534d79 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -411,7 +411,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL prepareOutputSignals(PASS_ENGINE_PARAMETER_F); } - efiAssertVoid(!CONFIG(useOnlyFrontForTrigger) || CONFIG(ignMathCalculateAtIndex) % 2 == 0, "invalid ignMathCalculateAtIndex"); + efiAssertVoid(!CONFIG(useOnlyRisingEdgeForTrigger) || CONFIG(ignMathCalculateAtIndex) % 2 == 0, "invalid ignMathCalculateAtIndex"); if (eventIndex == CONFIG(ignMathCalculateAtIndex)) { if (CONFIG(externalKnockSenseAdc) != EFI_ADC_NONE) { diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 1c874c2d81..491a1cbe46 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -54,7 +54,7 @@ void TriggerCentral::addEventListener(ShaftPositionListener listener, const char * @brief Adds a trigger event listener * * Trigger event listener would be invoked on each trigger event. For example, for a 60/2 wheel - * that would be 116 events: 58 SHAFT_PRIMARY_UP and 58 SHAFT_PRIMARY_DOWN events. + * that would be 116 events: 58 SHAFT_PRIMARY_RISING and 58 SHAFT_PRIMARY_FALLING events. */ void addTriggerEventListener(ShaftPositionListener listener, const char *name, Engine *engine) { engine->triggerCentral.addEventListener(listener, name, engine); @@ -119,7 +119,7 @@ static ALWAYS_INLINE void reportEventToWaveChart(trigger_event_e ckpSignalType, shaft_signal_msg_index[0] = isUp ? 'u' : 'd'; addEngineSniffferEvent(eventId[(int )ckpSignalType], (char* ) shaft_signal_msg_index); - if (engineConfiguration->useOnlyFrontForTrigger) { + if (engineConfiguration->useOnlyRisingEdgeForTrigger) { // let's add the opposite event right away shaft_signal_msg_index[0] = isUp ? 'd' : 'u'; addEngineSniffferEvent(eventId[(int )ckpSignalType], (char* ) shaft_signal_msg_index); @@ -293,7 +293,7 @@ void triggerInfo(void) { scheduleMsg(logger, "Template %s (%d) trigger %s (%d) useRiseEdge=%s onlyFront=%s gapBothDirections=%s useOnlyFirstChannel=%s", getConfigurationName(engineConfiguration->engineType), engineConfiguration->engineType, getTrigger_type_e(engineConfiguration->trigger.type), engineConfiguration->trigger.type, - boolToString(TRIGGER_SHAPE(useRiseEdge)), boolToString(engineConfiguration->useOnlyFrontForTrigger), + boolToString(TRIGGER_SHAPE(useRiseEdge)), boolToString(engineConfiguration->useOnlyRisingEdgeForTrigger), boolToString(TRIGGER_SHAPE(gapBothDirections)), boolToString(engineConfiguration->trigger.useOnlyFirstChannel)); diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index d4ebb91184..677c1f839e 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -97,7 +97,7 @@ static trigger_wheel_e eventIndex[6] = { T_PRIMARY, T_PRIMARY, T_SECONDARY, T_SE /* odd event - start accumulation */ \ currentCycle.timeOfPreviousEventNt[triggerWheel] = nowNt; \ } \ - if (engineConfiguration->useOnlyFrontForTrigger) {currentCycle.current_index++;} \ + if (engineConfiguration->useOnlyRisingEdgeForTrigger) {currentCycle.current_index++;} \ currentCycle.current_index++; \ } @@ -122,11 +122,11 @@ static trigger_wheel_e eventIndex[6] = { T_PRIMARY, T_PRIMARY, T_SECONDARY, T_SE * @param nowNt current time */ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t nowNt DECLARE_ENGINE_PARAMETER_S) { - efiAssertVoid(signal <= SHAFT_3RD_UP, "unexpected signal"); + efiAssertVoid(signal <= SHAFT_3RD_RISING, "unexpected signal"); trigger_wheel_e triggerWheel = eventIndex[signal]; - if (!engineConfiguration->useOnlyFrontForTrigger && curSignal == prevSignal) { + if (!engineConfiguration->useOnlyRisingEdgeForTrigger && curSignal == prevSignal) { orderingErrorCounter++; } @@ -232,7 +232,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no /** * in case of noise the counter could be above the expected number of events */ - int d = engineConfiguration->useOnlyFrontForTrigger ? 2 : 1; + int d = engineConfiguration->useOnlyRisingEdgeForTrigger ? 2 : 1; isSynchronizationPoint = !shaft_is_synchronized || (currentCycle.current_index >= TRIGGER_SHAPE(size) - d); } diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index edbadd7b9c..deef47e9c1 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -126,8 +126,8 @@ bool isTriggerDecoderError(void); #define considerEventForGap() (!TRIGGER_SHAPE(useOnlyPrimaryForSync) || isPrimary) -#define isLessImportant(signal) ((TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_UP) \ - || (!TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_DOWN) \ +#define isLessImportant(signal) ((TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_RISING) \ + || (!TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_FALLING) \ || (!considerEventForGap()) \ ) diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index f2d77ce0ae..820814c34c 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -39,7 +39,7 @@ EXTERN_ENGINE ; static void fireShaftSignal(trigger_event_e signal) { - if (!engineConfiguration->useOnlyFrontForTrigger || isRisingEdge[(int) signal]) + if (!engineConfiguration->useOnlyRisingEdgeForTrigger || isRisingEdge[(int) signal]) hwHandleShaftSignal(signal); } @@ -57,17 +57,17 @@ void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIn if (primaryWheelState != newPrimaryWheelState) { primaryWheelState = newPrimaryWheelState; - fireShaftSignal(primaryWheelState ? SHAFT_PRIMARY_UP : SHAFT_PRIMARY_DOWN); + fireShaftSignal(primaryWheelState ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING); } if (secondaryWheelState != newSecondaryWheelState) { secondaryWheelState = newSecondaryWheelState; - fireShaftSignal(secondaryWheelState ? SHAFT_SECONDARY_UP : SHAFT_SECONDARY_DOWN); + fireShaftSignal(secondaryWheelState ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING); } if (thirdWheelState != new3rdWheelState) { thirdWheelState = new3rdWheelState; - fireShaftSignal(thirdWheelState ? SHAFT_3RD_UP : SHAFT_3RD_DOWN); + fireShaftSignal(thirdWheelState ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING); } // print("hello %d\r\n", chTimeNow()); diff --git a/firmware/controllers/trigger/trigger_simulator.cpp b/firmware/controllers/trigger/trigger_simulator.cpp index 741752fed5..87171324fc 100644 --- a/firmware/controllers/trigger/trigger_simulator.cpp +++ b/firmware/controllers/trigger/trigger_simulator.cpp @@ -37,26 +37,26 @@ void TriggerStimulatorHelper::nextStep(TriggerState *state, TriggerShape * shape if (primaryWheelState != newPrimaryWheelState) { primaryWheelState = newPrimaryWheelState; - trigger_event_e s = primaryWheelState ? SHAFT_PRIMARY_UP : SHAFT_PRIMARY_DOWN; + trigger_event_e s = primaryWheelState ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING; state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER); } if (secondaryWheelState != newSecondaryWheelState) { secondaryWheelState = newSecondaryWheelState; - trigger_event_e s = secondaryWheelState ? SHAFT_SECONDARY_UP : SHAFT_SECONDARY_DOWN; + trigger_event_e s = secondaryWheelState ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING; state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER); } if (thirdWheelState != new3rdWheelState) { thirdWheelState = new3rdWheelState; - trigger_event_e s = thirdWheelState ? SHAFT_3RD_UP : SHAFT_3RD_DOWN; + trigger_event_e s = thirdWheelState ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING; state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER); } } void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(uint32_t index, TriggerState *state, TriggerShape * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S) { - int startIndex = engineConfiguration->useOnlyFrontForTrigger ? index + 2 : index + 1; + int startIndex = engineConfiguration->useOnlyRisingEdgeForTrigger ? index + 2 : index + 1; for (uint32_t i = startIndex; i <= index + 2 * shape->getSize(); i++) { nextStep(state, shape, i, triggerConfig PASS_ENGINE_PARAMETER); diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index cd74c9f727..158e5cf2ff 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -94,7 +94,7 @@ void TriggerShape::calculateTriggerSynchPoint(TriggerState *state DECLARE_ENGINE int triggerDefinitionIndex = triggerDefinitionCoordinate >= size ? triggerDefinitionCoordinate - size : triggerDefinitionCoordinate; float angle = getAngle(triggerDefinitionCoordinate) - firstAngle; fixAngle(angle); - if (engineConfiguration->useOnlyFrontForTrigger) { + if (engineConfiguration->useOnlyRisingEdgeForTrigger) { if (isFrontEvent[triggerDefinitionIndex]) { frontOnlyIndex += 2; eventAngles[frontOnlyIndex] = angle; @@ -169,8 +169,8 @@ void TriggerState::reset() { totalTriggerErrorCounter = 0; orderingErrorCounter = 0; currentDuration = 0; - curSignal = SHAFT_PRIMARY_DOWN; - prevSignal = SHAFT_PRIMARY_DOWN; + curSignal = SHAFT_PRIMARY_FALLING; + prevSignal = SHAFT_PRIMARY_FALLING; prevCycleDuration = 0; startOfCycleNt = 0; @@ -289,7 +289,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const waveIndex, trig #if EFI_PROD_CODE || defined(__DOXYGEN__) // todo: PASS_ENGINE? - if (!engineConfiguration->useOnlyFrontForTrigger || stateParam == TV_RISE) { + if (!engineConfiguration->useOnlyRisingEdgeForTrigger || stateParam == TV_RISE) { expectedEventCount[waveIndex]++; } #endif diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index c253d0f6b2..ba19ae4041 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -42,7 +42,7 @@ static void shaft_icu_width_callback(ICUDriver *icup) { } // icucnt_t last_width = icuGetWidth(icup); so far we are fine with system time // todo: add support for 3rd channel - trigger_event_e signal = isPrimary ? SHAFT_PRIMARY_UP : SHAFT_SECONDARY_UP; + trigger_event_e signal = isPrimary ? SHAFT_PRIMARY_RISING : SHAFT_SECONDARY_RISING; hwHandleShaftSignal(signal); } @@ -58,8 +58,8 @@ static void shaft_icu_period_callback(ICUDriver *icup) { // todo: add support for 3rd channel // icucnt_t last_period = icuGetPeriod(icup); so far we are fine with system time trigger_event_e signal = - isPrimary ? SHAFT_PRIMARY_DOWN : SHAFT_SECONDARY_DOWN; - if (CONFIG(useOnlyFrontForTrigger)) + isPrimary ? SHAFT_PRIMARY_FALLING : SHAFT_SECONDARY_FALLING; + if (CONFIG(useOnlyRisingEdgeForTrigger)) return; hwHandleShaftSignal(signal); } @@ -80,10 +80,10 @@ static ICUDriver *turnOnTriggerInputPin(brain_pin_e hwPin) { // todo: reuse 'setWaveReaderMode' method here? if (driver != NULL) { // todo: once http://forum.chibios.org/phpbb/viewtopic.php?f=16&t=1757 is fixed -// bool needWidthCallback = !CONFIG(useOnlyFrontForTrigger) || TRIGGER_SHAPE(useRiseEdge); +// bool needWidthCallback = !CONFIG(useOnlyRisingEdgeForTrigger) || TRIGGER_SHAPE(useRiseEdge); // shaft_icucfg.width_cb = needWidthCallback ? shaft_icu_width_callback : NULL; -// bool needPeriodCallback = !CONFIG(useOnlyFrontForTrigger) || !TRIGGER_SHAPE(useRiseEdge); +// bool needPeriodCallback = !CONFIG(useOnlyRisingEdgeForTrigger) || !TRIGGER_SHAPE(useRiseEdge); // shaft_icucfg.period_cb = needPeriodCallback ? shaft_icu_period_callback : NULL; efiIcuStart(driver, &shaft_icucfg); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 7ebeb255f4..43341e805f 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -533,7 +533,7 @@ custom idle_mode_e 4 bits, U32, @OFFSET@, [0:0], "false", "true" bit isPrintTriggerSynchDetails bit isManualSpinningMode;Usually if we have no trigger events that means engine is stopped\nUnless we are troubleshooting and spinning the engine by hand - this case a longer\ndelay is needed bit twoWireBatchInjection;This is needed if batched injection and individual injector wiring - bit useOnlyFrontForTrigger;See #172 + bit useOnlyRisingEdgeForTrigger;See #172 bit twoWireBatchIgnition;This is needed if batched igniton (waster spark) and individual coil wiring diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index f9a7bc7403..52e62aa8ee 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -51,9 +51,9 @@ void EngineTestHelper::fireTriggerEvents(int count) { for (int i = 0; i < count; i++) { timeNow += 5000; // 5ms board_configuration_s * boardConfiguration = &engine.engineConfiguration->bc; - engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration); + engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration); timeNow += 5000; - engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration); + engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration); } } diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index f35babc486..f3230e24f4 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -69,38 +69,38 @@ static void testDodgeNeonDecoder(void) { assertFalseM("1 shaft_is_synchronized", state.shaft_is_synchronized); // int r = 0; -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_UP, r + 60); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 60); // assertFalseM("2 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_DOWN, r + 210); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 210); // assertFalseM("3 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization // -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_UP, r + 420); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 420); // assertFalseM("4 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization // -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_DOWN, r + 630); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 630); // assertFalse(state.shaft_is_synchronized); // still no synchronization // // printf("2nd camshaft revolution\r\n"); // r = 720; -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_UP, r + 60); -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_DOWN, r + 210); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 60); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 210); // assertTrue(state.shaft_is_synchronized); // assertEquals(0, state.current_index); -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_UP, r + 420); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 420); // assertEquals(1, state.current_index); -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_DOWN, r + 630); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 630); // assertEquals(2, state.current_index); // // printf("3rd camshaft revolution\r\n"); // r = 2 * 720; -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_UP, r + 60); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 60); // assertEqualsM("current index", 3, state.current_index); -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_DOWN, r + 210); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 210); // assertTrue(state.shaft_is_synchronized); // assertEqualsM("current index", 0, state.current_index); -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_UP, r + 420); -// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_DOWN, r + 630); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 420); +// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 630); } static void assertTriggerPosition(event_trigger_position_s *position, int eventIndex, float angleOffset) { @@ -158,28 +158,28 @@ void test1995FordInline6TriggerDecoder(void) { assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized); int r = 10; - state.decodeTriggerEvent(SHAFT_PRIMARY_DOWN, r PASS_ENGINE_PARAMETER); + state.decodeTriggerEvent(SHAFT_PRIMARY_FALLING, r PASS_ENGINE_PARAMETER); assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization - state.decodeTriggerEvent(SHAFT_PRIMARY_UP, ++r PASS_ENGINE_PARAMETER); + state.decodeTriggerEvent(SHAFT_PRIMARY_RISING, ++r PASS_ENGINE_PARAMETER); assertTrue(state.shaft_is_synchronized); // first signal rise synchronize assertEquals(0, state.getCurrentIndex()); - state.decodeTriggerEvent(SHAFT_PRIMARY_DOWN, r++ PASS_ENGINE_PARAMETER); + state.decodeTriggerEvent(SHAFT_PRIMARY_FALLING, r++ PASS_ENGINE_PARAMETER); assertEquals(1, state.getCurrentIndex()); for (int i = 2; i < 10;) { - state.decodeTriggerEvent(SHAFT_PRIMARY_UP, r++ PASS_ENGINE_PARAMETER); + state.decodeTriggerEvent(SHAFT_PRIMARY_RISING, r++ PASS_ENGINE_PARAMETER); assertEqualsM("even", i++, state.getCurrentIndex()); - state.decodeTriggerEvent(SHAFT_PRIMARY_DOWN, r++ PASS_ENGINE_PARAMETER); + state.decodeTriggerEvent(SHAFT_PRIMARY_FALLING, r++ PASS_ENGINE_PARAMETER); assertEqualsM("odd", i++, state.getCurrentIndex()); } - state.decodeTriggerEvent(SHAFT_PRIMARY_UP, r++ PASS_ENGINE_PARAMETER); + state.decodeTriggerEvent(SHAFT_PRIMARY_RISING, r++ PASS_ENGINE_PARAMETER); assertEquals(10, state.getCurrentIndex()); - state.decodeTriggerEvent(SHAFT_PRIMARY_DOWN, r++ PASS_ENGINE_PARAMETER); + state.decodeTriggerEvent(SHAFT_PRIMARY_FALLING, r++ PASS_ENGINE_PARAMETER); assertEquals(11, state.getCurrentIndex()); - state.decodeTriggerEvent(SHAFT_PRIMARY_UP, r++ PASS_ENGINE_PARAMETER); + state.decodeTriggerEvent(SHAFT_PRIMARY_RISING, r++ PASS_ENGINE_PARAMETER); assertEquals(0, state.getCurrentIndex()); // new revolution assertEqualsM("running dwell", 0.5, getSparkDwell(2000 PASS_ENGINE_PARAMETER)); @@ -354,7 +354,7 @@ void testRpmCalculator(void) { InjectionEvent *ie0 = ð.engine.engineConfiguration2->injectionEvents->injectionEvents.elements[0]; assertEqualsM("injection angle", 0, ie0->injectionStart.angleOffset); - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING PASS_ENGINE_PARAMETER); assertEquals(1500, eth.engine.rpmCalculator.rpmValue); assertEqualsM("dwell", 4.5, eth.engine.engineState.dwellAngle); @@ -393,11 +393,11 @@ void testRpmCalculator(void) { schedulingQueue.clear(); timeNow += 5000; - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING PASS_ENGINE_PARAMETER); timeNow += 5000; // 5ms - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING PASS_ENGINE_PARAMETER); timeNow += 5000; - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING PASS_ENGINE_PARAMETER); assertEqualsM("index #3", 3, eth.engine.triggerCentral.triggerState.getCurrentIndex()); assertEqualsM("queue size 3", 6, schedulingQueue.size()); assertEqualsM("ev 3", st + 13333, schedulingQueue.getForUnitText(0)->momentX); @@ -412,15 +412,15 @@ void testRpmCalculator(void) { timeNow += 5000; assertEqualsM("Size 4.1", 6, engine->engineConfiguration2->injectionEvents->eventsCount); assertFalseM("No squirts expected 4.1", engine->engineConfiguration2->injectionEvents->hasEvents[4]); - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING PASS_ENGINE_PARAMETER); assertEqualsM("queue size 4.1", 0, schedulingQueue.size()); timeNow += 5000; // 5ms - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING PASS_ENGINE_PARAMETER); assertEqualsM("queue size 4.2", 6, schedulingQueue.size()); timeNow += 5000; // 5ms - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING PASS_ENGINE_PARAMETER); assertEqualsM("queue size 4.3", 6, schedulingQueue.size()); assertEqualsM("dwell", 4.5, eth.engine.engineState.dwellAngle); @@ -443,12 +443,12 @@ void testRpmCalculator(void) { schedulingQueue.clear(); timeNow += 5000; - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING PASS_ENGINE_PARAMETER); assertEqualsM("queue size 5", 0, schedulingQueue.size()); schedulingQueue.clear(); timeNow += 5000; // 5ms - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING PASS_ENGINE_PARAMETER); assertEqualsM("queue size 6", 6, schedulingQueue.size()); assertEqualsM("6/0", st + 40000, schedulingQueue.getForUnitText(0)->momentX); assertEqualsM("6/1", st + 40000, schedulingQueue.getForUnitText(1)->momentX); @@ -456,12 +456,12 @@ void testRpmCalculator(void) { schedulingQueue.clear(); timeNow += 5000; - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING PASS_ENGINE_PARAMETER); assertEqualsM("queue size 7", 0, schedulingQueue.size()); schedulingQueue.clear(); timeNow += 5000; // 5ms - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING PASS_ENGINE_PARAMETER); assertEqualsM("queue size 8", 6, schedulingQueue.size()); assertEqualsM("8/0", st + 53333, schedulingQueue.getForUnitText(0)->momentX); assertEqualsM("8/1", st + 53333, schedulingQueue.getForUnitText(1)->momentX); @@ -470,12 +470,12 @@ void testRpmCalculator(void) { schedulingQueue.clear(); timeNow += 5000; - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING PASS_ENGINE_PARAMETER); assertEqualsM("queue size 9", 0, schedulingQueue.size()); schedulingQueue.clear(); timeNow += 5000; // 5ms - eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER); + eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING PASS_ENGINE_PARAMETER); assertEqualsM("queue size 10", 0, schedulingQueue.size()); schedulingQueue.clear(); } @@ -553,7 +553,7 @@ void testTriggerDecoder(void) { assertEqualsM("index for 668", 11, t->triggerIndexByAngle[668]); - eth.persistentConfig.engineConfiguration.useOnlyFrontForTrigger = false; + eth.persistentConfig.engineConfiguration.useOnlyRisingEdgeForTrigger = false; eth.persistentConfig.engineConfiguration.bc.sensorChartMode = SC_DETAILED_RPM; applyNonPersistentConfiguration(NULL PASS_ENGINE_PARAMETER); @@ -574,8 +574,8 @@ void testTriggerDecoder(void) { EngineTestHelper eth(DODGE_NEON_2003); EXPAND_EngineTestHelper; - printf("!!!!!!!!!!!!!!!!!! Now trying with only front events !!!!!!!!!!!!!!!!!\r\n"); - engineConfiguration->useOnlyFrontForTrigger = true; + printf("!!!!!!!!!!!!!!!!!! Now trying with only rising edges !!!!!!!!!!!!!!!!!\r\n"); + engineConfiguration->useOnlyRisingEdgeForTrigger = true; applyNonPersistentConfiguration(NULL PASS_ENGINE_PARAMETER); prepareShapes(PASS_ENGINE_PARAMETER_F);