rusefi/firmware/controllers/engine_cycle/prime_injection.cpp

45 lines
1020 B
C++
Raw Normal View History

2022-09-07 13:25:50 -07:00
/*
* @file prime_injection.cpp
*/
2022-09-07 13:27:56 -07:00
#include "pch.h"
2022-09-07 13:25:50 -07:00
#include "prime_injection.h"
2022-09-07 16:35:52 -07:00
#include "injection_gpio.h"
2022-09-07 13:27:56 -07:00
#include "sensor.h"
2022-09-07 17:31:04 -07:00
#include "backup_ram.h"
2022-09-07 13:25:50 -07:00
2022-09-07 13:27:56 -07:00
void PrimeController::onPrimeEnd() {
endSimultaneousInjectionOnlyTogglePins();
m_isPriming = false;
}
floatms_t PrimeController::getPrimeDuration() const {
auto clt = Sensor::get(SensorType::Clt);
// If the coolant sensor is dead, skip the prime. The engine will still start fine, but may take a little longer.
if (!clt) {
return 0;
}
auto primeMass =
0.001f * // convert milligram to gram
interpolate2d(clt.Value, engineConfiguration->primeBins, engineConfiguration->primeValues);
return engine->module<InjectorModel>()->getInjectionDuration(primeMass);
}
2022-09-07 17:31:04 -07:00
void updatePrimeInjectionPulseState() {
static bool counterWasReset = false;
if (counterWasReset)
return;
if (!getEngineRotationState()->isStopped()) {
#if EFI_PROD_CODE
backupRamSave(BACKUP_IGNITION_SWITCH_COUNTER, 0);
#endif /* EFI_PROD_CODE */
counterWasReset = true;
}
}