From 39fd428e0df34693e04f6de95b4cc225369a9f4e Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 18 Dec 2016 22:03:00 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/algo/event_registry.h | 18 +----------------- firmware/controllers/math/engine_math.cpp | 8 ++++---- firmware/controllers/math/engine_math.h | 2 -- firmware/controllers/trigger/spark_logic.cpp | 4 ++-- .../controllers/trigger/trigger_structure.h | 19 +++++++++++++++++++ 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/firmware/controllers/algo/event_registry.h b/firmware/controllers/algo/event_registry.h index bfd33d5bd9..467f43004f 100644 --- a/firmware/controllers/algo/event_registry.h +++ b/firmware/controllers/algo/event_registry.h @@ -11,23 +11,7 @@ #include "global.h" #include "signal_executor.h" #include "fl_stack.h" - -/** - * This structure defines an angle position within the trigger - */ -class event_trigger_position_s { -public: - event_trigger_position_s(); - /** - * That's trigger event index - */ - uint32_t eventIndex; - angle_t eventAngle; - /** - * Angle offset from the trigger event - */ - angle_t angleOffset; -}; +#include "trigger_structure.h" class Engine; diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index e3ed104907..28259710ca 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -175,7 +175,7 @@ void FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_S) { efiAssertVoid(TRIGGER_SHAPE(getSize()) > 0, "uninitialized TriggerShape"); - findTriggerPosition(&ev->injectionStart, angle PASS_ENGINE_PARAMETER); + TRIGGER_SHAPE(findTriggerPosition(&ev->injectionStart, angle PASS_ENGINE_PARAMETER)); #if EFI_UNIT_TEST printf("registerInjectionEvent angle=%f trgIndex=%d inj %d\r\n", angle, ev->injectionStart.eventIndex, index); #endif @@ -255,13 +255,13 @@ static int findAngleIndex(float target DECLARE_ENGINE_PARAMETER_S) { } -void findTriggerPosition(event_trigger_position_s *position, angle_t angleOffset DECLARE_ENGINE_PARAMETER_S) { +void TriggerShape::findTriggerPosition(event_trigger_position_s *position, angle_t angleOffset DECLARE_ENGINE_PARAMETER_S) { // convert engine cycle angle into trigger cycle angle angleOffset += tdcPosition(); fixAngle(angleOffset, "addFuel#2"); - int index = TRIGGER_SHAPE(triggerIndexByAngle[(int)angleOffset]); - angle_t eventAngle = TRIGGER_SHAPE(eventAngles[index]); + int index = triggerIndexByAngle[(int)angleOffset]; + angle_t eventAngle = eventAngles[index]; if (angleOffset < eventAngle) { warning(CUSTOM_OBD_ANGLE_CONSTRAINT_VIOLATION, "angle constraint violation in findTriggerPosition(): %f/%f", angleOffset, eventAngle); return; diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index fb64387b27..94714a99f6 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -16,8 +16,6 @@ void setAlgorithm(engine_load_mode_e algo DECLARE_ENGINE_PARAMETER_S); -void findTriggerPosition( - event_trigger_position_s *position, angle_t angleOffset DECLARE_ENGINE_PARAMETER_S); #if EFI_ENABLE_ASSERTS #define assertAngleRange(angle, msg) if(angle > 10000000 || angle < -10000000) { firmwareError(OBD_PCM_Processor_Fault, "angle range %s %f", msg, angle);angle = 0;} diff --git a/firmware/controllers/trigger/spark_logic.cpp b/firmware/controllers/trigger/spark_logic.cpp index 936fd97404..21a8ef3685 100644 --- a/firmware/controllers/trigger/spark_logic.cpp +++ b/firmware/controllers/trigger/spark_logic.cpp @@ -174,7 +174,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI * Spark event is often happening during a later trigger event timeframe * TODO: improve precision */ - findTriggerPosition(&iEvent->sparkPosition, iEvent->advance PASS_ENGINE_PARAMETER); + TRIGGER_SHAPE(findTriggerPosition(&iEvent->sparkPosition, iEvent->advance PASS_ENGINE_PARAMETER)); #if EFI_UNIT_TEST || defined(__DOXYGEN__) printf("spark dwell@ %d/%d spark@ %d/%d id=%d\r\n", iEvent->dwellPosition.eventIndex, (int)iEvent->dwellPosition.angleOffset, @@ -245,7 +245,7 @@ void prepareIgnitionSchedule(IgnitionEvent *event DECLARE_ENGINE_PARAMETER_S) { event->outputs[1] = secondOutput; event->advance = localAdvance; - findTriggerPosition(&event->dwellPosition, localAdvance - dwellAngle PASS_ENGINE_PARAMETER); + TRIGGER_SHAPE(findTriggerPosition(&event->dwellPosition, localAdvance - dwellAngle PASS_ENGINE_PARAMETER)); #if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__) printf("addIgnitionEvent %s ind=%d\n", output->name, event->dwellPosition.eventIndex); diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index e75a9852e3..93247dd714 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -14,6 +14,23 @@ #include "EfiWave.h" #include "engine_configuration.h" +/** + * This structure defines an angle position within the trigger + */ +class event_trigger_position_s { +public: + event_trigger_position_s(); + /** + * That's trigger event index + */ + uint32_t eventIndex; + angle_t eventAngle; + /** + * Angle offset from the trigger event + */ + angle_t angleOffset; +}; + #define TRIGGER_CHANNEL_COUNT 3 class trigger_shape_helper { @@ -35,6 +52,8 @@ class TriggerShape { public: TriggerShape(); void initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_S); + void findTriggerPosition( + event_trigger_position_s *position, angle_t angleOffset DECLARE_ENGINE_PARAMETER_S); bool isSynchronizationNeeded; bool needSecondTriggerInput;