| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | ||||
| 3 | 2180 | bool isIgnVoltage() { | ||
| 4 | #if EFI_PROD_CODE | |||
| 5 | // Digital pin has priority over analog inputs | |||
| 6 | if (isBrainPinValid(engineConfiguration->ignitionKeyDigitalPin)) { | |||
| 7 | return efiReadPin(engineConfiguration->ignitionKeyDigitalPin, engineConfiguration->ignitionKeyDigitalPinMode); | |||
| 8 | } | |||
| 9 | #endif | |||
| 10 | ||||
| 11 | 2180 | float ignVoltage = 0; | ||
| 12 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2180 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 2180 times.
|
2180 | if (Sensor::hasSensor(SensorType::IgnKeyVoltage)) { |
| 13 | // If we have separate ignition sensing input | |||
| 14 | ✗ | ignVoltage = Sensor::getOrZero(SensorType::IgnKeyVoltage); | ||
| 15 | } else { | |||
| 16 | // No, we assume that ignition is ON while we are powered with resonable voltage | |||
| 17 | 2180 | ignVoltage = Sensor::getOrZero(SensorType::BatteryVoltage); | ||
| 18 | } | |||
| 19 | ||||
| 20 | 2180 | return (ignVoltage > 6.0f); | ||
| 21 | } | |||
| 22 | ||||
| 23 | 1086 | void IgnitionController::onSlowCallback() { | ||
| 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 |
1/1✓ Branch 2 taken 1086 times.
|
1086 | auto hasIgnVoltage = isIgnVoltage(); | |
| 27 | ||||
| 28 |
2/2✓ Branch 0 taken 85 times.
✓ Branch 1 taken 1001 times.
|
2/2✓ Decision 'true' taken 85 times.
✓ Decision 'false' taken 1001 times.
|
1086 | if (hasIgnVoltage) { |
| 29 |
1/1✓ Branch 1 taken 85 times.
|
85 | m_timeSinceIgnVoltage.reset(); | |
| 30 | } | |||
| 31 | ||||
| 32 |
2/2✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 1 time.
|
2/2✓ Decision 'true' taken 1085 times.
✓ Decision 'false' taken 1 time.
|
1086 | if (hasIgnVoltage == m_lastState) { |
| 33 | // nothing to do, states match | |||
| 34 | 1085 | 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 |
2/7✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 1 time.
|
1 | if (!hasIgnVoltage && secondsSinceIgnVoltage() < 0.2f) { |
| 40 | ✗ | return; | ||
| 41 | } | |||
| 42 | ||||
| 43 | // Store state and notify other modules of the change | |||
| 44 | 1 | m_lastState = hasIgnVoltage; | ||
| 45 | 31 | engine->engineModules.apply_all([&](auto& m) { m.onIgnitionStateChanged(hasIgnVoltage); }); | ||
| 46 | } | |||
| 47 |