GCC Code Coverage Report


Directory: ./
File: firmware/controllers/system/injection_gpio.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 95.2% 80 0 84
Functions: 100.0% 7 0 7
Branches: 81.2% 26 0 32
Decisions: 86.7% 26 - 30

Line Branch Decision Exec Source
1 /*
2 * injection_gpio.cpp
3 */
4
5 #include "pch.h"
6
7 extern bool printFuelDebug;
8
9 659 void startSimultaneousInjection() {
10 659 efitick_t nowNt = getTimeNowNt();
11
2/2
✓ Branch 0 taken 2482 times.
✓ Branch 1 taken 659 times.
2/2
✓ Decision 'true' taken 2482 times.
✓ Decision 'false' taken 659 times.
3141 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
12 2482 enginePins.injectors[i].open(nowNt);
13 }
14 659 }
15
16 659 void endSimultaneousInjectionOnlyTogglePins() {
17 659 efitick_t nowNt = getTimeNowNt();
18
2/2
✓ Branch 0 taken 2482 times.
✓ Branch 1 taken 659 times.
2/2
✓ Decision 'true' taken 2482 times.
✓ Decision 'false' taken 659 times.
3141 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
19 2482 enginePins.injectors[i].close(nowNt);
20 }
21 659 }
22
23 29 InjectorOutputPin::InjectorOutputPin() : NamedOutputPin() {
24 29 overlappingCounter = 1; // Force update in reset
25 29 reset();
26 29 injectorIndex = -1;
27 29 }
28
29 3373 void InjectorOutputPin::open(efitick_t nowNt) {
30 // per-output counter for error detection
31 3373 overlappingCounter++;
32 // global counter for logging
33 3373 getEngineState()->fuelInjectionCounter++;
34
35 #if FUEL_MATH_EXTREME_LOGGING
36
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3373 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 3373 times.
3373 if (printFuelDebug) {
37 printf("InjectorOutputPin::open %s %d now=%0.1fms\r\n", getName(), overlappingCounter, time2print(getTimeNowUs()) / 1000.0);
38 }
39 #endif /* FUEL_MATH_EXTREME_LOGGING */
40
41
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3361 times.
2/2
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 3361 times.
3373 if (overlappingCounter > 1) {
42 // /**
43 // * #299
44 // * this is another kind of overlap which happens in case of a small duty cycle after a large duty cycle
45 // */
46 #if FUEL_MATH_EXTREME_LOGGING
47
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 12 times.
12 if (printFuelDebug) {
48 printf("overlapping, no need to touch pin %s %d\r\n", getName(), time2print(getTimeNowUs()));
49 }
50 #endif /* FUEL_MATH_EXTREME_LOGGING */
51 } else {
52 #if EFI_TOOTH_LOGGER
53 3361 LogTriggerInjectorState(nowNt, injectorIndex, true);
54 #endif // EFI_TOOTH_LOGGER
55 3361 setHigh();
56 }
57 3373 }
58
59 3359 void InjectorOutputPin::close(efitick_t nowNt) {
60 #if FUEL_MATH_EXTREME_LOGGING
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3359 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 3359 times.
3359 if (printFuelDebug) {
62 printf("InjectorOutputPin::close %s %d %d\r\n", getName(), overlappingCounter, time2print(getTimeNowUs()));
63 }
64 #endif /* FUEL_MATH_EXTREME_LOGGING */
65
66 3359 overlappingCounter--;
67
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3347 times.
2/2
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 3347 times.
3359 if (overlappingCounter > 0) {
68 #if FUEL_MATH_EXTREME_LOGGING
69
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 12 times.
12 if (printFuelDebug) {
70 printf("was overlapping, no need to touch pin %s %d\r\n", getName(), time2print(getTimeNowUs()));
71 }
72 #endif /* FUEL_MATH_EXTREME_LOGGING */
73 } else {
74 #if EFI_TOOTH_LOGGER
75 3347 LogTriggerInjectorState(nowNt, injectorIndex, false);
76 #endif // EFI_TOOTH_LOGGER
77 3347 setLow();
78 }
79
80 // Don't allow negative overlap count
81
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3353 times.
2/2
✓ Decision 'true' taken 6 times.
✓ Decision 'false' taken 3353 times.
3359 if (overlappingCounter < 0) {
82 6 overlappingCounter = 0;
83 }
84 3359 }
85
86 3361 void InjectorOutputPin::setHigh() {
87 3361 NamedOutputPin::setHigh();
88 3361 TunerStudioOutputChannels *state = getTunerStudioOutputChannels();
89 // this is NASTY but what's the better option? bytes? At cost of 22 extra bytes in output status packet?
90
6/7
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 788 times.
✓ Branch 3 taken 789 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
3361 switch (injectorIndex) {
91
1/1
✓ Decision 'true' taken 880 times.
880 case 0:
92 880 state->injectorState1 = true;
93 880 break;
94
1/1
✓ Decision 'true' taken 876 times.
876 case 1:
95 876 state->injectorState2 = true;
96 876 break;
97
1/1
✓ Decision 'true' taken 788 times.
788 case 2:
98 788 state->injectorState3 = true;
99 788 break;
100
1/1
✓ Decision 'true' taken 789 times.
789 case 3:
101 789 state->injectorState4 = true;
102 789 break;
103
1/1
✓ Decision 'true' taken 14 times.
14 case 4:
104 14 state->injectorState5 = true;
105 14 break;
106
1/1
✓ Decision 'true' taken 14 times.
14 case 5:
107 14 state->injectorState6 = true;
108 14 break;
109 }
110 3361 }
111
112 3347 void InjectorOutputPin::setLow() {
113 3347 NamedOutputPin::setLow();
114 3347 TunerStudioOutputChannels *state = getTunerStudioOutputChannels();
115 // this is NASTY but what's the better option? bytes? At cost of 22 extra bytes in output status packet?
116
6/7
✓ Branch 0 taken 877 times.
✓ Branch 1 taken 872 times.
✓ Branch 2 taken 785 times.
✓ Branch 3 taken 785 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
3347 switch (injectorIndex) {
117
1/1
✓ Decision 'true' taken 877 times.
877 case 0:
118 877 state->injectorState1 = false;
119 877 break;
120
1/1
✓ Decision 'true' taken 872 times.
872 case 1:
121 872 state->injectorState2 = false;
122 872 break;
123
1/1
✓ Decision 'true' taken 785 times.
785 case 2:
124 785 state->injectorState3 = false;
125 785 break;
126
1/1
✓ Decision 'true' taken 785 times.
785 case 3:
127 785 state->injectorState4 = false;
128 785 break;
129
1/1
✓ Decision 'true' taken 14 times.
14 case 4:
130 14 state->injectorState5 = false;
131 14 break;
132
1/1
✓ Decision 'true' taken 14 times.
14 case 5:
133 14 state->injectorState6 = false;
134 14 break;
135 }
136 3347 }
137
138