diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 11f70f04e7..2b1ac8b6df 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -18,6 +18,10 @@ #include "table_helper.h" #include "listener_array.h" +#define OUTPUT_SIGNAL_MAX_SIZE 45 + +typedef ArrayList OutputSignalList; + /** * This class knows about when to inject fuel */ @@ -29,7 +33,7 @@ public: /** * this method schedules all fuel events for an engine cycle */ - void addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S); + void addFuelEvents(OutputSignalList *sourceList, injection_mode_e mode DECLARE_ENGINE_PARAMETER_S); /** * This is a performance optimization for https://sourceforge.net/p/rusefi/tickets/64/ @@ -38,7 +42,7 @@ public: uint8_t hasEvents[PWM_PHASE_MAX_COUNT]; private: void clear(); - void registerInjectionEvent(NamedOutputPin *output, float angle, bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S); + void registerInjectionEvent(OutputSignalList *sourceList, NamedOutputPin *output, float angle, bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S); }; /** diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index f201b9f5a8..145e8b8295 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -92,7 +92,8 @@ void setSingleCoilDwell(engine_configuration_s *engineConfiguration) { } #if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) -OutputSignalList injectonSignals CCM_OPTIONAL; +OutputSignalList runningInjectonSignals CCM_OPTIONAL; +OutputSignalList crankingInjectonSignals CCM_OPTIONAL; void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) { @@ -117,7 +118,7 @@ void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, } } -void FuelSchedule::registerInjectionEvent(NamedOutputPin *output, float angle, +void FuelSchedule::registerInjectionEvent(OutputSignalList *sourceList, NamedOutputPin *output, float angle, bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S) { if (!isSimultanious && !isPinAssigned(output)) { // todo: extact method for this index math @@ -130,7 +131,7 @@ void FuelSchedule::registerInjectionEvent(NamedOutputPin *output, float angle, return; } - OutputSignal *actuator = injectonSignals.add(); + OutputSignal *actuator = sourceList->add(); actuator->output = output; ev->isSimultanious = isSimultanious; @@ -151,7 +152,7 @@ void FuelSchedule::clear() { memset(hasEvents, 0, sizeof(hasEvents)); } -void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) { +void FuelSchedule::addFuelEvents(OutputSignalList *sourceList, injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) { ActuatorEventList *list = &events; ; list->reset(); @@ -164,7 +165,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_ int index = getCylinderId(engineConfiguration->specs.firingOrder, i) - 1; float angle = baseAngle + (float) engineConfiguration->engineCycle * i / engineConfiguration->specs.cylindersCount; - registerInjectionEvent(&enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); + registerInjectionEvent(sourceList, &enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); } break; case IM_SIMULTANEOUS: @@ -176,7 +177,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_ * We do not need injector pin here because we will control all injectors * simultaniously */ - registerInjectionEvent(NULL, angle, true PASS_ENGINE_PARAMETER); + registerInjectionEvent(sourceList, NULL, angle, true PASS_ENGINE_PARAMETER); } break; case IM_BATCH: @@ -184,7 +185,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_ int index = i % (engineConfiguration->specs.cylindersCount / 2); float angle = baseAngle + i * (float) engineConfiguration->engineCycle / engineConfiguration->specs.cylindersCount; - registerInjectionEvent(&enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); + registerInjectionEvent(sourceList, &enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); if (engineConfiguration->twoWireBatch) { @@ -192,7 +193,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_ * also fire the 2nd half of the injectors so that we can implement a batch mode on individual wires */ index = index + (engineConfiguration->specs.cylindersCount / 2); - registerInjectionEvent(&enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); + registerInjectionEvent(sourceList, &enginePins.injectors[index], angle, false PASS_ENGINE_PARAMETER); } } break; @@ -341,8 +342,10 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F) { injectonSignals.reset(); engineConfiguration2->crankingInjectionEvents.addFuelEvents( + &crankingInjectonSignals, engineConfiguration->crankingInjectionMode PASS_ENGINE_PARAMETER); - engineConfiguration2->injectionEvents.addFuelEvents(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER); + engineConfiguration2->injectionEvents.addFuelEvents(&runningInjectonSignals, + engineConfiguration->injectionMode PASS_ENGINE_PARAMETER); } #endif diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index 32179a58a8..98204ba487 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -14,10 +14,6 @@ #include "table_helper.h" #include "engine.h" -#define OUTPUT_SIGNAL_MAX_SIZE 90 - -typedef ArrayList OutputSignalList; - void findTriggerPosition( event_trigger_position_s *position, angle_t angleOffset DECLARE_ENGINE_PARAMETER_S);