GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
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

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