rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
main_trigger_callback.cpp File Reference

Detailed Description

Main logic is here!

See http://rusefi.com/docs/html/

Date
Feb 7, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

This file is part of rusEfi - see http://rusefi.com

rusEfi is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file main_trigger_callback.cpp.

Functions

void endSimultaneousInjection (InjectionEvent *event)
 
void turnInjectionPinLow (InjectionEvent *event)
 
static void turnInjectionPinLowStage2 (InjectionEvent *event)
 
static void handleFuel (efitick_t nowNt, float currentPhase, float nextPhase)
 
void mainTriggerCallback (uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_t currentPhase, angle_t nextPhase)
 

Variables

bool printFuelDebug = false
 

Function Documentation

◆ endSimultaneousInjection()

void endSimultaneousInjection ( InjectionEvent event)

Definition at line 50 of file main_trigger_callback.cpp.

50 {
52 event->update();
53}
void endSimultaneousInjectionOnlyTogglePins()
Here is the call graph for this function:

◆ handleFuel()

static void handleFuel ( efitick_t  nowNt,
float  currentPhase,
float  nextPhase 
)
static

Definition at line 224 of file main_trigger_callback.cpp.

224 {
226
227 efiAssertVoid(ObdCode::CUSTOM_STACK_6627, hasLotsOfRemainingStack(), "lowstck#3");
228
229 LimpState limitedFuelState = getLimpManager()->allowInjection();
230
231 // todo: eliminate state copy logic by giving limpManager it's owm limp_manager.txt and leveraging LiveData
232 engine->outputChannels.fuelCutReason = (int8_t)limitedFuelState.reason;
233 bool limitedFuel = !limitedFuelState.value;
234 if (limitedFuel) {
235 return;
236 }
237
238 // This is called in the fast callback already, but since we may have just achieved engine sync (and RPM)
239 // for the first time, force update the schedule so that we can inject immediately if necessary
241 if (!fs->isReady) {
242 fs->addFuelEvents();
243 }
244
245#if FUEL_MATH_EXTREME_LOGGING
246 if (printFuelDebug) {
247 efiPrintf("handleFuel [%.1f, %.1f) %d", currentPhase, nextPhase, getRevolutionCounter());
248 }
249#endif /* FUEL_MATH_EXTREME_LOGGING */
250
251 fs->onTriggerTooth(nowNt, currentPhase, nextPhase);
252}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
void onTriggerTooth(efitick_t nowNt, float currentPhase, float nextPhase)
LimpState allowInjection() const
LimpManager * getLimpManager()
Definition engine.cpp:597
FuelSchedule * getFuelSchedule()
Definition engine.cpp:601
static EngineAccessor engine
Definition engine.h:413
bool printFuelDebug
@ CUSTOM_STACK_6627
@ HandleFuel
const bool value
const ClearReason reason

Referenced by mainTriggerCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mainTriggerCallback()

void mainTriggerCallback ( uint32_t  trgEventIndex,
efitick_t  edgeTimestamp,
angle_t  currentPhase,
angle_t  nextPhase 
)

This is the main trigger event handler. Both injection and ignition are controlled from this method.

In case on a major error we should not process any more events.

For fuel we schedule start of injection based on trigger angle, and then inject for specified duration of time

For spark we schedule both start of coil charge and actual spark based on trigger angle

Definition at line 258 of file main_trigger_callback.cpp.

258 {
260
261 if (hasFirmwareError()) {
262 /**
263 * In case on a major error we should not process any more events.
264 */
265 return;
266 }
267
268 float rpm = engine->rpmCalculator.getCachedRpm();
269 if (rpm == 0) {
270 // this happens while we just start cranking
271
272 // todo: check for 'trigger->is_synchnonized?'
273 return;
274 }
275
276 if (trgEventIndex == 0) {
277
278 if (getTriggerCentral()->checkIfTriggerConfigChanged()) {
279 getIgnitionEvents()->isReady = false; // we need to rebuild complete ignition schedule
280 getFuelSchedule()->isReady = false;
281 // moved 'triggerIndexByAngle' into trigger initialization (why was it invoked from here if it's only about trigger shape & optimization?)
282 // see updateTriggerConfiguration() -> prepareOutputSignals()
283
284 // we need this to apply new 'triggerIndexByAngle' values
286 }
287 }
288
289 engine->engineModules.apply_all([=](auto & m) {
290 m.onEnginePhase(rpm, edgeTimestamp, currentPhase, nextPhase);
291 });
292
293 /**
294 * For fuel we schedule start of injection based on trigger angle, and then inject for
295 * specified duration of time
296 */
297 handleFuel(edgeTimestamp, currentPhase, nextPhase);
298
299 engine->module<TriggerScheduler>()->scheduleEventsUntilNextTriggerTooth(
300 rpm, edgeTimestamp, currentPhase, nextPhase);
301
302 /**
303 * For spark we schedule both start of coil charge and actual spark based on trigger angle
304 */
305 onTriggerEventSparkLogic(rpm, edgeTimestamp, currentPhase, nextPhase);
306}
void periodicFastCallback()
Definition engine.cpp:557
RpmCalculator rpmCalculator
Definition engine.h:306
constexpr auto & module()
Definition engine.h:200
type_list< Mockable< InjectorModelPrimary >, Mockable< InjectorModelSecondary >,#if EFI_IDLE_CONTROL Mockable< IdleController >,#endif TriggerScheduler,#if EFI_HPFP &&EFI_ENGINE_CONTROL Mockable< HpfpController >,#endif #if EFI_ENGINE_CONTROL Mockable< ThrottleModel >,#endif #if EFI_ALTERNATOR_CONTROL AlternatorController,#endif MainRelayController, Mockable< IgnitionController >, Mockable< AcController >, PrimeController, DfcoController,#if EFI_HD_ACR HarleyAcr,#endif Mockable< WallFuelController >, KnockController, SensorChecker,#if EFI_ENGINE_CONTROL Mockable< LimpManager >,#endif #if EFI_VVT_PID VvtController1, VvtController2, VvtController3, VvtController4,#endif #if EFI_BOOST_CONTROL BoostController,#endif TpsAccelEnrichment,#if EFI_LAUNCH_CONTROL NitrousController,#endif #if EFI_LTFT_CONTROL LongTermFuelTrim,#endif ShortTermFuelTrim,#include "modules_list_generated.h" EngineModule > engineModules
Definition engine.h:194
float getCachedRpm() const
TriggerCentral * getTriggerCentral()
Definition engine.cpp:591
IgnitionEventList * getIgnitionEvents()
Definition engine.cpp:605
static void handleFuel(efitick_t nowNt, float currentPhase, float nextPhase)
@ MainTriggerCallback
void onTriggerEventSparkLogic(float rpm, efitick_t edgeTimestamp, float currentPhase, float nextPhase)

Referenced by TriggerCentral::handleShaftSignal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ turnInjectionPinLow()

void turnInjectionPinLow ( InjectionEvent event)

Definition at line 55 of file main_trigger_callback.cpp.

55 {
56 efitick_t nowNt = getTimeNowNt();
57
58 for (size_t i = 0; i < efi::size(event->outputs); i++) {
59 InjectorOutputPin *output = event->outputs[i];
60 if (output) {
61 output->close(nowNt);
62 }
63 }
64 event->update();
65}
InjectorOutputPin * outputs[MAX_WIRES_COUNT]
void close(efitick_t nowNt)
efitick_t getTimeNowNt()
Definition efitime.cpp:19
Here is the call graph for this function:

◆ turnInjectionPinLowStage2()

static void turnInjectionPinLowStage2 ( InjectionEvent event)
static

Definition at line 67 of file main_trigger_callback.cpp.

67 {
68 efitick_t nowNt = getTimeNowNt();
69
70 for (size_t i = 0; i < efi::size(event->outputsStage2); i++) {
71 InjectorOutputPin *output = event->outputsStage2[i];
72 if (output) {
73 output->close(nowNt);
74 }
75 }
76}
InjectorOutputPin * outputsStage2[MAX_WIRES_COUNT]
Here is the call graph for this function:

Variable Documentation

◆ printFuelDebug

bool printFuelDebug = false

Go to the source code of this file.