diff --git a/unit_tests/.cproject b/unit_tests/.cproject
index cb910d6b94..3732922bb8 100644
--- a/unit_tests/.cproject
+++ b/unit_tests/.cproject
@@ -71,7 +71,7 @@
-
+
@@ -119,7 +119,7 @@
-
+
diff --git a/unit_tests/Makefile b/unit_tests/Makefile
index 2cc0a88e0d..17041869be 100644
--- a/unit_tests/Makefile
+++ b/unit_tests/Makefile
@@ -86,19 +86,20 @@ CSRC = $(UTILSRC) \
$(CONTROLLERS_MATH_SRC) \
$(CONTROLLERS_SENSORS_SRC) \
$(ENGINES_SRC) \
- $(PROJECT_DIR)/controllers/trigger/trigger_mazda.c \
- $(PROJECT_DIR)/controllers/trigger/trigger_structure.c \
$(TEST_SRC_C)
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC = $(UTILSRC_CPP) \
$(CONTROLLERS_ALGO_SRC_CPP) \
+ $(PROJECT_DIR)/controllers/trigger/trigger_mazda.cpp \
$(PROJECT_DIR)/controllers/trigger/trigger_chrysler.cpp \
$(PROJECT_DIR)/controllers/trigger/trigger_gm.cpp \
$(PROJECT_DIR)/controllers/trigger/trigger_decoder.cpp \
+ $(PROJECT_DIR)/controllers/trigger/trigger_structure.cpp \
$(ENGINES_SRC_CPP) \
$(CONTROLLERS_MATH_SRC_CPP) \
+ $(CONTROLLERS_SENSORS_SRC_CPP) \
$(TEST_SRC_CPP) \
main.cpp
diff --git a/unit_tests/efifeatures.h b/unit_tests/efifeatures.h
index 5827283bd1..7712b23b37 100644
--- a/unit_tests/efifeatures.h
+++ b/unit_tests/efifeatures.h
@@ -16,5 +16,7 @@
#define EFI_SUPPORT_FORD_FIESTA TRUE
#define EFI_SUPPORT_NISSAN_PRIMERA TRUE
+#define EFI_SIGNAL_EXECUTOR_ONE_TIMER TRUE
+
#endif /* EFIFEATURES_H_ */
diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp
index cfb61a912d..2bab2a75af 100644
--- a/unit_tests/main.cpp
+++ b/unit_tests/main.cpp
@@ -14,6 +14,8 @@
#include "main.h"
#include "error_handling.h"
+#include "ec2.h"
+
extern "C"
{
@@ -23,7 +25,6 @@ extern "C"
#include "test_interpolation_3d.h"
#include "test_find_index.h"
#include "test_fuel_map.h"
-#include "test_engine_math.h"
#include "test_event_registry.h"
#include "test_sensors.h"
#include "test_signal_executor.h"
@@ -32,6 +33,7 @@ extern "C"
#include "engine_math.h"
}
+#include "test_engine_math.h"
#include "test_trigger_decoder.h"
static engine_configuration_s ec;
@@ -45,7 +47,7 @@ uint64_t getTimeNowUs(void) {
return 0;
}
-void assertEqualsM(char *msg, float expected, float actual) {
+void assertEqualsM(const char *msg, float expected, float actual) {
if (cisnan(actual) && !cisnan(expected)) {
printf("Unexpected: %s %.4f while expected %.4f\r\n", msg, actual, expected);
exit(-1);
@@ -64,7 +66,7 @@ void assertEquals(float expected, float actual) {
assertEqualsM("", expected, actual);
}
-void assertTrueM(char *msg, float actual) {
+void assertTrueM(const char *msg, float actual) {
assertEqualsM(msg, TRUE, actual);
}
@@ -72,7 +74,7 @@ void assertTrue(float actual) {
assertTrueM("", actual);
}
-void assertFalseM(char *msg, float actual) {
+void assertFalseM(const char *msg, float actual) {
assertEqualsM(msg, FALSE, actual);
}
@@ -117,7 +119,7 @@ int main(void) {
testPinHelper();
testSetTableValue();
- printf("Success 20130422\r\n");
+ printf("Success 20130429\r\n");
// resizeMap();
diff --git a/unit_tests/main.h b/unit_tests/main.h
index e605c6e613..5122fb4ce4 100644
--- a/unit_tests/main.h
+++ b/unit_tests/main.h
@@ -40,12 +40,12 @@ void print(const char *fmt, ...);
#define chDbgCheck(x, y) chDbgAssert(x, y, NULL)
-void assertEqualsM(char *msg, float expected, float actual);
+void assertEqualsM(const char *msg, float expected, float actual);
void assertEquals(float expected, float actual);
void assertTrue(float actual);
-void assertTrueM(char *msg, float actual);
+void assertTrueM(const char *msg, float actual);
void assertFalse(float actual);
-void assertFalseM(char *msg, float actual);
+void assertFalseM(const char *msg, float actual);
float getIntakeAirTemperature(void);
float getCoolantTemperature(void);
diff --git a/unit_tests/test.mk b/unit_tests/test.mk
index e983a44c70..fe5910bf36 100644
--- a/unit_tests/test.mk
+++ b/unit_tests/test.mk
@@ -1,5 +1,4 @@
TEST_SRC_C = boards.c \
- test_data_structures/test_engine_math.c \
test_basic_math/test_find_index.c \
test_basic_math/test_interpolation_3d.c \
test_idle_controller.c \
@@ -7,6 +6,7 @@ TEST_SRC_C = boards.c \
TEST_SRC_CPP = test_util.cpp \
test_data_structures/test_event_registry.cpp \
+ test_data_structures/test_engine_math.cpp \
test_trigger_decoder.cpp \
test_fuel_map.cpp \
test_signal_executor.cpp
diff --git a/unit_tests/test_data_structures/test_event_registry.c b/unit_tests/test_data_structures/test_event_registry.c
deleted file mode 100644
index e7d2bd025a..0000000000
--- a/unit_tests/test_data_structures/test_event_registry.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * test_event_registry.c
- *
- * Created on: Nov 27, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "event_registry.h"
-#include "test_event_registry.h"
-#include "main.h"
-
-static ActuatorEventList eventList;
-static ActuatorEventList result;
-
-int pinDefaultState[IO_PIN_COUNT];
-
-void initOutputSignal(OutputSignal *signal, io_pin_e ioPin) {
- signal->io_pin = ioPin;
-}
-
-extern int outputSignalCount;
-
-void testEventRegistry(void) {
- printf("*************************************** testEventRegistry\r\n");
-
- printf("resetting\r\n");
- resetEventList(&eventList);
- resetOutputSignals();
- printf("registering 0\r\n");
-
- registerActuatorEvent(&eventList, 0, addOutputSignal(10), 0);
- registerActuatorEvent(&eventList, 0, addOutputSignal(20), 10);
- assertEquals(2, eventList.size);
-
- printf("registering 1\r\n");
- registerActuatorEvent(&eventList, 1, addOutputSignal(30), 0);
- registerActuatorEvent(&eventList, 1, addOutputSignal(40), 10);
- assertEquals(4, eventList.size);
-
- printf("Looking for 0\r\n");
- findEvents(0, &eventList, &result);
- assertEquals(2, result.size);
- assertEquals(4, eventList.size);
-
- printf("Validating pins\r\n");
- assertEquals(10, result.events[0].actuator->io_pin);
- assertEquals(20, result.events[1].actuator->io_pin);
-
- printf("Looking for 1\r\n");
- findEvents(1, &eventList, &result);
- assertEquals(2, result.size);
- assertEquals(4, eventList.size);
-
- assertEquals(30, result.events[0].actuator->io_pin);
- assertEquals(40, result.events[1].actuator->io_pin);
-}
diff --git a/unit_tests/test_engine_math.c b/unit_tests/test_engine_math.c
deleted file mode 100644
index f6deca3558..0000000000
--- a/unit_tests/test_engine_math.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * @file test_engine_math.c
- *
- * Created on: Nov 14, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "test_engine_math.h"
-#include "main.h"
-#include "engine_math.h"
-#include "engine_configuration.h"
-
-extern engine_configuration_s *engineConfiguration;
-extern engine_configuration2_s *engineConfiguration2;
-
-void testEngineMath(void) {
- printf("*************************************************** testEngineMath\r\n");
-
- engineConfiguration->rpmMultiplier = 0.5;
-
- assertEqualsM("600 RPM", 5000, getOneDegreeTime(600) * 180);
- assertEqualsM("6000 RPM", 500, getOneDegreeTime(6000) * 180);
-}
-
-float getMap(void) {
- return 0;
-}
diff --git a/unit_tests/test_fuel_map.c b/unit_tests/test_fuel_map.c
deleted file mode 100644
index 337dc6a561..0000000000
--- a/unit_tests/test_fuel_map.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * @file test_fuel_map.c
- *
- * Created on: Nov 6, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "main.h"
-#include "engine_configuration.h"
-#include "fuel_math.h"
-#include "trigger_structure.h"
-#include "allsensors.h"
-#include "engine_math.h"
-
-extern engine_configuration_s *engineConfiguration;
-extern engine_configuration2_s *engineConfiguration2;
-
-void testFuelMap(void) {
- chDbgCheck(engineConfiguration!=NULL, "engineConfiguration");
-
- printf("*************************************************** testFuelMap\r\n");
-
- for (int k = 0; k < FUEL_LOAD_COUNT; k++) {
- for (int r = 0; r < FUEL_RPM_COUNT; r++) {
- engineConfiguration->fuelTable[k][r] = k * 200 + r;
- }
- }
- printf("*************************************************** initThermistors\r\n");
-
- initThermistors();
-
- printf("*** getInjectorLag\r\n");
- assertEquals(0, getInjectorLag(12));
-
- for (int i = 0; i < FUEL_LOAD_COUNT; i++)
- engineConfiguration->fuelLoadBins[i] = i;
- for (int i = 0; i < FUEL_RPM_COUNT; i++)
- engineConfiguration->fuelRpmBins[i] = i;
-
- printf("*************************************************** prepareFuelMap\r\n");
- prepareFuelMap();
- assertEquals(1005, getBaseFuel(5, 5));
-
- engineConfiguration->injectorLag = 0.5;
-
- for (int i = 0; i < VBAT_INJECTOR_CURVE_SIZE; i++) {
- engineConfiguration->battInjectorLagCorrBins[i] = i;
- engineConfiguration->battInjectorLagCorr[i] = 2 * i;
- }
-
- // because all the correction tables are zero
- printf("*************************************************** getRunningFuel\r\n");
- assertEquals(1005.5, getRunningFuel(5, 5));
-
- printf("*************************************************** setting IAT table\r\n");
- for (int i = 0; i < IAT_CURVE_SIZE; i++) {
- engineConfiguration->iatFuelCorrBins[i] = i;
- engineConfiguration->iatFuelCorr[i] = 2 * i;
- }
- engineConfiguration->iatFuelCorr[0] = 2;
-
- printf("*************************************************** setting CLT table\r\n");
- for (int i = 0; i < CLT_CURVE_SIZE; i++) {
- engineConfiguration->cltFuelCorrBins[i] = i;
- engineConfiguration->cltFuelCorr[i] = 1;
- }
- engineConfiguration->injectorLag = 0;
-
- assertEquals(NAN, getIntakeAirTemperature());
- float iatCorrection = getIatCorrection(-KELV);
- assertEqualsM("IAT", 2, iatCorrection);
- float cltCorrection = getCltCorrection(getCoolantTemperature());
- assertEqualsM("CLT", 1, cltCorrection);
- float injectorLag = getInjectorLag(getVBatt());
- assertEquals(0, injectorLag);
-
-
- // 1005 * 2 for IAT correction
- printf("*************************************************** getRunningFuel\r\n");
- assertEquals(1005, getRunningFuel(5, 5));
-
- engineConfiguration->crankingSettings.coolantTempMaxC = 65; // 8ms at 65C
- engineConfiguration->crankingSettings.fuelAtMaxTempMs = 8;
-
- engineConfiguration->crankingSettings.coolantTempMinC = 0; // 20ms at 0C
- engineConfiguration->crankingSettings.fuelAtMinTempMs = 20;
-
- printf("*************************************************** getStartingFuel\r\n");
- // NAN in case we have issues with the CLT sensor
-// assertEquals(16, getStartingFuel(NAN));
- assertEquals(20, getStartingFuel(0));
- assertEquals(18.5231, getStartingFuel(8));
- assertEquals(8, getStartingFuel(70));
-}
-
-static void confgiureFordAspireTriggerShape(trigger_shape_s * s) {
- triggerShapeInit(s);
-
- triggerAddEvent(s, 53.747, T_SECONDARY, 1);
- triggerAddEvent(s, 121.90, T_SECONDARY, 0);
- triggerAddEvent(s, 232.76, T_SECONDARY, 1);
- triggerAddEvent(s, 300.54, T_SECONDARY, 0);
- triggerAddEvent(s, 360, T_PRIMARY, 1);
-
- triggerAddEvent(s, 409.8412, T_SECONDARY, 1);
- triggerAddEvent(s, 478.6505, T_SECONDARY, 0);
- triggerAddEvent(s, 588.045, T_SECONDARY, 1);
- triggerAddEvent(s, 657.03, T_SECONDARY, 0);
- triggerAddEvent(s, 720, T_PRIMARY, 0);
-}
-
-
-static ActuatorEventList ae;
-
-extern int outputSignalCount;
-
-void testAngleResolver(void) {
- printf("*************************************************** testAngleResolver\r\n");
-
- engineConfiguration->globalTriggerAngleOffset = 175;
- trigger_shape_s * ts = &engineConfiguration2->triggerShape;
-
- confgiureFordAspireTriggerShape(ts);
- assertEqualsM("shape size", 10, ts->size);
-
- resetOutputSignals();
-
- resetEventList(&ae);
- printf("*************************************************** testAngleResolver 0\r\n");
- registerActuatorEventExt(engineConfiguration, &engineConfiguration2->triggerShape, &ae, addOutputSignal(INJECTOR_1_OUTPUT), 53 - 175);
- assertEquals(1, ae.size);
- assertEquals(1, outputSignalCount);
- assertEquals(0, ae.events[0].eventIndex);
- assertEquals(53, ae.events[0].angleOffset);
-
- printf("*************************************************** testAngleResolver 2\r\n");
- resetEventList(&ae);
- registerActuatorEventExt(engineConfiguration, &engineConfiguration2->triggerShape, &ae, addOutputSignal(INJECTOR_1_OUTPUT), 51 + 180 - 175);
- assertEquals(2, ae.events[0].eventIndex);
- assertEquals(51.9870, ae.events[0].angleOffset);
-}
-
-void testPinHelper(void) {
- printf("*************************************************** testPinHelper\r\n");
- assertEquals(0, getElectricalValue(0, OM_DEFAULT));
- assertEquals(1, getElectricalValue(1, OM_DEFAULT));
-
- assertEquals(0, getElectricalValue(1, OM_INVERTED));
- assertEquals(1, getElectricalValue(0, OM_INVERTED));
-}
diff --git a/unit_tests/test_signal_executor.c b/unit_tests/test_signal_executor.c
deleted file mode 100644
index ab066951d0..0000000000
--- a/unit_tests/test_signal_executor.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * @file test_signal_executor.c
- *
- * @date Nov 28, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include
-#include "main.h"
-
-#include "signal_executor.h"
-#include "signal_executor_single_timer_algo.h"
-#include "test_signal_executor.h"
-#include "io_pins.h"
-#include "utlist.h"
-
-extern OutputSignal *st_output_list;
-
-static io_pin_e testLastToggledPin;
-static int testToggleCounter;
-
-void setOutputPinValue(io_pin_e pin, int value) {
- // this is a test implementation of the method - we use it to see what's going on
- testLastToggledPin = pin;
- testToggleCounter++;
-}
-
-void scheduleTask(scheduling_s *scheduling, int delay, schfunc_t callback, void *param) {
-
-}
-
-void testSignalExecutor() {
- print("*************************************** testSignalExecutor\r\n");
-
-// OutputSignal s1;
-// OutputSignal s2;
-//
-// registerSignal(&s1);
-// registerSignal(&s2);
-//
-// OutputSignal *out;
-// int count;
-// LL_COUNT(st_output_list, out, count);
-// assertEquals(2, count);
-//
-// s1.io_pin = 0;
-// initOutputSignalBase(&s1);
-// assertEqualsM("status", IDLE, s1.status);
-// scheduleOutputBase(&s1, 10, 100);
-//
-// long now = 1;
-// print("now = 1\r\n");
-// testToggleCounter = 0;
-// assertEqualsM("duration", 10, GET_DURATION(&s1));
-// assertEquals(9, toggleSignalIfNeeded(&s1, now));
-// assertEquals(0, testToggleCounter);
-//
-// now = 100;
-// print("now = 100\r\n");
-// testToggleCounter = 0;
-// assertEquals(100, toggleSignalIfNeeded(&s1, now));
-// assertEquals(1, testToggleCounter);
-//
-// print("now = 300\r\n");
-// now = 300; // let's see what happens if the handler is late
-// testToggleCounter = 0;
-// assertEquals(10, toggleSignalIfNeeded(&s1, now));
-// assertEquals(1, testToggleCounter);
-}
diff --git a/unit_tests/test_trigger_decoder.c b/unit_tests/test_trigger_decoder.c
deleted file mode 100644
index 08082b4c3f..0000000000
--- a/unit_tests/test_trigger_decoder.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/**
- * @file test_trigger_decoder.c
- *
- * @date Dec 24, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "main.h"
-#include "test_trigger_decoder.h"
-#include "trigger_decoder.h"
-#include "engine_math.h"
-
-#include "ford_aspire.h"
-#include "dodge_neon.h"
-#include "ford_1995_inline_6.h"
-#include "mazda_323.h"
-
-void sendOutConfirmation(char *value, int i) {
- // test implementation
-}
-
-static void testDodgeNeonDecoder(void) {
- printf("*************************************************** testDodgeNeonDecoder\r\n");
- initTriggerDecoder();
-
- engine_configuration_s ec;
- engine_configuration2_s ec2;
-
- resetConfigurationExt(DODGE_NEON_1995, &ec, &ec2);
-
- trigger_shape_s * shape = &ec2.triggerShape;
- trigger_state_s state;
- clearTriggerState(&state);
-
-
-
-
- assertFalseM("1 shaft_is_synchronized", state.shaft_is_synchronized);
-
-
- int r = 0;
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 60);
- assertFalseM("2 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r + 210);
- assertFalseM("3 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 420);
- assertFalseM("4 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, 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);
- assertTrue(state.shaft_is_synchronized);
- assertEquals(0, state.current_index);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 420);
- assertEquals(1, state.current_index);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, 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);
- assertEqualsM("current index", 3, state.current_index);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, 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);
-}
-
-static void test1995FordInline6TriggerDecoder(void) {
- printf("*************************************************** test1995FordInline6TriggerDecoder\r\n");
- initTriggerDecoder();
- resetOutputSignals();
-
- engine_configuration_s ec;
- engine_configuration2_s ec2;
-
- resetConfigurationExt(FORD_INLINE_6_1995, &ec, &ec2);
-
- ActuatorEventList *ecl = &ec2.engineEventConfiguration.ignitionEvents;
- assertEqualsM("ignition events size", 6, ecl->size);
- assertEqualsM("event index", 0, ecl->events[0].eventIndex);
- assertEquals(13, ecl->events[0].angleOffset);
-
- assertEqualsM("event index", 10, ecl->events[5].eventIndex);
- assertEquals(13, ecl->events[5].angleOffset);
-
- trigger_state_s state;
- clearTriggerState(&state);
-
- trigger_shape_s * shape = &ec2.triggerShape;
- assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
- int r = 0;
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r + 10);
- assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 11);
- assertTrue(state.shaft_is_synchronized); // first signal rise synchronize
- assertEquals(0, state.current_index);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r++);
- assertEquals(1, state.current_index);
-
- for (int i = 2; i < 10;) {
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r++);
- assertEqualsM("even", i++, state.current_index);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r++);
- assertEqualsM("odd", i++, state.current_index);
- }
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r++);
- assertEquals(10, state.current_index);
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r++);
- assertEquals(11, state.current_index);
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r++);
- assertEquals(0, state.current_index); // new revolution
-
- assertEqualsM("running dwell", 0.5, getSparkDwellMsT(&ec, 2000));
-}
-
-void testFordAspire(void) {
- printf("*************************************************** testTriggerDecoder\r\n");
-
- engine_configuration_s ec;
- engine_configuration2_s ec2;
- resetConfigurationExt(FORD_ASPIRE_1996, &ec, &ec2);
-
- assertEqualsM("cranking dwell", 54.166670, getSparkDwellMsT(&ec, 200));
- assertEqualsM("running dwell", 4, getSparkDwellMsT(&ec, 2000));
-
- assertEqualsM("higher rpm dwell", 3.25, getSparkDwellMsT(&ec, 6000));
-}
-
-void testMazda323(void) {
- printf("*************************************************** testMazda323\r\n");
-
- engine_configuration_s ec;
- engine_configuration2_s ec2;
- resetConfigurationExt(MAZDA_323, &ec, &ec2);
-
-}
-
-void testMazdaMianaNbDecoder(void) {
- printf("*************************************************** testMazdaMianaNbDecoder\r\n");
-
- engine_configuration_s ec;
- engine_configuration2_s ec2;
- resetConfigurationExt(MAZDA_MIATA_NB, &ec, &ec2);
-
- trigger_state_s state;
- clearTriggerState(&state);
- trigger_shape_s * shape = &ec2.triggerShape;
-
- int a = 0;
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 20);
- assertFalseM("0a shaft_is_synchronized", state.shaft_is_synchronized);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 340);
- assertFalseM("0b shaft_is_synchronized", state.shaft_is_synchronized);
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 360);
- assertFalseM("0c shaft_is_synchronized", state.shaft_is_synchronized);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 380);
- assertFalseM("0d shaft_is_synchronized", state.shaft_is_synchronized);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 400);
- assertTrueM("0e shaft_is_synchronized", state.shaft_is_synchronized);
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 720);
- assertTrueM("0f shaft_is_synchronized", state.shaft_is_synchronized);
-
- a = 720;
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 20);
- assertTrueM("1a shaft_is_synchronized", state.shaft_is_synchronized);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 340);
- assertTrueM("1b shaft_is_synchronized", state.shaft_is_synchronized);
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 360);
- assertTrueM("1c shaft_is_synchronized", state.shaft_is_synchronized);
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 380);
- assertTrueM("1d shaft_is_synchronized", state.shaft_is_synchronized);
- assertEquals(5, state.current_index);
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 400);
- assertTrueM("1e shaft_is_synchronized", state.shaft_is_synchronized);
- assertEquals(0, state.current_index);
-
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 720);
- assertTrueM("1f shaft_is_synchronized", state.shaft_is_synchronized);
-
-
-}
-
-void testGY6_139QMB(void) {
- printf("*************************************************** testGY6_139QMB\r\n");
-
- engine_configuration_s ec;
- engine_configuration2_s ec2;
- resetConfigurationExt(GY6_139QMB, &ec, &ec2);
-
- trigger_state_s state;
- clearTriggerState(&state);
- assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
-
- trigger_shape_s * shape = &ec2.triggerShape;
-
- assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
- assertEquals(0, state.current_index);
-
- int now = 0;
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, now++);
- assertTrueM("shaft_is_synchronized", state.shaft_is_synchronized);
- assertEquals(0, state.current_index);
-
- processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, now++);
- assertTrueM("shaft_is_synchronized", state.shaft_is_synchronized);
- assertEquals(1, state.current_index);
-}
-
-void testTriggerDecoder(void) {
- printf("*************************************************** testTriggerDecoder\r\n");
-
- engine_configuration2_s ec2;
-
- initializeSkippedToothTriggerShapeExt(&ec2, 2, 0);
- assertEquals(ec2.triggerShape.size, 4);
- assertEquals(ec2.triggerShape.wave.switchTimes[0], 0.25);
- assertEquals(ec2.triggerShape.wave.switchTimes[1], 0.5);
- assertEquals(ec2.triggerShape.wave.switchTimes[2], 0.75);
- assertEquals(ec2.triggerShape.wave.switchTimes[3], 1);
-
- testDodgeNeonDecoder();
- testFordAspire();
- test1995FordInline6TriggerDecoder();
- testMazdaMianaNbDecoder();
- testGY6_139QMB();
-
- testMazda323();
-}
-