refactoring around cranking priming
This commit is contained in:
parent
a67c7d58f2
commit
bebc58aa57
|
@ -83,24 +83,24 @@ extern TunerStudioOutputChannels tsOutputChannels;
|
||||||
//#define RAM_METHOD_PREFIX
|
//#define RAM_METHOD_PREFIX
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
static void startSimultaniousInjection(InjectionEvent *event) {
|
static void startSimultaniousInjection(Engine *engine) {
|
||||||
(void)event;
|
|
||||||
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
|
|
||||||
Engine *engine = event->engine;
|
|
||||||
#endif
|
|
||||||
for (int i = 0; i < engine->engineConfiguration->specs.cylindersCount; i++) {
|
for (int i = 0; i < engine->engineConfiguration->specs.cylindersCount; i++) {
|
||||||
enginePins.injectors[i].setHigh();
|
enginePins.injectors[i].setHigh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void endSimultaniousInjectionOnlyTogglePins(Engine *engine) {
|
||||||
|
for (int i = 0; i < engine->engineConfiguration->specs.cylindersCount; i++) {
|
||||||
|
enginePins.injectors[i].setLow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void endSimultaniousInjection(InjectionEvent *event) {
|
static void endSimultaniousInjection(InjectionEvent *event) {
|
||||||
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
|
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
|
||||||
Engine *engine = event->engine;
|
Engine *engine = event->engine;
|
||||||
EXPAND_Engine;
|
EXPAND_Engine;
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < engine->engineConfiguration->specs.cylindersCount; i++) {
|
endSimultaniousInjectionOnlyTogglePins(engine);
|
||||||
enginePins.injectors[i].setLow();
|
|
||||||
}
|
|
||||||
engine->injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX);
|
engine->injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
||||||
// todo: sequential need this logic as well, just do not forget to clear flag pair->isScheduled = true;
|
// todo: sequential need this logic as well, just do not forget to clear flag pair->isScheduled = true;
|
||||||
scheduling_s * sDown = &pair->signalTimerDown;
|
scheduling_s * sDown = &pair->signalTimerDown;
|
||||||
|
|
||||||
scheduleTask(sUp, (int) injectionStartDelayUs, (schfunc_t) &startSimultaniousInjection, event);
|
scheduleTask(sUp, (int) injectionStartDelayUs, (schfunc_t) &startSimultaniousInjection, engine);
|
||||||
scheduleTask(sDown, (int) injectionStartDelayUs + durationUs,
|
scheduleTask(sDown, (int) injectionStartDelayUs + durationUs,
|
||||||
(schfunc_t) &endSimultaniousInjection, event);
|
(schfunc_t) &endSimultaniousInjection, event);
|
||||||
|
|
||||||
|
@ -537,14 +537,18 @@ static void startPrimeInjectionPulse(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
primeInjEvent.isSimultanious = true;
|
primeInjEvent.isSimultanious = true;
|
||||||
|
|
||||||
scheduling_s *sDown = &ENGINE(fuelActuators[0]).signalTimerDown;
|
scheduling_s *sDown = &ENGINE(fuelActuators[0]).signalTimerDown;
|
||||||
startSimultaniousInjection(&primeInjEvent);
|
|
||||||
// When the engine is hot, basically we don't need prime inj.pulse, so we use an interpolation over temperature (falloff).
|
// When the engine is hot, basically we don't need prime inj.pulse, so we use an interpolation over temperature (falloff).
|
||||||
// If 'primeInjFalloffTemperature' is not specified (by default), we have a prime pulse deactivation at zero celsius degrees, which is okay.
|
// If 'primeInjFalloffTemperature' is not specified (by default), we have a prime pulse deactivation at zero celsius degrees, which is okay.
|
||||||
const float maxPrimeInjAtTemperature = -40.0f; // at this temperature the pulse is maximal.
|
const float maxPrimeInjAtTemperature = -40.0f; // at this temperature the pulse is maximal.
|
||||||
float pulseLength = interpolateClamped(maxPrimeInjAtTemperature, CONFIG(startOfCrankingPrimingPulse),
|
floatms_t pulseLength = interpolateClamped(maxPrimeInjAtTemperature, CONFIG(startOfCrankingPrimingPulse),
|
||||||
CONFIG(primeInjFalloffTemperature), 0.0f, ENGINE(sensors.clt));
|
CONFIG(primeInjFalloffTemperature), 0.0f, ENGINE(sensors.clt));
|
||||||
|
if (pulseLength > 0) {
|
||||||
|
startSimultaniousInjection(engine);
|
||||||
|
// todo: why do we round to whole number of milliseconds here?
|
||||||
efitimeus_t turnOffTime = getTimeNowUs() + MS2US((int)efiRound(pulseLength, 1.0f));
|
efitimeus_t turnOffTime = getTimeNowUs() + MS2US((int)efiRound(pulseLength, 1.0f));
|
||||||
scheduleTask(sDown, turnOffTime, (schfunc_t) &endSimultaniousInjection, &primeInjEvent);
|
// todo: we have a bug here for sure since 'scheduleTask' does it's own 'getTimeNowUs()'
|
||||||
|
scheduleTask(sDown, turnOffTime, (schfunc_t) &endSimultaniousInjectionOnlyTogglePins, engine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// we'll reset it later when the engine starts
|
// we'll reset it later when the engine starts
|
||||||
backupRamSave(BACKUP_IGNITION_SWITCH_COUNTER, ignSwitchCounter + 1);
|
backupRamSave(BACKUP_IGNITION_SWITCH_COUNTER, ignSwitchCounter + 1);
|
||||||
|
|
Loading…
Reference in New Issue