diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index 71058c515a..ab4af8957b 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -440,6 +440,8 @@ case Force_4b_firing_order: return "Force_4b_firing_order"; case FO_1_THEN_2_THEN_4_THEN3: return "FO_1_THEN_2_THEN_4_THEN3"; +case FO_1_2_4_5_3: + return "FO_1_2_4_5_3"; } return NULL; } diff --git a/firmware/controllers/algo/ec2.h b/firmware/controllers/algo/ec2.h index 04c32ab15b..adb82a8a5a 100644 --- a/firmware/controllers/algo/ec2.h +++ b/firmware/controllers/algo/ec2.h @@ -45,8 +45,6 @@ public: // todo: this should go, too engine_configuration_s *engineConfiguration; - trigger_shape_s triggerShape; - FuelSchedule crankingInjectionEvents; FuelSchedule injectionEvents; @@ -64,7 +62,7 @@ public: }; void initializeIgnitionActions(float advance, float dwellAngle, - engine_configuration2_s *engineConfiguration2, IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S); + IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S); void setDefaultNonPersistentConfiguration(engine_configuration2_s *engineConfiguration2); void printConfiguration(engine_configuration_s *engineConfiguration, engine_configuration2_s *engineConfiguration2); diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index ba1fc3bf93..24eae247e1 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -36,6 +36,8 @@ public: Thermistor iat; Thermistor clt; + trigger_shape_s triggerShape; + void onTriggerEvent(uint64_t nowNt); EngineState engineState; uint64_t lastTriggerEventTimeNt; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index d67e54c4eb..73dc5ef3c4 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -585,12 +585,12 @@ void applyNonPersistentConfiguration(Logging * logger, Engine *engine) { #if EFI_PROD_CODE scheduleMsg(logger, "applyNonPersistentConfiguration()"); #endif - initializeTriggerShape(logger, engineConfiguration, engineConfiguration2, engine); - if (engineConfiguration2->triggerShape.getSize() == 0) { + initializeTriggerShape(logger, engineConfiguration, engine); + if (engine->triggerShape.getSize() == 0) { firmwareError("triggerShape size is zero"); return; } - if (engineConfiguration2->triggerShape.shaftPositionEventCount == 0) { + if (engine->triggerShape.shaftPositionEventCount == 0) { firmwareError("shaftPositionEventCount is zero"); return; } @@ -602,8 +602,7 @@ void prepareShapes(Engine *engine) { engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2; // todo: looks like this is here only for unit tests. todo: remove - initializeIgnitionActions(0, 0, engineConfiguration2, - &engineConfiguration2->ignitionEvents[0] PASS_ENGINE_PARAMETER); + initializeIgnitionActions(0, 0, &engineConfiguration2->ignitionEvents[0] PASS_ENGINE_PARAMETER); } void setOperationMode(engine_configuration_s *engineConfiguration, operation_mode_e mode) { diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 2fd08ed08a..d1406b4ee3 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -241,11 +241,16 @@ typedef enum { typedef enum { FO_ONE_CYLINDER = 0, + // 4 cylinder FO_1_THEN_3_THEN_4_THEN2 = 1, FO_1_THEN_2_THEN_4_THEN3 = 2, FO_1_THEN_3_THEN_2_THEN4 = 3, + // 6 cylinder FO_1_THEN_5_THEN_3_THEN_6_THEN_2_THEN_4 = 4, + // 8 cylinder FO_1_8_4_3_6_5_7_2 = 5, + // 5 cylinder + FO_1_2_4_5_3 = 6, Force_4b_firing_order = ENUM_SIZE_HACK, } firing_order_e; diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index f1f658c11d..d96daf59ed 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -121,7 +121,7 @@ static void registerSparkEvent(trigger_shape_s * s, IgnitionEventList *list, io_ findTriggerPosition(s, &event->dwellPosition, localAdvance - dwell PASS_ENGINE_PARAMETER); } -void initializeIgnitionActions(float advance, float dwellAngle, engine_configuration2_s *engineConfiguration2, +void initializeIgnitionActions(float advance, float dwellAngle, IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) { efiAssertVoid(engineConfiguration->cylindersCount > 0, "cylindersCount"); @@ -135,7 +135,7 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura float localAdvance = advance + (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount; - registerSparkEvent(&engineConfiguration2->triggerShape, list, SPARKOUT_1_OUTPUT, localAdvance, + registerSparkEvent(&engine->triggerShape, list, SPARKOUT_1_OUTPUT, localAdvance, dwellAngle PASS_ENGINE_PARAMETER); } break; @@ -149,7 +149,7 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura int id = getCylinderId(engineConfiguration->firingOrder, wastedIndex) - 1; io_pin_e ioPin = (io_pin_e) (SPARKOUT_1_OUTPUT + id); - registerSparkEvent(&engineConfiguration2->triggerShape, list, ioPin, localAdvance, + registerSparkEvent(&engine->triggerShape, list, ioPin, localAdvance, dwellAngle PASS_ENGINE_PARAMETER); } @@ -161,7 +161,7 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura + (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount; io_pin_e pin = (io_pin_e) ((int) SPARKOUT_1_OUTPUT + getCylinderId(engineConfiguration->firingOrder, i) - 1); - registerSparkEvent(&engineConfiguration2->triggerShape, list, pin, localAdvance, + registerSparkEvent(&engine->triggerShape, list, pin, localAdvance, dwellAngle PASS_ENGINE_PARAMETER); } break; @@ -359,10 +359,9 @@ void prepareOutputSignals(Engine *engine) { engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2; // todo: move this reset into decoder - engineConfiguration2->triggerShape.calculateTriggerSynchPoint(engineConfiguration, - &engineConfiguration->triggerConfig, engine); + engine->triggerShape.calculateTriggerSynchPoint(engineConfiguration, engine); - trigger_shape_s * ts = &engineConfiguration2->triggerShape; + trigger_shape_s * ts = &engine->triggerShape; injectonSignals.clear(); engineConfiguration2->crankingInjectionEvents.addFuelEvents(ts, diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index aad67229ad..1ccb41af1c 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -403,7 +403,7 @@ static void setTriggerType(int value) { } static void setToothedWheel(int total, int skipped) { - setToothedWheelConfiguration(&engineConfiguration2->triggerShape, total, skipped, engineConfiguration); + setToothedWheelConfiguration(&engine->triggerShape, total, skipped, engineConfiguration); // initializeTriggerShape(&logger, engineConfiguration, engineConfiguration2); incrementGlobalConfigurationVersion(); doPrintConfiguration(engine); diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index d5f8a9cf4b..df7e40c860 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -149,7 +149,7 @@ static ALWAYS_INLINE void handleFuel(uint32_t eventIndex, int rpm DECLARE_ENGINE if (!isInjectionEnabled(engine->engineConfiguration)) return; efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#3"); - efiAssertVoid(eventIndex < engine->engineConfiguration2->triggerShape.getLength(), "event index"); + efiAssertVoid(eventIndex < engine->triggerShape.getLength(), "event index"); /** * Ignition events are defined by addFuelEvents() according to selected @@ -218,7 +218,7 @@ static ALWAYS_INLINE void handleSparkEvent(uint32_t eventIndex, IgnitionEvent *i * TODO: improve precision */ - findTriggerPosition(&engineConfiguration2->triggerShape, &iEvent->sparkPosition, + findTriggerPosition(&engine->triggerShape, &iEvent->sparkPosition, iEvent->advance PASS_ENGINE_PARAMETER); if (iEvent->sparkPosition.eventIndex == eventIndex) { @@ -297,7 +297,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng } (void) ckpSignalType; - efiAssertVoid(eventIndex < 2 * engine->engineConfiguration2->triggerShape.shaftPositionEventCount, "event index"); + efiAssertVoid(eventIndex < 2 * engine->triggerShape.shaftPositionEventCount, "event index"); efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#2"); // todo: remove these local variables soon? @@ -366,7 +366,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng // todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that - initializeIgnitionActions(fixAngle(-advance PASS_ENGINE_PARAMETER), dwellAngle, engine->engineConfiguration2, + initializeIgnitionActions(fixAngle(-advance PASS_ENGINE_PARAMETER), dwellAngle, &engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER); } diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 2d08e5888b..26ecdff2d1 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -135,7 +135,7 @@ void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) { } previousShaftEventTimeNt = nowNt; - trigger_shape_s * triggerShape = &engine->engineConfiguration2->triggerShape; + trigger_shape_s * triggerShape = &engine->triggerShape; /** * This invocation changes the state of triggerState @@ -162,7 +162,7 @@ void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) { } reportEventToWaveChart(signal, triggerIndexForListeners); - if (triggerState.getCurrentIndex() >= engine->engineConfiguration2->triggerShape.shaftPositionEventCount) { + if (triggerState.getCurrentIndex() >= engine->triggerShape.shaftPositionEventCount) { warning(OBD_PCM_Processor_Fault, "unexpected eventIndex=%d", triggerState.getCurrentIndex()); } else { @@ -196,7 +196,7 @@ extern board_configuration_s *boardConfiguration; static void triggerShapeInfo(Engine *engine) { #if EFI_PROD_CODE || EFI_SIMULATOR - trigger_shape_s *s = &engineConfiguration2->triggerShape; + trigger_shape_s *s = &engine->triggerShape; for (int i = 0; i < s->getSize(); i++) { scheduleMsg(&logger, "event %d %f", i, s->eventAngles[i]); } @@ -212,7 +212,7 @@ extern uint32_t maxLockTime; static void triggerInfo(Engine *engine) { #if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__) - trigger_shape_s *ts = &engineConfiguration2->triggerShape; + trigger_shape_s *ts = &engine->triggerShape; scheduleMsg(&logger, "Template %s/%d trigger %d", getConfigurationName(engineConfiguration->engineType), engineConfiguration->engineType, engineConfiguration->triggerConfig.triggerType); @@ -222,13 +222,12 @@ static void triggerInfo(Engine *engine) { scheduleMsg(&logger, "trigger event counters %d/%d/%d/%d", triggerCentral.getHwEventCounter(0), triggerCentral.getHwEventCounter(1), triggerCentral.getHwEventCounter(2), triggerCentral.getHwEventCounter(3)); - scheduleMsg(&logger, "expected cycle events %d/%d/%d", engineConfiguration2->triggerShape.expectedEventCount[0], - engineConfiguration2->triggerShape.expectedEventCount[1], ts->expectedEventCount[2]); + scheduleMsg(&logger, "expected cycle events %d/%d/%d", ts->expectedEventCount[0], + engine->triggerShape.expectedEventCount[1], ts->expectedEventCount[2]); scheduleMsg(&logger, "trigger type=%d/need2ndChannel=%s", engineConfiguration->triggerConfig.triggerType, boolToString(engineConfiguration->needSecondTriggerInput)); - scheduleMsg(&logger, "expected duty #0=%f/#1=%f", engineConfiguration2->triggerShape.dutyCycle[0], - engineConfiguration2->triggerShape.dutyCycle[1]); + 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", boolToString(isTriggerDecoderError()), diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 53f7fee0b4..62dddd0670 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -30,6 +30,7 @@ #include "trigger_structure.h" #include "efiGpio.h" +#include "engine.h" // todo: better name for this constant #define HELPER_PERIOD 100000 @@ -220,12 +221,12 @@ void initializeSkippedToothTriggerShapeExt(trigger_shape_s *s, int totalTeethCou * External logger is needed because at this point our logger is not yet initialized */ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, - engine_configuration2_s *engineConfiguration2, Engine *engine) { + Engine *engine) { #if EFI_PROD_CODE scheduleMsg(logger, "initializeTriggerShape()"); #endif const trigger_config_s *triggerConfig = &engineConfiguration->triggerConfig; - trigger_shape_s *triggerShape = &engineConfiguration2->triggerShape; + trigger_shape_s *triggerShape = &engine->triggerShape; setTriggerSynchronizationGap(triggerShape, 2); triggerShape->useRiseEdge = true; @@ -235,7 +236,7 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin case TT_TOOTHED_WHEEL: // todo: move to into configuration definition engineConfiguration2->triggerShape.needSecondTriggerInput = false; - engineConfiguration2->triggerShape.isSynchronizationNeeded = + triggerShape->isSynchronizationNeeded = engineConfiguration->triggerConfig.customIsSynchronizationNeeded; initializeSkippedToothTriggerShapeExt(triggerShape, triggerConfig->customTotalToothCount, @@ -304,9 +305,8 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin ; return; } - trigger_shape_s *s = &engineConfiguration2->triggerShape; - s->assignSize(); - s->wave.checkSwitchTimes(s->getSize()); + triggerShape->assignSize(); + triggerShape->wave.checkSwitchTimes(triggerShape->getSize()); } TriggerStimulatorHelper::TriggerStimulatorHelper() { diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index 861abd9e82..0ca17d32f8 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -91,7 +91,7 @@ uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape, trigger_config_s con class Engine; -void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, engine_configuration2_s *engineConfiguration2, Engine *engine); +void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, Engine *engine); void initTriggerDecoder(void); bool_t isTriggerDecoderError(void); diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index 7bdc3245b9..15dd04a333 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -94,7 +94,7 @@ static void updateTriggerShapeIfNeeded(PwmConfig *state) { applyNonPersistentConfiguration(&logger, engine); - trigger_shape_s *s = &engineConfiguration2->triggerShape; + trigger_shape_s *s = &engine->triggerShape; int *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates, s->wave.waves[2].pinStates }; copyPwmParameters(state, s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM, pinStates); @@ -137,7 +137,7 @@ static void resumeStimulator(Engine *engine) { void initTriggerEmulatorLogic(Engine *engine) { initLogging(&logger, "position sensor(s) emulator"); - trigger_shape_s *s = &engineConfiguration2->triggerShape; + trigger_shape_s *s = &engine->triggerShape; setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency, engine); int *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates, s->wave.waves[2].pinStates }; diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index d08e9dc22a..767f4604f5 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -55,7 +55,8 @@ int trigger_shape_s::getTriggerShapeSynchPointIndex() { // todo: clean-up! int getEngineCycleEventCount2(operation_mode_e mode, trigger_shape_s * s); -void trigger_shape_s::calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, trigger_config_s const*triggerConfig, Engine *engine) { +void trigger_shape_s::calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, Engine *engine) { + trigger_config_s const*triggerConfig = &engineConfiguration->triggerConfig; setTriggerShapeSynchPointIndex(engineConfiguration, findTriggerZeroEventIndex(this, triggerConfig), engine); } diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index 6013c5d57b..7df92b5a83 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -85,7 +85,7 @@ public: int getTriggerShapeSynchPointIndex(); - void calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, trigger_config_s const*triggerConfig, Engine *engine); + void calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, Engine *engine); void setTriggerShapeSynchPointIndex(engine_configuration_s *engineConfiguration, int triggerShapeSynchPointIndex, Engine *engine); /** diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 0d12c6074f..7ef29502a7 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -256,9 +256,9 @@ void firmwareError(const char *fmt, ...) { } } -static char UNUSED_RAM_SIZE[20000]; +static char UNUSED_RAM_SIZE[10000]; -static char UNUSED_CCM_SIZE[5000] CCM_OPTIONAL; +static char UNUSED_CCM_SIZE[15000] CCM_OPTIONAL; int getRusEfiVersion(void) { if (UNUSED_RAM_SIZE == 0) diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index 35dbcf1f6f..96d1b9139c 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -40,7 +40,7 @@ void EngineTestHelper::fireTriggerEvents() { } void EngineTestHelper::initTriggerShapeAndRpmCalculator() { - initializeTriggerShape(NULL, ec, &ec2, &engine); + initializeTriggerShape(NULL, ec, &engine); incrementGlobalConfigurationVersion(); triggerCentral.addEventListener((ShaftPositionListener) &rpmShaftPositionCallback, "rpm reporter", &engine); diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index f52b7ff957..370a9e9eea 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -92,9 +92,6 @@ void chDbgAssert(int c, char *msg, void *arg) { } } -static engine_configuration2_s ec2; -engine_configuration2_s *engineConfiguration2 = &ec2; - int getRevolutionCounter(void) { return 0; } diff --git a/unit_tests/test_fuel_map.cpp b/unit_tests/test_fuel_map.cpp index 9c866e1100..ef7d1f2ac1 100644 --- a/unit_tests/test_fuel_map.cpp +++ b/unit_tests/test_fuel_map.cpp @@ -159,18 +159,19 @@ void testAngleResolver(void) { engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration; engineConfiguration->globalTriggerAngleOffset = 175; - trigger_shape_s * ts = &engineConfiguration2->triggerShape; + assertTrue(engine->engineConfiguration2!=NULL); + trigger_shape_s * ts = &engine->triggerShape; confgiureFordAspireTriggerShape(ts); - ts->calculateTriggerSynchPoint(engineConfiguration, &engineConfiguration->triggerConfig, engine); + ts->calculateTriggerSynchPoint(engineConfiguration, engine); - assertEqualsM("index 2", 232.76, ts->eventAngles[3]); // this angle is relation to synch point + assertEqualsM("index 2", 228.0450, ts->eventAngles[3]); // this angle is relation to synch point assertEqualsM("time 2", 0.3233, ts->wave.getSwitchTime(2)); - assertEqualsM("index 5", 409.8412, ts->eventAngles[6]); + assertEqualsM("index 5", 413.7470, ts->eventAngles[6]); assertEqualsM("time 5", 0.5692, ts->wave.getSwitchTime(5)); - assertEquals(9, ts->getTriggerShapeSynchPointIndex()); + assertEquals(4, ts->getTriggerShapeSynchPointIndex()); assertEqualsM("shape size", 10, ts->getSize()); @@ -180,14 +181,14 @@ void testAngleResolver(void) { printf("*************************************************** testAngleResolver 0\r\n"); findTriggerPosition(ts, &ae.getNextActuatorEvent()->position, 53 - 175 PASS_ENGINE_PARAMETER); assertEqualsM("size", 1, ae.size); - assertEquals(0, ae.events[0].position.eventIndex); - assertEquals(53, ae.events[0].position.angleOffset); + assertEquals(1, ae.events[0].position.eventIndex); + assertEquals(3.1588, ae.events[0].position.angleOffset); printf("*************************************************** testAngleResolver 2\r\n"); ae.resetEventList(); findTriggerPosition(ts, &ae.getNextActuatorEvent()->position, 51 + 180 - 175 PASS_ENGINE_PARAMETER); - assertEquals(2, ae.events[0].position.eventIndex); - assertEquals(109.1, ae.events[0].position.angleOffset); + assertEquals(3, ae.events[0].position.eventIndex); + assertEquals(2.955, ae.events[0].position.angleOffset); } void testPinHelper(void) { diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index f3e36894a0..fc06b1cada 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -44,7 +44,7 @@ int getTheAngle(engine_type_e engineType) { engine_configuration_s *ec = eth.ec; initDataStructures(ec); - trigger_shape_s * shape = ð.ec2.triggerShape; + trigger_shape_s * shape = ð.engine.triggerShape; return findTriggerZeroEventIndex(shape, &ec->triggerConfig); } @@ -57,7 +57,7 @@ static void testDodgeNeonDecoder(void) { EngineTestHelper eth(DODGE_NEON_1995); engine_configuration_s *ec = eth.ec; - trigger_shape_s * shape = ð.ec2.triggerShape; + trigger_shape_s * shape = ð.engine.triggerShape; assertEquals(8, shape->getTriggerShapeSynchPointIndex()); TriggerState state; @@ -116,7 +116,7 @@ static void test1995FordInline6TriggerDecoder(void) { engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration; Engine *engine = ð.engine; - trigger_shape_s * shape = ð.ec2.triggerShape; + trigger_shape_s * shape = ð.engine.triggerShape; assertEqualsM("triggerShapeSynchPointIndex", 0, shape->getTriggerShapeSynchPointIndex()); @@ -180,7 +180,7 @@ void testFordAspire(void) { Engine *engine = ð.engine; engine_configuration_s *engineConfiguration = eth.ec; - assertEquals(4, eth.ec2.triggerShape.getTriggerShapeSynchPointIndex()); + assertEquals(4, eth.engine.triggerShape.getTriggerShapeSynchPointIndex()); assertEquals(800, engineConfiguration->fuelRpmBins[0]); assertEquals(7000, engineConfiguration->fuelRpmBins[15]); @@ -198,7 +198,7 @@ void testMazda323(void) { printf("*************************************************** testMazda323\r\n"); EngineTestHelper eth(MAZDA_323); - assertEquals(0, eth.ec2.triggerShape.getTriggerShapeSynchPointIndex()); + assertEquals(0, eth.engine.triggerShape.getTriggerShapeSynchPointIndex()); } void testMazdaMianaNbDecoder(void) { @@ -208,7 +208,7 @@ void testMazdaMianaNbDecoder(void) { engine_configuration_s *ec = eth.ec; Engine *engine = ð.engine; engine_configuration_s *engineConfiguration = ec; - trigger_shape_s * shape = ð.ec2.triggerShape; + trigger_shape_s * shape = ð.engine.triggerShape; assertEquals(11, shape->getTriggerShapeSynchPointIndex()); TriggerState state; @@ -294,7 +294,7 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo initSpeedDensity(ec); - trigger_shape_s *t = ð.ec2.triggerShape; + trigger_shape_s *t = ð.engine.triggerShape; assertEqualsM("synchPointIndex", synchPointIndex, t->getTriggerShapeSynchPointIndex()); @@ -311,7 +311,7 @@ void testGY6_139QMB(void) { TriggerState state; assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized); - trigger_shape_s * shape = ð.ec2.triggerShape; + trigger_shape_s * shape = ð.engine.triggerShape; assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized); assertEquals(0, state.getCurrentIndex()); @@ -484,8 +484,8 @@ static void testRpmCalculator(void) { void testTriggerDecoder(void) { printf("*************************************************** testTriggerDecoder\r\n"); - engine_configuration2_s ec2; - trigger_shape_s * s = &ec2.triggerShape; + Engine engine; + trigger_shape_s * s = &engine.triggerShape; initializeSkippedToothTriggerShapeExt(s, 2, 0, FOUR_STROKE_CAM_SENSOR);