From af7d4d77ba21ad18855944ac91a0f445c84afea2 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 31 Oct 2015 16:02:10 -0400 Subject: [PATCH] auto-sync --- .../controllers/algo/auto_generated_enums.cpp | 8 +- firmware/controllers/algo/rusefi_enums.h | 3 +- firmware/controllers/trigger/trigger_bmw.cpp | 20 +- .../controllers/trigger/trigger_chrysler.cpp | 436 +++++++++--------- .../controllers/trigger/trigger_decoder.cpp | 22 +- firmware/controllers/trigger/trigger_gm.cpp | 28 +- .../controllers/trigger/trigger_mazda.cpp | 104 ++--- .../trigger/trigger_mitsubishi.cpp | 44 +- .../controllers/trigger/trigger_nissan.cpp | 4 +- .../controllers/trigger/trigger_structure.cpp | 62 +-- .../controllers/trigger/trigger_subaru.cpp | 20 +- firmware/hw_layer/pwm_generator.cpp | 6 +- unit_tests/test_fuel_map.cpp | 20 +- 13 files changed, 388 insertions(+), 389 deletions(-) diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index 259647e6f4..e62cea2512 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -177,10 +177,10 @@ case Force_4b_adc_channel_mode: } const char *getTrigger_value_e(trigger_value_e value){ switch(value) { -case TV_HIGH: - return "TV_HIGH"; -case TV_LOW: - return "TV_LOW"; +case TV_RISE: + return "TV_RISE"; +case TV_FALL: + return "TV_FALL"; } return NULL; } diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 6df01c75bd..72a29302d9 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -166,9 +166,8 @@ typedef enum { Force_4b_adc_channel_mode = ENUM_32_BITS, } adc_channel_mode_e; -// todo: better names? typedef enum { - TV_LOW = 0, TV_HIGH = 1 + TV_FALL = 0, TV_RISE = 1 } trigger_value_e; // todo: better names? diff --git a/firmware/controllers/trigger/trigger_bmw.cpp b/firmware/controllers/trigger/trigger_bmw.cpp index 5bf94cf665..d57b88369a 100644 --- a/firmware/controllers/trigger/trigger_bmw.cpp +++ b/firmware/controllers/trigger/trigger_bmw.cpp @@ -8,9 +8,9 @@ #include "trigger_bmw.h" static inline float addPair(TriggerShape *s, float a, float w) { - s->addEvent(a, T_SECONDARY, TV_HIGH); + s->addEvent(a, T_SECONDARY, TV_RISE); a += w; - s->addEvent(a, T_SECONDARY, TV_LOW); + s->addEvent(a, T_SECONDARY, TV_FALL); a += w; return a; } @@ -22,7 +22,7 @@ void configureMiniCooperTriggerShape(TriggerShape *s) { float w = 360.0 / 121; float a = w / 2; - s->addEvent(a, T_SECONDARY, TV_LOW); + s->addEvent(a, T_SECONDARY, TV_FALL); a += w; for (int i = 0; i <= 22; i++) { @@ -33,16 +33,16 @@ void configureMiniCooperTriggerShape(TriggerShape *s) { float firstGapAngle = a; - s->addEvent(a, T_SECONDARY, TV_HIGH); + s->addEvent(a, T_SECONDARY, TV_RISE); a += 3 * w; - s->addEvent(a, T_SECONDARY, TV_LOW); + s->addEvent(a, T_SECONDARY, TV_FALL); a += w; for (int i = 0; i < 36; i++) { a = addPair(s, a, w); } - s->addEvent(376, T_PRIMARY, TV_HIGH); + s->addEvent(376, T_PRIMARY, TV_RISE); for (int i = 0; i < 21; i++) { a = addPair(s, a, w); @@ -51,9 +51,9 @@ void configureMiniCooperTriggerShape(TriggerShape *s) { efiAssertVoid(absF(firstGapAngle + 360 - a) < 0.1, "shape constraint"); - s->addEvent(a, T_SECONDARY, TV_HIGH); + s->addEvent(a, T_SECONDARY, TV_RISE); a += 3 * w; - s->addEvent(a, T_SECONDARY, TV_LOW); + s->addEvent(a, T_SECONDARY, TV_FALL); a += w; for (int i = 0; i < 33; i++) { @@ -61,9 +61,9 @@ void configureMiniCooperTriggerShape(TriggerShape *s) { } efiAssertVoid(absF(720 - w / 2 - a) < 0.1, "shape constraint"); - s->addEvent(a, T_SECONDARY, TV_HIGH); + s->addEvent(a, T_SECONDARY, TV_RISE); - s->addEvent(720.0, T_PRIMARY, TV_LOW); + s->addEvent(720.0, T_PRIMARY, TV_FALL); /** * With just one tooth on camshaft synchronization is not needed diff --git a/firmware/controllers/trigger/trigger_chrysler.cpp b/firmware/controllers/trigger/trigger_chrysler.cpp index 09a84e1f62..54d43de189 100644 --- a/firmware/controllers/trigger/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/trigger_chrysler.cpp @@ -17,12 +17,12 @@ void initDodgeRam(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { addSkippedToothTriggerEvents(T_SECONDARY, s, 8, 0, 0.06, -25, 360, 0, 720); - s->addEvent(360, T_PRIMARY, TV_HIGH); + s->addEvent(360, T_PRIMARY, TV_RISE); addSkippedToothTriggerEvents(T_SECONDARY, s, 8, 0, 0.06, 360 - 25, 360, 0, 720); - s->addEvent(720, T_PRIMARY, TV_LOW); + s->addEvent(720, T_PRIMARY, TV_FALL); } void configureNeon2003TriggerShape(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { @@ -43,23 +43,23 @@ void configureNeon2003TriggerShape(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { s->useOnlyPrimaryForSync = true; if (useOnlyPrimary) { - s->addEvent(144, T_PRIMARY, TV_HIGH); - s->addEvent(180, T_PRIMARY, TV_LOW); + s->addEvent(144, T_PRIMARY, TV_RISE); + s->addEvent(180, T_PRIMARY, TV_FALL); - s->addEvent(216, T_PRIMARY, TV_HIGH); - s->addEvent(252, T_PRIMARY, TV_LOW); + s->addEvent(216, T_PRIMARY, TV_RISE); + s->addEvent(252, T_PRIMARY, TV_FALL); - s->addEvent(288, T_PRIMARY, TV_HIGH); - s->addEvent(324, T_PRIMARY, TV_LOW); + s->addEvent(288, T_PRIMARY, TV_RISE); + s->addEvent(324, T_PRIMARY, TV_FALL); - s->addEvent(360, T_PRIMARY, TV_HIGH); // width = 144 - s->addEvent(504, T_PRIMARY, TV_LOW); // width = 36 - s->addEvent(540, T_PRIMARY, TV_HIGH); - s->addEvent(576, T_PRIMARY, TV_LOW); - s->addEvent(612, T_PRIMARY, TV_HIGH); - s->addEvent(648, T_PRIMARY, TV_LOW); - s->addEvent(684, T_PRIMARY, TV_HIGH); - s->addEvent(720, T_PRIMARY, TV_LOW); + s->addEvent(360, T_PRIMARY, TV_RISE); // width = 144 + s->addEvent(504, T_PRIMARY, TV_FALL); // width = 36 + s->addEvent(540, T_PRIMARY, TV_RISE); + s->addEvent(576, T_PRIMARY, TV_FALL); + s->addEvent(612, T_PRIMARY, TV_RISE); + s->addEvent(648, T_PRIMARY, TV_FALL); + s->addEvent(684, T_PRIMARY, TV_RISE); + s->addEvent(720, T_PRIMARY, TV_FALL); } else { /** @@ -68,171 +68,171 @@ void configureNeon2003TriggerShape(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { * */ - s->addEvent(25, T_SECONDARY, TV_LOW); - s->addEvent(30, T_SECONDARY, TV_HIGH); - s->addEvent(35, T_SECONDARY, TV_LOW); - s->addEvent(40, T_SECONDARY, TV_HIGH); - s->addEvent(45, T_SECONDARY, TV_LOW); - s->addEvent(50, T_SECONDARY, TV_HIGH); - s->addEvent(55, T_SECONDARY, TV_LOW); - s->addEvent(60, T_SECONDARY, TV_HIGH); - s->addEvent(65, T_SECONDARY, TV_LOW); - s->addEvent(70, T_SECONDARY, TV_HIGH); - s->addEvent(75, T_SECONDARY, TV_LOW); - s->addEvent(80, T_SECONDARY, TV_HIGH); - s->addEvent(85, T_SECONDARY, TV_LOW); - s->addEvent(90, T_SECONDARY, TV_HIGH); - s->addEvent(95, T_SECONDARY, TV_LOW); - s->addEvent(100, T_SECONDARY, TV_HIGH); - s->addEvent(105, T_SECONDARY, TV_LOW); - s->addEvent(110, T_SECONDARY, TV_HIGH); - s->addEvent(115, T_SECONDARY, TV_LOW); - s->addEvent(120, T_SECONDARY, TV_HIGH); - s->addEvent(125, T_SECONDARY, TV_LOW); - s->addEvent(130, T_SECONDARY, TV_HIGH); - s->addEvent(135, T_SECONDARY, TV_LOW); - s->addEvent(140, T_SECONDARY, TV_HIGH); + s->addEvent(25, T_SECONDARY, TV_FALL); + s->addEvent(30, T_SECONDARY, TV_RISE); + s->addEvent(35, T_SECONDARY, TV_FALL); + s->addEvent(40, T_SECONDARY, TV_RISE); + s->addEvent(45, T_SECONDARY, TV_FALL); + s->addEvent(50, T_SECONDARY, TV_RISE); + s->addEvent(55, T_SECONDARY, TV_FALL); + s->addEvent(60, T_SECONDARY, TV_RISE); + s->addEvent(65, T_SECONDARY, TV_FALL); + s->addEvent(70, T_SECONDARY, TV_RISE); + s->addEvent(75, T_SECONDARY, TV_FALL); + s->addEvent(80, T_SECONDARY, TV_RISE); + s->addEvent(85, T_SECONDARY, TV_FALL); + s->addEvent(90, T_SECONDARY, TV_RISE); + s->addEvent(95, T_SECONDARY, TV_FALL); + s->addEvent(100, T_SECONDARY, TV_RISE); + s->addEvent(105, T_SECONDARY, TV_FALL); + s->addEvent(110, T_SECONDARY, TV_RISE); + s->addEvent(115, T_SECONDARY, TV_FALL); + s->addEvent(120, T_SECONDARY, TV_RISE); + s->addEvent(125, T_SECONDARY, TV_FALL); + s->addEvent(130, T_SECONDARY, TV_RISE); + s->addEvent(135, T_SECONDARY, TV_FALL); + s->addEvent(140, T_SECONDARY, TV_RISE); - s->addEvent(144, T_PRIMARY, TV_HIGH); + s->addEvent(144, T_PRIMARY, TV_RISE); - s->addEvent(145,T_SECONDARY, TV_LOW); - s->addEvent(150, T_SECONDARY, TV_HIGH); - s->addEvent(155, T_SECONDARY, TV_LOW); - s->addEvent(160, T_SECONDARY, TV_HIGH); - s->addEvent(165, T_SECONDARY, TV_LOW); - s->addEvent(170, T_SECONDARY, TV_HIGH); - s->addEvent(175, T_SECONDARY, TV_LOW); - s->addEvent(180 - EPS_ANGLE, T_SECONDARY, TV_HIGH); + s->addEvent(145,T_SECONDARY, TV_FALL); + s->addEvent(150, T_SECONDARY, TV_RISE); + s->addEvent(155, T_SECONDARY, TV_FALL); + s->addEvent(160, T_SECONDARY, TV_RISE); + s->addEvent(165, T_SECONDARY, TV_FALL); + s->addEvent(170, T_SECONDARY, TV_RISE); + s->addEvent(175, T_SECONDARY, TV_FALL); + s->addEvent(180 - EPS_ANGLE, T_SECONDARY, TV_RISE); - s->addEvent(180, T_PRIMARY, TV_LOW); + s->addEvent(180, T_PRIMARY, TV_FALL); - s->addEvent(185, T_SECONDARY, TV_LOW); - s->addEvent(210, T_SECONDARY, TV_HIGH); - s->addEvent(215, T_SECONDARY, TV_LOW); + s->addEvent(185, T_SECONDARY, TV_FALL); + s->addEvent(210, T_SECONDARY, TV_RISE); + s->addEvent(215, T_SECONDARY, TV_FALL); - s->addEvent(216, T_PRIMARY, TV_HIGH); + s->addEvent(216, T_PRIMARY, TV_RISE); - s->addEvent(220, T_SECONDARY, TV_HIGH); - s->addEvent(225, T_SECONDARY, TV_LOW); - s->addEvent(230, T_SECONDARY, TV_HIGH); - s->addEvent(235, T_SECONDARY, TV_LOW); - s->addEvent(240, T_SECONDARY, TV_HIGH); - s->addEvent(245, T_SECONDARY, TV_LOW); - s->addEvent(250, T_SECONDARY, TV_HIGH); + s->addEvent(220, T_SECONDARY, TV_RISE); + s->addEvent(225, T_SECONDARY, TV_FALL); + s->addEvent(230, T_SECONDARY, TV_RISE); + s->addEvent(235, T_SECONDARY, TV_FALL); + s->addEvent(240, T_SECONDARY, TV_RISE); + s->addEvent(245, T_SECONDARY, TV_FALL); + s->addEvent(250, T_SECONDARY, TV_RISE); - s->addEvent(252, T_PRIMARY, TV_LOW); + s->addEvent(252, T_PRIMARY, TV_FALL); - s->addEvent(255, T_SECONDARY, TV_LOW); + s->addEvent(255, T_SECONDARY, TV_FALL); - s->addEvent(260, T_SECONDARY, TV_HIGH); - s->addEvent(265, T_SECONDARY, TV_LOW); - s->addEvent(270, T_SECONDARY, TV_HIGH); - s->addEvent(275, T_SECONDARY, TV_LOW); - s->addEvent(280, T_SECONDARY, TV_HIGH); - s->addEvent(285, T_SECONDARY, TV_LOW); + s->addEvent(260, T_SECONDARY, TV_RISE); + s->addEvent(265, T_SECONDARY, TV_FALL); + s->addEvent(270, T_SECONDARY, TV_RISE); + s->addEvent(275, T_SECONDARY, TV_FALL); + s->addEvent(280, T_SECONDARY, TV_RISE); + s->addEvent(285, T_SECONDARY, TV_FALL); - s->addEvent(288, T_PRIMARY, TV_HIGH); + s->addEvent(288, T_PRIMARY, TV_RISE); - s->addEvent(290, T_SECONDARY, TV_HIGH); - s->addEvent(295, T_SECONDARY, TV_LOW); - s->addEvent(300, T_SECONDARY, TV_HIGH); - s->addEvent(305, T_SECONDARY, TV_LOW); - s->addEvent(310, T_SECONDARY, TV_HIGH); - s->addEvent(315, T_SECONDARY, TV_LOW); - s->addEvent(320, T_SECONDARY, TV_HIGH); + s->addEvent(290, T_SECONDARY, TV_RISE); + s->addEvent(295, T_SECONDARY, TV_FALL); + s->addEvent(300, T_SECONDARY, TV_RISE); + s->addEvent(305, T_SECONDARY, TV_FALL); + s->addEvent(310, T_SECONDARY, TV_RISE); + s->addEvent(315, T_SECONDARY, TV_FALL); + s->addEvent(320, T_SECONDARY, TV_RISE); - s->addEvent(324, T_PRIMARY, TV_LOW); + s->addEvent(324, T_PRIMARY, TV_FALL); - s->addEvent(325, T_SECONDARY, TV_LOW); - s->addEvent(330, T_SECONDARY, TV_HIGH); - s->addEvent(335, T_SECONDARY, TV_LOW); - s->addEvent(340, T_SECONDARY, TV_HIGH); - s->addEvent(345, T_SECONDARY, TV_LOW); - s->addEvent(350, T_SECONDARY, TV_HIGH); - s->addEvent(355, T_SECONDARY, TV_LOW); - s->addEvent(360 - EPS_ANGLE, T_SECONDARY, TV_HIGH); + s->addEvent(325, T_SECONDARY, TV_FALL); + s->addEvent(330, T_SECONDARY, TV_RISE); + s->addEvent(335, T_SECONDARY, TV_FALL); + s->addEvent(340, T_SECONDARY, TV_RISE); + s->addEvent(345, T_SECONDARY, TV_FALL); + s->addEvent(350, T_SECONDARY, TV_RISE); + s->addEvent(355, T_SECONDARY, TV_FALL); + s->addEvent(360 - EPS_ANGLE, T_SECONDARY, TV_RISE); - s->addEvent(360, T_PRIMARY, TV_HIGH); + s->addEvent(360, T_PRIMARY, TV_RISE); - s->addEvent(385, T_SECONDARY, TV_LOW); - s->addEvent(390, T_SECONDARY, TV_HIGH); - s->addEvent(395, T_SECONDARY, TV_LOW); - s->addEvent(400, T_SECONDARY, TV_HIGH); - s->addEvent(405, T_SECONDARY, TV_LOW); - s->addEvent(410, T_SECONDARY, TV_HIGH); - s->addEvent(415, T_SECONDARY, TV_LOW); - s->addEvent(420, T_SECONDARY, TV_HIGH); - s->addEvent(425, T_SECONDARY, TV_LOW); - s->addEvent(430, T_SECONDARY, TV_HIGH); - s->addEvent(435, T_SECONDARY, TV_LOW); - s->addEvent(440, T_SECONDARY, TV_HIGH); - s->addEvent(445, T_SECONDARY, TV_LOW); - s->addEvent(450, T_SECONDARY, TV_HIGH); - s->addEvent(455, T_SECONDARY, TV_LOW); - s->addEvent(460, T_SECONDARY, TV_HIGH); - s->addEvent(465, T_SECONDARY, TV_LOW); - s->addEvent(470, T_SECONDARY, TV_HIGH); - s->addEvent(475, T_SECONDARY, TV_LOW); - s->addEvent(480, T_SECONDARY, TV_HIGH); - s->addEvent(485, T_SECONDARY, TV_LOW); - s->addEvent(490, T_SECONDARY, TV_HIGH); - s->addEvent(495, T_SECONDARY, TV_LOW); - s->addEvent(500, T_SECONDARY, TV_HIGH); + s->addEvent(385, T_SECONDARY, TV_FALL); + s->addEvent(390, T_SECONDARY, TV_RISE); + s->addEvent(395, T_SECONDARY, TV_FALL); + s->addEvent(400, T_SECONDARY, TV_RISE); + s->addEvent(405, T_SECONDARY, TV_FALL); + s->addEvent(410, T_SECONDARY, TV_RISE); + s->addEvent(415, T_SECONDARY, TV_FALL); + s->addEvent(420, T_SECONDARY, TV_RISE); + s->addEvent(425, T_SECONDARY, TV_FALL); + s->addEvent(430, T_SECONDARY, TV_RISE); + s->addEvent(435, T_SECONDARY, TV_FALL); + s->addEvent(440, T_SECONDARY, TV_RISE); + s->addEvent(445, T_SECONDARY, TV_FALL); + s->addEvent(450, T_SECONDARY, TV_RISE); + s->addEvent(455, T_SECONDARY, TV_FALL); + s->addEvent(460, T_SECONDARY, TV_RISE); + s->addEvent(465, T_SECONDARY, TV_FALL); + s->addEvent(470, T_SECONDARY, TV_RISE); + s->addEvent(475, T_SECONDARY, TV_FALL); + s->addEvent(480, T_SECONDARY, TV_RISE); + s->addEvent(485, T_SECONDARY, TV_FALL); + s->addEvent(490, T_SECONDARY, TV_RISE); + s->addEvent(495, T_SECONDARY, TV_FALL); + s->addEvent(500, T_SECONDARY, TV_RISE); - s->addEvent(504, T_PRIMARY, TV_LOW); + s->addEvent(504, T_PRIMARY, TV_FALL); - s->addEvent(505, T_SECONDARY, TV_LOW); - s->addEvent(510, T_SECONDARY, TV_HIGH); - s->addEvent(515, T_SECONDARY, TV_LOW); - s->addEvent(520, T_SECONDARY, TV_HIGH); - s->addEvent(525, T_SECONDARY, TV_LOW); - s->addEvent(530, T_SECONDARY, TV_HIGH); - s->addEvent(535, T_SECONDARY, TV_LOW); - s->addEvent(540 - EPS_ANGLE, T_SECONDARY, TV_HIGH); + s->addEvent(505, T_SECONDARY, TV_FALL); + s->addEvent(510, T_SECONDARY, TV_RISE); + s->addEvent(515, T_SECONDARY, TV_FALL); + s->addEvent(520, T_SECONDARY, TV_RISE); + s->addEvent(525, T_SECONDARY, TV_FALL); + s->addEvent(530, T_SECONDARY, TV_RISE); + s->addEvent(535, T_SECONDARY, TV_FALL); + s->addEvent(540 - EPS_ANGLE, T_SECONDARY, TV_RISE); - s->addEvent(540, T_PRIMARY, TV_HIGH); + s->addEvent(540, T_PRIMARY, TV_RISE); - s->addEvent(545, T_SECONDARY, TV_LOW); - s->addEvent(570, T_SECONDARY, TV_HIGH); - s->addEvent(575, T_SECONDARY, TV_LOW); + s->addEvent(545, T_SECONDARY, TV_FALL); + s->addEvent(570, T_SECONDARY, TV_RISE); + s->addEvent(575, T_SECONDARY, TV_FALL); - s->addEvent(576, T_PRIMARY, TV_LOW); - s->addEvent(580, T_SECONDARY, TV_HIGH); - s->addEvent(585, T_SECONDARY, TV_LOW); - s->addEvent(590, T_SECONDARY, TV_HIGH); - s->addEvent(595, T_SECONDARY, TV_LOW); - s->addEvent(600, T_SECONDARY, TV_HIGH); - s->addEvent(605, T_SECONDARY, TV_LOW); - s->addEvent(610, T_SECONDARY, TV_HIGH); + s->addEvent(576, T_PRIMARY, TV_FALL); + s->addEvent(580, T_SECONDARY, TV_RISE); + s->addEvent(585, T_SECONDARY, TV_FALL); + s->addEvent(590, T_SECONDARY, TV_RISE); + s->addEvent(595, T_SECONDARY, TV_FALL); + s->addEvent(600, T_SECONDARY, TV_RISE); + s->addEvent(605, T_SECONDARY, TV_FALL); + s->addEvent(610, T_SECONDARY, TV_RISE); - s->addEvent(612, T_PRIMARY, TV_HIGH); - s->addEvent(615, T_SECONDARY, TV_LOW); - s->addEvent(620, T_SECONDARY, TV_HIGH); - s->addEvent(625, T_SECONDARY, TV_LOW); - s->addEvent(630, T_SECONDARY, TV_HIGH); - s->addEvent(635, T_SECONDARY, TV_LOW); - s->addEvent(640, T_SECONDARY, TV_HIGH); - s->addEvent(645, T_SECONDARY, TV_LOW); + s->addEvent(612, T_PRIMARY, TV_RISE); + s->addEvent(615, T_SECONDARY, TV_FALL); + s->addEvent(620, T_SECONDARY, TV_RISE); + s->addEvent(625, T_SECONDARY, TV_FALL); + s->addEvent(630, T_SECONDARY, TV_RISE); + s->addEvent(635, T_SECONDARY, TV_FALL); + s->addEvent(640, T_SECONDARY, TV_RISE); + s->addEvent(645, T_SECONDARY, TV_FALL); - s->addEvent(648, T_PRIMARY, TV_LOW); - s->addEvent(650, T_SECONDARY, TV_HIGH); - s->addEvent(655, T_SECONDARY, TV_LOW); - s->addEvent(660, T_SECONDARY, TV_HIGH); - s->addEvent(665, T_SECONDARY, TV_LOW); - s->addEvent(670, T_SECONDARY, TV_HIGH); - s->addEvent(675, T_SECONDARY, TV_LOW); - s->addEvent(680, T_SECONDARY, TV_HIGH); + s->addEvent(648, T_PRIMARY, TV_FALL); + s->addEvent(650, T_SECONDARY, TV_RISE); + s->addEvent(655, T_SECONDARY, TV_FALL); + s->addEvent(660, T_SECONDARY, TV_RISE); + s->addEvent(665, T_SECONDARY, TV_FALL); + s->addEvent(670, T_SECONDARY, TV_RISE); + s->addEvent(675, T_SECONDARY, TV_FALL); + s->addEvent(680, T_SECONDARY, TV_RISE); - s->addEvent(684, T_PRIMARY, TV_HIGH); - s->addEvent(685, T_SECONDARY, TV_LOW); - s->addEvent(690, T_SECONDARY, TV_HIGH); - s->addEvent(695, T_SECONDARY, TV_LOW); - s->addEvent(700, T_SECONDARY, TV_HIGH); - s->addEvent(705, T_SECONDARY, TV_LOW); - s->addEvent(710, T_SECONDARY, TV_HIGH); - s->addEvent(715, T_SECONDARY, TV_LOW); - s->addEvent(720 - EPS_ANGLE, T_SECONDARY, TV_HIGH); - s->addEvent(720, T_PRIMARY, TV_LOW); + s->addEvent(684, T_PRIMARY, TV_RISE); + s->addEvent(685, T_SECONDARY, TV_FALL); + s->addEvent(690, T_SECONDARY, TV_RISE); + s->addEvent(695, T_SECONDARY, TV_FALL); + s->addEvent(700, T_SECONDARY, TV_RISE); + s->addEvent(705, T_SECONDARY, TV_FALL); + s->addEvent(710, T_SECONDARY, TV_RISE); + s->addEvent(715, T_SECONDARY, TV_FALL); + s->addEvent(720 - EPS_ANGLE, T_SECONDARY, TV_RISE); + s->addEvent(720, T_PRIMARY, TV_FALL); } } @@ -250,56 +250,56 @@ void configureDodgeStratusTriggerShape(TriggerShape *s DECLARE_ENGINE_PARAMETER_ float base = 0; // 2 teeth float angle = base + 120.0 - w; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); angle += g; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); base += 120; // 3 teeth angle = base + 120.0 - w; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); angle += g; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); angle += g; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); base += 120; // 2 teeth angle = base + 120.0 - w; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); angle += g; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); base += 120; // just one angle = base + 120.0 - w; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); base += 120; // 3 teeth angle = base + 120.0 - w; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); angle += g; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); angle += g; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); base += 120; // just one again angle = base + 120.0 - w; - s->addEvent(angle, T_PRIMARY, TV_HIGH); - s->addEvent(angle + w, T_PRIMARY, TV_LOW); + s->addEvent(angle, T_PRIMARY, TV_RISE); + s->addEvent(angle + w, T_PRIMARY, TV_FALL); } void configureNeon1995TriggerShape(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { @@ -314,49 +314,49 @@ void configureNeon1995TriggerShape(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { s->initialState[T_PRIMARY] = 1; - s->addEvent(base - 720 + 600, T_SECONDARY, TV_HIGH); - s->addEvent(base - 720 + 604, T_SECONDARY, TV_LOW); - s->addEvent(base - 720 + 616, T_SECONDARY, TV_HIGH); - s->addEvent(base - 720 + 620, T_SECONDARY, TV_LOW); - s->addEvent(base - 720 + 643, T_SECONDARY, TV_HIGH); - s->addEvent(base - 720 + 648, T_SECONDARY, TV_LOW); - s->addEvent(base - 720 + 671, T_SECONDARY, TV_HIGH); - s->addEvent(base - 720 + 676, T_SECONDARY, TV_LOW); + s->addEvent(base - 720 + 600, T_SECONDARY, TV_RISE); + s->addEvent(base - 720 + 604, T_SECONDARY, TV_FALL); + s->addEvent(base - 720 + 616, T_SECONDARY, TV_RISE); + s->addEvent(base - 720 + 620, T_SECONDARY, TV_FALL); + s->addEvent(base - 720 + 643, T_SECONDARY, TV_RISE); + s->addEvent(base - 720 + 648, T_SECONDARY, TV_FALL); + s->addEvent(base - 720 + 671, T_SECONDARY, TV_RISE); + s->addEvent(base - 720 + 676, T_SECONDARY, TV_FALL); - s->addEvent(base + 0, T_PRIMARY, TV_LOW); + s->addEvent(base + 0, T_PRIMARY, TV_FALL); - s->addEvent(base + 20, T_SECONDARY, TV_HIGH); - s->addEvent(base + 60, T_SECONDARY, TV_LOW); - s->addEvent(base + 75, T_SECONDARY, TV_HIGH); - s->addEvent(base + 79, T_SECONDARY, TV_LOW); - s->addEvent(base + 101, T_SECONDARY, TV_HIGH); - s->addEvent(base + 106, T_SECONDARY, TV_LOW); - s->addEvent(base + 130, T_SECONDARY, TV_HIGH); - s->addEvent(base + 135, T_SECONDARY, TV_LOW); + s->addEvent(base + 20, T_SECONDARY, TV_RISE); + s->addEvent(base + 60, T_SECONDARY, TV_FALL); + s->addEvent(base + 75, T_SECONDARY, TV_RISE); + s->addEvent(base + 79, T_SECONDARY, TV_FALL); + s->addEvent(base + 101, T_SECONDARY, TV_RISE); + s->addEvent(base + 106, T_SECONDARY, TV_FALL); + s->addEvent(base + 130, T_SECONDARY, TV_RISE); + s->addEvent(base + 135, T_SECONDARY, TV_FALL); - s->addEvent(base + 200, T_PRIMARY, TV_HIGH); // width = 150 + s->addEvent(base + 200, T_PRIMARY, TV_RISE); // width = 150 - s->addEvent(base + 236, T_SECONDARY, TV_HIGH); - s->addEvent(base + 239, T_SECONDARY, TV_LOW); - s->addEvent(base + 250, T_SECONDARY, TV_HIGH); - s->addEvent(base + 255, T_SECONDARY, TV_LOW); - s->addEvent(base + 277, T_SECONDARY, TV_HIGH); - s->addEvent(base + 282, T_SECONDARY, TV_LOW); - s->addEvent(base + 305, T_SECONDARY, TV_HIGH); - s->addEvent(base + 310, T_SECONDARY, TV_LOW); + s->addEvent(base + 236, T_SECONDARY, TV_RISE); + s->addEvent(base + 239, T_SECONDARY, TV_FALL); + s->addEvent(base + 250, T_SECONDARY, TV_RISE); + s->addEvent(base + 255, T_SECONDARY, TV_FALL); + s->addEvent(base + 277, T_SECONDARY, TV_RISE); + s->addEvent(base + 282, T_SECONDARY, TV_FALL); + s->addEvent(base + 305, T_SECONDARY, TV_RISE); + s->addEvent(base + 310, T_SECONDARY, TV_FALL); - s->addEvent(base + 374, T_SECONDARY, TV_HIGH); + s->addEvent(base + 374, T_SECONDARY, TV_RISE); - s->addEvent(base + 395, T_PRIMARY, TV_LOW); // width = + s->addEvent(base + 395, T_PRIMARY, TV_FALL); // width = - s->addEvent(base + 418, T_SECONDARY, TV_LOW); - s->addEvent(base + 436, T_SECONDARY, TV_HIGH); - s->addEvent(base + 441, T_SECONDARY, TV_LOW); - s->addEvent(base + 463, T_SECONDARY, TV_HIGH); - s->addEvent(base + 468, T_SECONDARY, TV_LOW); - s->addEvent(base + 492, T_SECONDARY, TV_HIGH); - s->addEvent(base + 497, T_SECONDARY, TV_LOW); + s->addEvent(base + 418, T_SECONDARY, TV_FALL); + s->addEvent(base + 436, T_SECONDARY, TV_RISE); + s->addEvent(base + 441, T_SECONDARY, TV_FALL); + s->addEvent(base + 463, T_SECONDARY, TV_RISE); + s->addEvent(base + 468, T_SECONDARY, TV_FALL); + s->addEvent(base + 492, T_SECONDARY, TV_RISE); + s->addEvent(base + 497, T_SECONDARY, TV_FALL); - s->addEvent(base + 560, T_PRIMARY, TV_HIGH); // width = + s->addEvent(base + 560, T_PRIMARY, TV_RISE); // width = } diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index d5150a9d27..5f7d2dcfa3 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -80,7 +80,7 @@ float TriggerState::getTriggerDutyCycle(int index) { } static trigger_wheel_e eventIndex[6] = { T_PRIMARY, T_PRIMARY, T_SECONDARY, T_SECONDARY, T_CHANNEL_3, T_CHANNEL_3 }; -//static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW, TV_HIGH }; +//static trigger_value_e eventType[6] = { TV_FALL, TV_RISE, TV_FALL, TV_RISE, TV_FALL, TV_RISE }; #define getCurrentGapDuration(nowNt) \ (isFirstEvent ? 0 : (nowNt) - toothed_previous_time) @@ -335,13 +335,13 @@ void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int to for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) { float angleDown = engineCycle / totalTeethCount * (i + (1 - toothWidth)); float angleUp = engineCycle / totalTeethCount * (i + 1); - s->addEvent(offset + angleDown, wheel, TV_HIGH, filterLeft, filterRight); - s->addEvent(offset + angleUp, wheel, TV_LOW, filterLeft, filterRight); + s->addEvent(offset + angleDown, wheel, TV_RISE, filterLeft, filterRight); + s->addEvent(offset + angleUp, wheel, TV_FALL, filterLeft, filterRight); } float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + (1 - toothWidth)); - s->addEvent(offset + angleDown, wheel, TV_HIGH, filterLeft, filterRight); - s->addEvent(offset + engineCycle, wheel, TV_LOW, filterLeft, filterRight); + s->addEvent(offset + angleDown, wheel, TV_RISE, filterLeft, filterRight); + s->addEvent(offset + engineCycle, wheel, TV_FALL, filterLeft, filterRight); } void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount, @@ -362,11 +362,11 @@ static void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode) s->initialize(FOUR_STROKE_CAM_SENSOR, true); - s->addEvent(180, T_PRIMARY, TV_HIGH); - s->addEvent(360, T_PRIMARY, TV_LOW); + s->addEvent(180, T_PRIMARY, TV_RISE); + s->addEvent(360, T_PRIMARY, TV_FALL); - s->addEvent(540, T_SECONDARY, TV_HIGH); - s->addEvent(720, T_SECONDARY, TV_LOW); + s->addEvent(540, T_SECONDARY, TV_RISE); + s->addEvent(720, T_SECONDARY, TV_FALL); s->isSynchronizationNeeded = false; } @@ -377,9 +377,9 @@ static void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode int totalTeethCount = 60; int skippedCount = 2; - s->addEvent(2, T_PRIMARY, TV_HIGH); + s->addEvent(2, T_PRIMARY, TV_RISE); addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0.5, 0, 360, 2, 20); - s->addEvent(20, T_PRIMARY, TV_LOW); + s->addEvent(20, T_PRIMARY, TV_FALL); addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0.5, 0, 360, 20, NO_RIGHT_FILTER); addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0.5, 360, 360, NO_LEFT_FILTER, diff --git a/firmware/controllers/trigger/trigger_gm.cpp b/firmware/controllers/trigger/trigger_gm.cpp index 085723adeb..e3f68cab35 100644 --- a/firmware/controllers/trigger/trigger_gm.cpp +++ b/firmware/controllers/trigger/trigger_gm.cpp @@ -13,25 +13,25 @@ void configureGmTriggerShape(TriggerShape *s) { // all angles are x2 here - so, 5 degree width is 10 float w = 10; - s->addEvent(120 - w, T_PRIMARY, TV_HIGH); - s->addEvent(120.0, T_PRIMARY, TV_LOW); + s->addEvent(120 - w, T_PRIMARY, TV_RISE); + s->addEvent(120.0, T_PRIMARY, TV_FALL); - s->addEvent(240 - w, T_PRIMARY, TV_HIGH); - s->addEvent(240.0, T_PRIMARY, TV_LOW); + s->addEvent(240 - w, T_PRIMARY, TV_RISE); + s->addEvent(240.0, T_PRIMARY, TV_FALL); - s->addEvent(360 - w, T_PRIMARY, TV_HIGH); - s->addEvent(360.0, T_PRIMARY, TV_LOW); + s->addEvent(360 - w, T_PRIMARY, TV_RISE); + s->addEvent(360.0, T_PRIMARY, TV_FALL); - s->addEvent(480 - w, T_PRIMARY, TV_HIGH); - s->addEvent(480.0, T_PRIMARY, TV_LOW); + s->addEvent(480 - w, T_PRIMARY, TV_RISE); + s->addEvent(480.0, T_PRIMARY, TV_FALL); - s->addEvent(600 - w, T_PRIMARY, TV_HIGH); - s->addEvent(600.0, T_PRIMARY, TV_LOW); + s->addEvent(600 - w, T_PRIMARY, TV_RISE); + s->addEvent(600.0, T_PRIMARY, TV_FALL); - s->addEvent(700 - w, T_PRIMARY, TV_HIGH); - s->addEvent(700.0, T_PRIMARY, TV_LOW); + s->addEvent(700 - w, T_PRIMARY, TV_RISE); + s->addEvent(700.0, T_PRIMARY, TV_FALL); - s->addEvent(720 - w, T_PRIMARY, TV_HIGH); - s->addEvent(720.0, T_PRIMARY, TV_LOW); + s->addEvent(720 - w, T_PRIMARY, TV_RISE); + s->addEvent(720.0, T_PRIMARY, TV_FALL); } diff --git a/firmware/controllers/trigger/trigger_mazda.cpp b/firmware/controllers/trigger/trigger_mazda.cpp index f68ffc2e0b..03bba39f3d 100644 --- a/firmware/controllers/trigger/trigger_mazda.cpp +++ b/firmware/controllers/trigger/trigger_mazda.cpp @@ -30,21 +30,21 @@ void initializeMazdaMiataNaShape(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { /** * http://rusefi.com/forum/viewtopic.php?f=3&t=729&p=12983#p12983 */ - s->addEvent(52.960405, T_SECONDARY, TV_HIGH); - s->addEvent(122.635956, T_SECONDARY, TV_LOW); + s->addEvent(52.960405, T_SECONDARY, TV_RISE); + s->addEvent(122.635956, T_SECONDARY, TV_FALL); - s->addEvent(216.897031, T_PRIMARY, TV_HIGH); - s->addEvent(232.640068, T_SECONDARY, TV_HIGH); - s->addEvent(288.819688, T_PRIMARY, TV_LOW); - s->addEvent(302.646323, T_SECONDARY, TV_LOW); + s->addEvent(216.897031, T_PRIMARY, TV_RISE); + s->addEvent(232.640068, T_SECONDARY, TV_RISE); + s->addEvent(288.819688, T_PRIMARY, TV_FALL); + s->addEvent(302.646323, T_SECONDARY, TV_FALL); - s->addEvent(412.448056, T_SECONDARY, TV_HIGH); - s->addEvent(482.816719, T_SECONDARY, TV_LOW); + s->addEvent(412.448056, T_SECONDARY, TV_RISE); + s->addEvent(482.816719, T_SECONDARY, TV_FALL); - s->addEvent(577.035495, T_PRIMARY, TV_HIGH); - s->addEvent(592.878113, T_SECONDARY, TV_HIGH); - s->addEvent(662.899708, T_SECONDARY, TV_LOW); - s->addEvent(720.0f, T_PRIMARY, TV_LOW); + s->addEvent(577.035495, T_PRIMARY, TV_RISE); + s->addEvent(592.878113, T_SECONDARY, TV_RISE); + s->addEvent(662.899708, T_SECONDARY, TV_FALL); + s->addEvent(720.0f, T_PRIMARY, TV_FALL); } void initializeMazdaMiataNbShape(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { @@ -57,33 +57,33 @@ void initializeMazdaMiataNbShape(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { /** * cam sensor is primary, crank sensor is secondary */ - s->addEvent(20.0f, T_PRIMARY, TV_HIGH); + s->addEvent(20.0f, T_PRIMARY, TV_RISE); - s->addEvent(66.0f, T_SECONDARY, TV_LOW); - s->addEvent(70.0f, T_SECONDARY, TV_HIGH); - s->addEvent(136.0f, T_SECONDARY, TV_LOW); - s->addEvent(140.0f, T_SECONDARY, TV_HIGH); - s->addEvent(246.0f, T_SECONDARY, TV_LOW); - s->addEvent(250.0f, T_SECONDARY, TV_HIGH); - s->addEvent(316.0f, T_SECONDARY, TV_LOW); - s->addEvent(320.0f, T_SECONDARY, TV_HIGH); + s->addEvent(66.0f, T_SECONDARY, TV_FALL); + s->addEvent(70.0f, T_SECONDARY, TV_RISE); + s->addEvent(136.0f, T_SECONDARY, TV_FALL); + s->addEvent(140.0f, T_SECONDARY, TV_RISE); + s->addEvent(246.0f, T_SECONDARY, TV_FALL); + s->addEvent(250.0f, T_SECONDARY, TV_RISE); + s->addEvent(316.0f, T_SECONDARY, TV_FALL); + s->addEvent(320.0f, T_SECONDARY, TV_RISE); - s->addEvent(340.0f, T_PRIMARY, TV_LOW); - s->addEvent(360.0f, T_PRIMARY, TV_HIGH); + s->addEvent(340.0f, T_PRIMARY, TV_FALL); + s->addEvent(360.0f, T_PRIMARY, TV_RISE); - s->addEvent(380.0f, T_PRIMARY, TV_LOW); - s->addEvent(400.0f, T_PRIMARY, TV_HIGH); + s->addEvent(380.0f, T_PRIMARY, TV_FALL); + s->addEvent(400.0f, T_PRIMARY, TV_RISE); - s->addEvent(426.0f, T_SECONDARY, TV_LOW); - s->addEvent(430.0f, T_SECONDARY, TV_HIGH); - s->addEvent(496.0f, T_SECONDARY, TV_LOW); - s->addEvent(500.0f, T_SECONDARY, TV_HIGH); - s->addEvent(606.0f, T_SECONDARY, TV_LOW); - s->addEvent(610.0f, T_SECONDARY, TV_HIGH); - s->addEvent(676.0f, T_SECONDARY, TV_LOW); - s->addEvent(680.0f, T_SECONDARY, TV_HIGH); + s->addEvent(426.0f, T_SECONDARY, TV_FALL); + s->addEvent(430.0f, T_SECONDARY, TV_RISE); + s->addEvent(496.0f, T_SECONDARY, TV_FALL); + s->addEvent(500.0f, T_SECONDARY, TV_RISE); + s->addEvent(606.0f, T_SECONDARY, TV_FALL); + s->addEvent(610.0f, T_SECONDARY, TV_RISE); + s->addEvent(676.0f, T_SECONDARY, TV_FALL); + s->addEvent(680.0f, T_SECONDARY, TV_RISE); - s->addEvent(720.0f, T_PRIMARY, TV_LOW); + s->addEvent(720.0f, T_PRIMARY, TV_FALL); } void configureMazdaProtegeSOHC(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { @@ -98,18 +98,18 @@ void configureMazdaProtegeSOHC(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { float z = 0.093; a = 180; - s->addEvent(a - z * 720, T_PRIMARY, TV_HIGH); - s->addEvent(a, T_PRIMARY, TV_LOW); + s->addEvent(a - z * 720, T_PRIMARY, TV_RISE); + s->addEvent(a, T_PRIMARY, TV_FALL); a += 180; - s->addEvent(a - z * 720, T_PRIMARY, TV_HIGH); - s->addEvent(a, T_PRIMARY, TV_LOW); + s->addEvent(a - z * 720, T_PRIMARY, TV_RISE); + s->addEvent(a, T_PRIMARY, TV_FALL); a += 180; - s->addEvent(a - z * 720, T_PRIMARY, TV_HIGH); - s->addEvent(a, T_PRIMARY, TV_LOW); + s->addEvent(a - z * 720, T_PRIMARY, TV_RISE); + s->addEvent(a, T_PRIMARY, TV_FALL); a += 180; - s->addEvent(a - z * 720, T_PRIMARY, TV_HIGH); - s->addEvent(a, T_PRIMARY, TV_LOW); + s->addEvent(a - z * 720, T_PRIMARY, TV_RISE); + s->addEvent(a, T_PRIMARY, TV_FALL); s->isSynchronizationNeeded = false; } @@ -121,21 +121,21 @@ void configureMazdaProtegeLx(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { /** * 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 */ - s->addEvent2(95.329254, T_PRIMARY, TV_HIGH PASS_ENGINE_PARAMETER); + s->addEvent2(95.329254, T_PRIMARY, TV_RISE PASS_ENGINE_PARAMETER); - s->addEvent2(95.329254 + 14.876692, T_SECONDARY, TV_HIGH PASS_ENGINE_PARAMETER); - s->addEvent2(95.329254 + 82.693557, T_SECONDARY, TV_LOW PASS_ENGINE_PARAMETER); + s->addEvent2(95.329254 + 14.876692, T_SECONDARY, TV_RISE PASS_ENGINE_PARAMETER); + s->addEvent2(95.329254 + 82.693557, T_SECONDARY, TV_FALL PASS_ENGINE_PARAMETER); - s->addEvent2(95.329254 + 137.119154, T_PRIMARY, TV_LOW PASS_ENGINE_PARAMETER); + s->addEvent2(95.329254 + 137.119154, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER); - s->addEvent2(95.329254 + 192.378308, T_SECONDARY, TV_HIGH PASS_ENGINE_PARAMETER); - s->addEvent2(95.329254 + 261.556418, T_SECONDARY, TV_LOW PASS_ENGINE_PARAMETER); + s->addEvent2(95.329254 + 192.378308, T_SECONDARY, TV_RISE PASS_ENGINE_PARAMETER); + s->addEvent2(95.329254 + 261.556418, T_SECONDARY, TV_FALL PASS_ENGINE_PARAMETER); - s->addEvent2(95.329254 + 373.060597, T_SECONDARY, TV_HIGH PASS_ENGINE_PARAMETER); - s->addEvent2(95.329254 + 443.503184, T_SECONDARY, TV_LOW PASS_ENGINE_PARAMETER); + s->addEvent2(95.329254 + 373.060597, T_SECONDARY, TV_RISE PASS_ENGINE_PARAMETER); + s->addEvent2(95.329254 + 443.503184, T_SECONDARY, TV_FALL PASS_ENGINE_PARAMETER); - s->addEvent2(95.329254 + 555.349776, T_SECONDARY, TV_HIGH PASS_ENGINE_PARAMETER); - s->addEvent2(720, T_SECONDARY, TV_LOW PASS_ENGINE_PARAMETER); + s->addEvent2(95.329254 + 555.349776, T_SECONDARY, TV_RISE PASS_ENGINE_PARAMETER); + s->addEvent2(720, T_SECONDARY, TV_FALL PASS_ENGINE_PARAMETER); s->tdcPosition = 137.119154; s->isSynchronizationNeeded = false; diff --git a/firmware/controllers/trigger/trigger_mitsubishi.cpp b/firmware/controllers/trigger/trigger_mitsubishi.cpp index c1cc46a731..473e66d71c 100644 --- a/firmware/controllers/trigger/trigger_mitsubishi.cpp +++ b/firmware/controllers/trigger/trigger_mitsubishi.cpp @@ -14,17 +14,17 @@ void configureFordAspireTriggerShape(TriggerShape * s) { float x = 121.90; float y = 110.86; - s->addEvent(x + y - 180, T_SECONDARY, TV_HIGH); - s->addEvent(x, T_SECONDARY, TV_LOW); - s->addEvent(x + y, T_SECONDARY, TV_HIGH); - s->addEvent(x + 180, T_SECONDARY, TV_LOW); - s->addEvent(360, T_PRIMARY, TV_HIGH); + s->addEvent(x + y - 180, T_SECONDARY, TV_RISE); + s->addEvent(x, T_SECONDARY, TV_FALL); + s->addEvent(x + y, T_SECONDARY, TV_RISE); + s->addEvent(x + 180, T_SECONDARY, TV_FALL); + s->addEvent(360, T_PRIMARY, TV_RISE); - s->addEvent(x + 180 + y, T_SECONDARY, TV_HIGH); - s->addEvent(x + 360, T_SECONDARY, TV_LOW); - s->addEvent(x + 360 + y, T_SECONDARY, TV_HIGH); - s->addEvent(x + 540, T_SECONDARY, TV_LOW); - s->addEvent(720, T_PRIMARY, TV_LOW); + s->addEvent(x + 180 + y, T_SECONDARY, TV_RISE); + s->addEvent(x + 360, T_SECONDARY, TV_FALL); + s->addEvent(x + 360 + y, T_SECONDARY, TV_RISE); + s->addEvent(x + 540, T_SECONDARY, TV_FALL); + s->addEvent(720, T_PRIMARY, TV_FALL); } void initializeMitsubishi4g18(TriggerShape *s) { @@ -35,19 +35,19 @@ void initializeMitsubishi4g18(TriggerShape *s) { int secondaryWidth = 70; - s->addEvent(180.0 - 131 + 5, T_PRIMARY, TV_HIGH); - s->addEvent(180.0 - secondaryWidth, T_SECONDARY, TV_HIGH); - s->addEvent(180.0, T_SECONDARY, TV_LOW); - s->addEvent(180.0 + 49 + 5, T_PRIMARY, TV_LOW); + s->addEvent(180.0 - 131 + 5, T_PRIMARY, TV_RISE); + s->addEvent(180.0 - secondaryWidth, T_SECONDARY, TV_RISE); + s->addEvent(180.0, T_SECONDARY, TV_FALL); + s->addEvent(180.0 + 49 + 5, T_PRIMARY, TV_FALL); - s->addEvent(360.0 - secondaryWidth, T_SECONDARY, TV_HIGH); - s->addEvent(360.0, T_SECONDARY, TV_LOW); + s->addEvent(360.0 - secondaryWidth, T_SECONDARY, TV_RISE); + s->addEvent(360.0, T_SECONDARY, TV_FALL); - s->addEvent(540.0 - 131 + 5, T_PRIMARY, TV_HIGH); - s->addEvent(540.0 - secondaryWidth, T_SECONDARY, TV_HIGH); - s->addEvent(540.0 - 131 + 5 + 90, T_PRIMARY, TV_LOW); - s->addEvent(540.0, T_SECONDARY, TV_LOW); + s->addEvent(540.0 - 131 + 5, T_PRIMARY, TV_RISE); + s->addEvent(540.0 - secondaryWidth, T_SECONDARY, TV_RISE); + s->addEvent(540.0 - 131 + 5 + 90, T_PRIMARY, TV_FALL); + s->addEvent(540.0, T_SECONDARY, TV_FALL); - s->addEvent(720.0 - secondaryWidth, T_SECONDARY, TV_HIGH); - s->addEvent(720.0, T_SECONDARY, TV_LOW); + s->addEvent(720.0 - secondaryWidth, T_SECONDARY, TV_RISE); + s->addEvent(720.0, T_SECONDARY, TV_FALL); } diff --git a/firmware/controllers/trigger/trigger_nissan.cpp b/firmware/controllers/trigger/trigger_nissan.cpp index 6c8d0d240a..43933de005 100644 --- a/firmware/controllers/trigger/trigger_nissan.cpp +++ b/firmware/controllers/trigger/trigger_nissan.cpp @@ -21,7 +21,7 @@ void initializeNissan(TriggerShape *s) { // todo base += 180; - s->addEvent(base - w, T_PRIMARY, TV_HIGH); - s->addEvent(base, T_PRIMARY, TV_LOW); + s->addEvent(base - w, T_PRIMARY, TV_RISE); + s->addEvent(base, T_PRIMARY, TV_FALL); } diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 552dd4aecf..d17505d7e9 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -265,7 +265,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const waveIndex, trig trigger_value_e state; if (invertOnAdd) { - state = (stateParam == TV_LOW) ? TV_HIGH : TV_LOW; + state = (stateParam == TV_FALL) ? TV_RISE : TV_FALL; } else { state = stateParam; } @@ -285,7 +285,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_HIGH) { + if (!engineConfiguration->useOnlyFrontForTrigger || stateParam == TV_RISE) { expectedEventCount[waveIndex]++; } #endif @@ -310,7 +310,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const waveIndex, trig wave->pinStates[0] = initialState[i]; } - isFrontEvent[0] = TV_HIGH == stateParam; + isFrontEvent[0] = TV_RISE == stateParam; wave.setSwitchTime(0, angle); wave.waves[waveIndex].pinStates[0] = state; return; @@ -333,7 +333,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const waveIndex, trig wave.setSwitchTime(i + 1, wave.getSwitchTime(i)); } - isFrontEvent[index] = TV_HIGH == stateParam; + isFrontEvent[index] = TV_RISE == stateParam; if (index != size) { firmwareError("are we ever here?"); @@ -384,8 +384,8 @@ void setVwConfiguration(TriggerShape *s) { NO_LEFT_FILTER, 690); float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + (1 - toothWidth) ); - s->addEvent(0 + angleDown + 12, T_PRIMARY, TV_HIGH, NO_LEFT_FILTER, NO_RIGHT_FILTER); - s->addEvent(0 + engineCycle, T_PRIMARY, TV_LOW, NO_LEFT_FILTER, NO_RIGHT_FILTER); + s->addEvent(0 + angleDown + 12, T_PRIMARY, TV_RISE, NO_LEFT_FILTER, NO_RIGHT_FILTER); + s->addEvent(0 + engineCycle, T_PRIMARY, TV_FALL, NO_LEFT_FILTER, NO_RIGHT_FILTER); s->setTriggerSynchronizationGap2(1.6, 4); } @@ -424,9 +424,9 @@ void TriggerShape::setSecondTriggerSynchronizationGap(float synchRatio) { #define S24 (720.0f / 24 / 2) static float addAccordPair(TriggerShape *s, float sb, trigger_wheel_e const waveIndex) { - s->addEvent(sb, waveIndex, TV_HIGH); + s->addEvent(sb, waveIndex, TV_RISE); sb += S24; - s->addEvent(sb, waveIndex, TV_LOW); + s->addEvent(sb, waveIndex, TV_FALL); sb += S24; return sb; @@ -435,9 +435,9 @@ static float addAccordPair(TriggerShape *s, float sb, trigger_wheel_e const wave #define DIP 7.5f static float addAccordPair3(TriggerShape *s, float sb) { sb += DIP; - s->addEvent(sb, T_CHANNEL_3, TV_HIGH); + s->addEvent(sb, T_CHANNEL_3, TV_RISE); sb += DIP; - s->addEvent(sb, T_CHANNEL_3, TV_LOW); + s->addEvent(sb, T_CHANNEL_3, TV_FALL); sb += 2 * DIP; return sb; } @@ -449,62 +449,62 @@ static float addAccordPair3(TriggerShape *s, float sb) { void configureHondaAccordCDDip(TriggerShape *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); - s->initialState[T_SECONDARY] = TV_HIGH; + s->initialState[T_SECONDARY] = TV_RISE; float sb = 0; sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); - s->addEvent(90, T_SECONDARY, TV_LOW); + s->addEvent(90, T_SECONDARY, TV_FALL); sb = 90; sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); - s->addEvent(180, T_SECONDARY, TV_HIGH); + s->addEvent(180, T_SECONDARY, TV_RISE); sb = 180; sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); - s->addEvent(270, T_SECONDARY, TV_LOW); + s->addEvent(270, T_SECONDARY, TV_FALL); sb = 270; sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); - s->addEvent(360.0f - DIP, T_PRIMARY, TV_HIGH); - s->addEvent(360, T_SECONDARY, TV_HIGH); + s->addEvent(360.0f - DIP, T_PRIMARY, TV_RISE); + s->addEvent(360, T_SECONDARY, TV_RISE); sb = 360; sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); - s->addEvent(450, T_SECONDARY, TV_LOW); + s->addEvent(450, T_SECONDARY, TV_FALL); sb = 450; sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); - s->addEvent(540, T_SECONDARY, TV_HIGH); + s->addEvent(540, T_SECONDARY, TV_RISE); sb = 540; sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); - s->addEvent(630, T_SECONDARY, TV_LOW); + s->addEvent(630, T_SECONDARY, TV_FALL); sb = 630; sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); sb = addAccordPair3(s, sb); - s->addEvent(720.0f - DIP, T_PRIMARY, TV_LOW); + s->addEvent(720.0f - DIP, T_PRIMARY, TV_FALL); -// s->addEvent(720.0f - 12 * sb, T_SECONDARY, TV_LOW); -// s->addEvent(720.0f, T_SECONDARY, TV_LOW); +// s->addEvent(720.0f - 12 * sb, T_SECONDARY, TV_FALL); +// s->addEvent(720.0f, T_SECONDARY, TV_FALL); - s->addEvent(720.0f, T_SECONDARY, TV_HIGH); + s->addEvent(720.0f, T_SECONDARY, TV_RISE); s->isSynchronizationNeeded = false; } @@ -528,20 +528,20 @@ void configureHondaAccordCD(TriggerShape *s, bool withOneEventSignal, bool withF sb = addAccordPair(s, sb, T_SECONDARY); if (withOneEventSignal) - s->addEvent(sb - S24 / 2, oneEventWave, TV_HIGH); + s->addEvent(sb - S24 / 2, oneEventWave, TV_RISE); sb = addAccordPair(s, sb, T_SECONDARY); sb = addAccordPair(s, sb, T_SECONDARY); if (withOneEventSignal) - s->addEvent(sb - S24 / 2, oneEventWave, TV_LOW); + s->addEvent(sb - S24 / 2, oneEventWave, TV_FALL); sb = addAccordPair(s, sb, T_SECONDARY); sb = addAccordPair(s, sb, T_SECONDARY); if (withFourEventSignal) { - s->addEvent(1 * 180.0f + prefix - tdcWidth, fourEventWave, TV_HIGH); + s->addEvent(1 * 180.0f + prefix - tdcWidth, fourEventWave, TV_RISE); } sb = addAccordPair(s, sb, T_SECONDARY); if (withFourEventSignal) { - s->addEvent(1 * 180.0f + prefix, fourEventWave, TV_LOW); + s->addEvent(1 * 180.0f + prefix, fourEventWave, TV_FALL); } sb = addAccordPair(s, sb, T_SECONDARY); @@ -551,11 +551,11 @@ void configureHondaAccordCD(TriggerShape *s, bool withOneEventSignal, bool withF sb = addAccordPair(s, sb, T_SECONDARY); if (withFourEventSignal) { - s->addEvent(2 * 180.0f + prefix - tdcWidth, fourEventWave, TV_HIGH); + s->addEvent(2 * 180.0f + prefix - tdcWidth, fourEventWave, TV_RISE); } sb = addAccordPair(s, sb, T_SECONDARY); if (withFourEventSignal) { - s->addEvent(2 * 180.0f + prefix, fourEventWave, TV_LOW); + s->addEvent(2 * 180.0f + prefix, fourEventWave, TV_FALL); } for (int i = 3; i <= 4; i++) { @@ -566,11 +566,11 @@ void configureHondaAccordCD(TriggerShape *s, bool withOneEventSignal, bool withF sb = addAccordPair(s, sb, T_SECONDARY); if (withFourEventSignal) { - s->addEvent(i * 180.0f + prefix - tdcWidth, fourEventWave, TV_HIGH); + s->addEvent(i * 180.0f + prefix - tdcWidth, fourEventWave, TV_RISE); } sb = addAccordPair(s, sb, T_SECONDARY); if (withFourEventSignal) { - s->addEvent(i * 180.0f + prefix, fourEventWave, TV_LOW); + s->addEvent(i * 180.0f + prefix, fourEventWave, TV_FALL); } } } diff --git a/firmware/controllers/trigger/trigger_subaru.cpp b/firmware/controllers/trigger/trigger_subaru.cpp index 5ef21b245f..0d7aecfc9a 100644 --- a/firmware/controllers/trigger/trigger_subaru.cpp +++ b/firmware/controllers/trigger/trigger_subaru.cpp @@ -23,24 +23,24 @@ void initialize36_2_2_2(TriggerShape *s) { float base = 0; for (int i = 0; i < 12; i++) { - s->addEvent(base + narrow / 2, T_PRIMARY, TV_HIGH); - s->addEvent(base + narrow, T_PRIMARY, TV_LOW); + s->addEvent(base + narrow / 2, T_PRIMARY, TV_RISE); + s->addEvent(base + narrow, T_PRIMARY, TV_FALL); base += narrow; } - s->addEvent(base + wide / 2, T_PRIMARY, TV_HIGH); - s->addEvent(base + wide, T_PRIMARY, TV_LOW); + s->addEvent(base + wide / 2, T_PRIMARY, TV_RISE); + s->addEvent(base + wide, T_PRIMARY, TV_FALL); base += wide; for (int i = 0; i < 15; i++) { - s->addEvent(base + narrow / 2, T_PRIMARY, TV_HIGH); - s->addEvent(base + narrow, T_PRIMARY, TV_LOW); + s->addEvent(base + narrow / 2, T_PRIMARY, TV_RISE); + s->addEvent(base + narrow, T_PRIMARY, TV_FALL); base += narrow; } - s->addEvent(720 - wide - wide / 2, T_PRIMARY, TV_HIGH); - s->addEvent(720 - wide, T_PRIMARY, TV_LOW); + s->addEvent(720 - wide - wide / 2, T_PRIMARY, TV_RISE); + s->addEvent(720 - wide, T_PRIMARY, TV_FALL); - s->addEvent(720 - wide / 2, T_PRIMARY, TV_HIGH); - s->addEvent(720, T_PRIMARY, TV_LOW); + s->addEvent(720 - wide / 2, T_PRIMARY, TV_RISE); + s->addEvent(720, T_PRIMARY, TV_FALL); } diff --git a/firmware/hw_layer/pwm_generator.cpp b/firmware/hw_layer/pwm_generator.cpp index f9ed9d25b2..df2810e697 100644 --- a/firmware/hw_layer/pwm_generator.cpp +++ b/firmware/hw_layer/pwm_generator.cpp @@ -46,12 +46,12 @@ void startSimplePwm(PwmConfig *state, const char *msg, OutputPin *output, float state->weComplexInit(msg, 2, switchTimes, 1, pinStates, NULL, stateChangeCallback); } +extern pin_output_mode_e DEFAULT_OUTPUT; + void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, OutputPin *output, float frequency, float dutyCycle, pwm_gen_callback *stateChangeCallback) { - GPIO_TypeDef * port = getHwPort(brainPin); - int pin = getHwPin(brainPin); - outputPinRegister(msg, output, port, pin); + outputPinRegisterExt2(msg, output, brainPin, &DEFAULT_OUTPUT); startSimplePwm(state, msg, output, frequency, dutyCycle, stateChangeCallback); } diff --git a/unit_tests/test_fuel_map.cpp b/unit_tests/test_fuel_map.cpp index daae9706b4..ca40b92171 100644 --- a/unit_tests/test_fuel_map.cpp +++ b/unit_tests/test_fuel_map.cpp @@ -124,17 +124,17 @@ extern engine_configuration_s *engineConfiguration; static void confgiureFordAspireTriggerShape(TriggerShape * s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); - s->addEvent(53.747, T_SECONDARY, TV_HIGH); - s->addEvent(121.90, T_SECONDARY, TV_LOW); - s->addEvent(232.76, T_SECONDARY, TV_HIGH); - s->addEvent(300.54, T_SECONDARY, TV_LOW); - s->addEvent(360, T_PRIMARY, TV_HIGH); + s->addEvent(53.747, T_SECONDARY, TV_RISE); + s->addEvent(121.90, T_SECONDARY, TV_FALL); + s->addEvent(232.76, T_SECONDARY, TV_RISE); + s->addEvent(300.54, T_SECONDARY, TV_FALL); + s->addEvent(360, T_PRIMARY, TV_RISE); - s->addEvent(409.8412, T_SECONDARY, TV_HIGH); - s->addEvent(478.6505, T_SECONDARY, TV_LOW); - s->addEvent(588.045, T_SECONDARY, TV_HIGH); - s->addEvent(657.03, T_SECONDARY, TV_LOW); - s->addEvent(720, T_PRIMARY, TV_LOW); + s->addEvent(409.8412, T_SECONDARY, TV_RISE); + s->addEvent(478.6505, T_SECONDARY, TV_FALL); + s->addEvent(588.045, T_SECONDARY, TV_RISE); + s->addEvent(657.03, T_SECONDARY, TV_FALL); + s->addEvent(720, T_PRIMARY, TV_FALL); assertEquals(53.747 / 720, s->wave.getSwitchTime(0)); assertEqualsM("@0", 1, s->wave.getChannelState(1, 0));