GCC Code Coverage Report


Directory: ./
File: firmware/controllers/ignition_controller.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 95.7% 44 0 46
Functions: 100.0% 33 0 33
Branches: 60.0% 9 0 15
Decisions: 75.0% 6 - 8

Line Branch Decision Exec Source
1 #include "pch.h"
2
3 2178 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 2178 float ignVoltage = 0;
12
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2178 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 2178 times.
2178 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 2178 ignVoltage = Sensor::getOrZero(SensorType::BatteryVoltage);
18 }
19
20 2178 return (ignVoltage > 6.0f);
21 }
22
23 1085 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 1085 times.
1085 auto hasIgnVoltage = isIgnVoltage();
27
28
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 1000 times.
2/2
✓ Decision 'true' taken 85 times.
✓ Decision 'false' taken 1000 times.
1085 if (hasIgnVoltage) {
29
1/1
✓ Branch 1 taken 85 times.
85 m_timeSinceIgnVoltage.reset();
30 }
31
32
2/2
✓ Branch 0 taken 1084 times.
✓ Branch 1 taken 1 time.
2/2
✓ Decision 'true' taken 1084 times.
✓ Decision 'false' taken 1 time.
1085 if (hasIgnVoltage == m_lastState) {
33 // nothing to do, states match
34 1084 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