diff --git a/firmware/config/engines/nissan_primera.cpp b/firmware/config/engines/nissan_primera.cpp index 889ca648d8..ae6418de88 100644 --- a/firmware/config/engines/nissan_primera.cpp +++ b/firmware/config/engines/nissan_primera.cpp @@ -16,4 +16,8 @@ void setNissanPrimeraEngineConfiguration(engine_configuration_s *engineConfigura engineConfiguration->trigger.type = TT_NISSAN_SR20VE; } +void setNissanPrimeraEngineConfiguration_360(engine_configuration_s *engineConfiguration) { + engineConfiguration->trigger.type = TT_NISSAN_SR20VE_360; +} + #endif /* EFI_SUPPORT_NISSAN_PRIMERA */ diff --git a/firmware/config/engines/nissan_primera.h b/firmware/config/engines/nissan_primera.h index d280fce031..d8caabb311 100644 --- a/firmware/config/engines/nissan_primera.h +++ b/firmware/config/engines/nissan_primera.h @@ -15,6 +15,8 @@ #include "engine_configuration.h" void setNissanPrimeraEngineConfiguration(engine_configuration_s *engineConfiguration); +void setNissanPrimeraEngineConfiguration_360(engine_configuration_s *engineConfiguration); + #endif /* EFI_SUPPORT_NISSAN_PRIMERA */ #endif /* NISSAN_PRIMERA_H_ */ diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index 4e2d343797..27655e99d3 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -215,8 +215,8 @@ case TT_2JZ_3_34: return "TT_2JZ_3_34"; case TT_ROVER_K: return "TT_ROVER_K"; -case TT_TEMP_WIP: - return "TT_TEMP_WIP"; +case TT_NISSAN_SR20VE_360: + return "TT_NISSAN_SR20VE_360"; } return NULL; } diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index feb8b270ec..0382be7ca2 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -244,7 +244,7 @@ typedef enum { TT_JEEP_18_2_2_2 = 37, - TT_TEMP_WIP = 38, + TT_NISSAN_SR20VE_360 = 38, TT_UNUSED = 39, // this is used if we want to iterate over all trigger types diff --git a/firmware/controllers/trigger/decoders/trigger_nissan.cpp b/firmware/controllers/trigger/decoders/trigger_nissan.cpp index b2287c8764..3c23cbcc86 100644 --- a/firmware/controllers/trigger/decoders/trigger_nissan.cpp +++ b/firmware/controllers/trigger/decoders/trigger_nissan.cpp @@ -6,40 +6,98 @@ */ #include "trigger_nissan.h" +#include "trigger_universal.h" -/** - * Nissan Primera p11 year 1995-2002 - */ - -void initializeNissanSR20VE_4(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { - s->initialize(FOUR_STROKE_CAM_SENSOR, false); +static void initializeNissanSR20VE_4_optional_360(TriggerShape *s, bool with2nd DECLARE_ENGINE_PARAMETER_S) { + s->initialize(FOUR_STROKE_CAM_SENSOR, with2nd); s->isSynchronizationNeeded = true; s->gapBothDirections = true; + s->useOnlyPrimaryForSync = true; s->tdcPosition = 630; float w = 5; s->setTriggerSynchronizationGap2(9.67 * 0.75, 16); + float left = 0; + float right; + + int total = 360; // 360 on cam, over 720 crank degree + float base = 180; - s->addEvent2(base - 15, T_PRIMARY, TV_RISE PASS_ENGINE_PARAMETER); - s->addEvent2(base, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER); + right = base - 15; + + if (with2nd) { + addSkippedToothTriggerEvents(T_SECONDARY, s, total, 0, 0.5, 0, 720, + left, right PASS_ENGINE_PARAMETER); + } + + s->addEvent2(right, T_PRIMARY, TV_RISE PASS_ENGINE_PARAMETER); + + left = right; + right = base; + if (with2nd) { + addSkippedToothTriggerEvents(T_SECONDARY, s, total, 0, 0.5, 0, 720, + left, right PASS_ENGINE_PARAMETER); + } + s->addEvent2(right, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER); // was is the the one with 360 opto sensor? base += 180; - s->addEvent2(base - w, T_PRIMARY, TV_RISE PASS_ENGINE_PARAMETER); - s->addEvent2(base, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER); + + left = right; + right = base - w; + if (with2nd) { +// addSkippedToothTriggerEvents(T_SECONDARY, s, total, 0, 0.5, 0, 720, +// left, right PASS_ENGINE_PARAMETER); + } + s->addEvent2(right, T_PRIMARY, TV_RISE PASS_ENGINE_PARAMETER); + + left = right; + right = base; + if (with2nd) { +// addSkippedToothTriggerEvents(T_SECONDARY, s, total, 0, 0.5, 0, 720, +// left, right PASS_ENGINE_PARAMETER); + } + s->addEvent2(right, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER); base += 180; - s->addEvent2(base - w, T_PRIMARY, TV_RISE PASS_ENGINE_PARAMETER); - s->addEvent2(base, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER); + left = right; + right = base - w; + if (with2nd) { +// addSkippedToothTriggerEvents(T_SECONDARY, s, total, 0, 0.5, 0, 720, +// left, right PASS_ENGINE_PARAMETER); + } + s->addEvent2(right, T_PRIMARY, TV_RISE PASS_ENGINE_PARAMETER); + + left = right; + right = base; + if (with2nd) { +// addSkippedToothTriggerEvents(T_SECONDARY, s, total, 0, 0.5, 0, 720, +// left, right PASS_ENGINE_PARAMETER); + } + s->addEvent2(right, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER); base += 180; - s->addEvent2(base - w, T_PRIMARY, TV_RISE PASS_ENGINE_PARAMETER); - s->addEvent2(base, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER); + left = right; + right = base - w; + + s->addEvent2(right, T_PRIMARY, TV_RISE PASS_ENGINE_PARAMETER); + left = right; + right = base; + s->addEvent2(right, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER); +} + + +/** + * Nissan Primera p11 year 1995-2002 + */ + +void initializeNissanSR20VE_4(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { + initializeNissanSR20VE_4_optional_360(s, false PASS_ENGINE_PARAMETER); } void initializeNissanSR20VE_4_360(TriggerShape *s DECLARE_ENGINE_PARAMETER_S) { - + initializeNissanSR20VE_4_optional_360(s, true PASS_ENGINE_PARAMETER); } diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 2ffe65fe14..61f5a76805 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -634,10 +634,13 @@ void TriggerShape::initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMET break; case TT_NISSAN_SR20VE: - case TT_TEMP_WIP: initializeNissanSR20VE_4(this PASS_ENGINE_PARAMETER); break; + case TT_NISSAN_SR20VE_360: + initializeNissanSR20VE_4_360(this PASS_ENGINE_PARAMETER); + break; + case TT_ROVER_K: initializeRoverK(this PASS_ENGINE_PARAMETER); break; diff --git a/firmware/global.h b/firmware/global.h index 3bb60a41a1..0a3510581e 100644 --- a/firmware/global.h +++ b/firmware/global.h @@ -125,4 +125,8 @@ int getRemainingStack(thread_t *otp); } #endif /* __cplusplus */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif /* GLOBAL_H_ */