26 #if EFI_PRINTF_FUEL_DETAILS
30 #if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
36 #include "cyclic_buffer.h"
44 #if EFI_LAUNCH_CONTROL
98 const float injectionMassStage2 = stage2Fraction * injectionMassGrams;
99 float injectionMassStage1 = injectionMassGrams - injectionMassStage2;
101 #if EFI_VEHICLE_SPEED
108 float actualInjectedMass = numberOfInjections * (injectionMassStage1 + injectionMassStage2);
117 #if EFI_PRINTF_FUEL_DETAILS
119 printf(
"fuel injectionDuration=%.2fms adjusted=%.2fms\n",
121 injectionDurationStage1);
130 if (cisnan(injectionDurationStage1) || cisnan(injectionDurationStage2)) {
134 if (injectionDurationStage1 < 0) {
143 if (injectionDurationStage1 < 0.050f)
148 floatus_t durationUsStage1 = MS2US(injectionDurationStage1);
149 floatus_t durationUsStage2 = MS2US(injectionDurationStage2);
152 bool hasStage2Injection = durationUsStage2 > 50;
154 #if EFI_PRINTF_FUEL_DETAILS
157 printf(
"handleFuelInjectionEvent fuelout %s injection_duration %dus engineCycleDuration=%.1fms\t\n", output->
getName(), (
int)durationUsStage1,
162 action_s startAction, endActionStage1, endActionStage2;
168 uintptr_t startActionPtr =
reinterpret_cast<uintptr_t
>(
this);
170 if (hasStage2Injection) {
182 float angleFromNow = eventAngle - currentPhase;
183 if (angleFromNow < 0) {
188 efitick_t startTime =
scheduleByAngle(
nullptr, nowNt, angleFromNow, startAction);
191 efitick_t turnOffTimeStage1 = startTime + US2NT((
int)durationUsStage1);
195 if (hasStage2Injection && endActionStage2) {
196 efitick_t turnOffTimeStage2 = startTime + US2NT((
int)durationUsStage2);
200 #if EFI_DEFAILED_LOGGING
201 printf(
"scheduling injection angle=%.2f/delay=%d injectionDuration=%d %d\r\n", angleFromNow, (
int)NT2US(startTime - nowNt), (
int)durationUsStage1, (
int)durationUsStage2);
203 #if EFI_DEFAILED_LOGGING
204 efiPrintf(
"handleFuel pin=%s eventIndex %d duration=%.2fms %d",
outputs[0]->name,
206 injectionDurationStage1,
207 getRevolutionCounter());
208 efiPrintf(
"handleFuel pin=%s delay=%.2f %d",
outputs[0]->name, NT2US(startTime - nowNt),
209 getRevolutionCounter());
213 static void handleFuel(efitick_t nowNt,
float currentPhase,
float nextPhase) {
222 bool limitedFuel = !limitedFuelState.
value;
234 #if FUEL_MATH_EXTREME_LOGGING
236 efiPrintf(
"handleFuel [%.1f, %.1f) %d", currentPhase, nextPhase, getRevolutionCounter());
251 if (hasFirmwareError()) {
266 if (rpm == NOISY_RPM) {
272 if (trgEventIndex == 0) {
289 handleFuel(edgeTimestamp, currentPhase, nextPhase);
292 rpm, edgeTimestamp, currentPhase, nextPhase);
Non-volatile backup-RAM registers support.
void periodicFastCallback()
RpmCalculator rpmCalculator
constexpr auto & module()
TunerStudioOutputChannels outputChannels
virtual bool isCranking() const =0
float injectionMass[MAX_CYLINDER_COUNT]
float injectionStage2Fraction
void onTriggerTooth(efitick_t nowNt, float currentPhase, float nextPhase)
InjectorOutputPin * outputsStage2[MAX_WIRES_COUNT]
void onTriggerTooth(efitick_t nowNt, float currentPhase, float nextPhase)
InjectorOutputPin * outputs[MAX_WIRES_COUNT]
float injectionStartAngle
void close(efitick_t nowNt)
LimpState allowInjection() const
const char * getName() const
float getCachedRpm() const
static float getOrZero(SensorType type)
float adjust(float desiredMassGrams)
bool isPhaseInRange(float test, float current, float next)
EngineRotationState * getEngineRotationState()
FuelSchedule * getFuelSchedule()
LimpManager * getLimpManager()
IgnitionEventList * getIgnitionEvents()
ExecutorInterface * getExecutorInterface()
EngineState * getEngineState()
TriggerCentral * getTriggerCentral()
floatms_t getCrankshaftRevolutionTimeMs(int rpm)
bool warning(ObdCode code, const char *fmt,...)
int getNumberOfInjections(injection_mode_e mode)
void turnInjectionPinHigh(uintptr_t arg)
void startSimultaneousInjection(void *)
void endSimultaneousInjectionOnlyTogglePins()
void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_t currentPhase, angle_t nextPhase)
static void handleFuel(efitick_t nowNt, float currentPhase, float nextPhase)
void turnInjectionPinLow(InjectionEvent *event)
void endSimultaneousInjection(InjectionEvent *event)
static void turnInjectionPinLowStage2(InjectionEvent *event)
@ OBD_Crankshaft_Position_Sensor_A_Circuit_Malfunction
@ CUSTOM_OBD_NEG_INJECTION
@ CUSTOM_OBD_NAN_INJECTION
engine_configuration_s * engineConfiguration
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t nowNt, angle_t angle, action_s action)
void onTriggerEventSparkLogic(int rpm, efitick_t edgeTimestamp, float currentPhase, float nextPhase)
virtual void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action)=0
injection_mode_e crankingInjectionMode
injection_mode_e injectionMode
scaled_channel< uint16_t, 300, 1 > actualLastInjectionStage2
scaled_channel< uint16_t, 300, 1 > actualLastInjection