rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
ignition_controller.cpp
Go to the documentation of this file.
1#include "pch.h"
2
4#if EFI_PROD_CODE
5 // Digital pin has priority over analog inputs
8 }
9#endif
10
11 float ignVoltage = 0;
13 // If we have separate ignition sensing input
15 } else {
16 // No, we assume that ignition is ON while we are powered with resonable voltage
18 }
19
20 return (ignVoltage > 6.0f);
21}
22
24 // default to 0 if failed sensor to prevent accidental ign-on if battery
25 // input misconfigured (or the ADC hasn't started yet)
26 auto hasIgnVoltage = isIgnVoltage();
27
28 if (hasIgnVoltage) {
30 }
31
32 if (hasIgnVoltage == m_lastState) {
33 // nothing to do, states match
34 return;
35 }
36
37 // Ignore low voltage transients - we may see this at the start of cranking
38 // and we don't want to
39 if (!hasIgnVoltage && secondsSinceIgnVoltage() < 0.2f) {
40 return;
41 }
42
43 // Store state and notify other modules of the change
44 m_lastState = hasIgnVoltage;
45 engine->engineModules.apply_all([&](auto& m) { m.onIgnitionStateChanged(hasIgnVoltage); });
46}
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
void onSlowCallback() override
virtual bool hasSensor() const
Definition sensor.h:141
static float getOrZero(SensorType type)
Definition sensor.h:83
static EngineAccessor engine
Definition engine.h:413
static constexpr engine_configuration_s * engineConfiguration
bool isIgnVoltage()
bool isIgnVoltage()
bool efiReadPin(brain_pin_e pin)
Definition io_pins.cpp:89
bool isBrainPinValid(brain_pin_e brainPin)