GCC Code Coverage Report


Directory: ./
File: firmware/controllers/system/injection_gpio.cpp
Date: 2025-10-24 14:26:41
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 657 void startSimultaneousInjection() {
10 657 efitick_t nowNt = getTimeNowNt();
11
2/2
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 657 times.
2/2
✓ Decision 'true' taken 2474 times.
✓ Decision 'false' taken 657 times.
3131 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
12 2474 enginePins.injectors[i].open(nowNt);
13 }
14 657 }
15
16 657 void endSimultaneousInjectionOnlyTogglePins() {
17 657 efitick_t nowNt = getTimeNowNt();
18
2/2
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 657 times.
2/2
✓ Decision 'true' taken 2474 times.
✓ Decision 'false' taken 657 times.
3131 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
19 2474 enginePins.injectors[i].close(nowNt);
20 }
21 657 }
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 3365 void InjectorOutputPin::open(efitick_t nowNt) {
30 // per-output counter for error detection
31 3365 overlappingCounter++;
32 // global counter for logging
33 3365 getEngineState()->fuelInjectionCounter++;
34
35 #if FUEL_MATH_EXTREME_LOGGING
36
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3365 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 3365 times.
3365 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 3353 times.
2/2
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 3353 times.
3365 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 3353 LogTriggerInjectorState(nowNt, injectorIndex, true);
54 #endif // EFI_TOOTH_LOGGER
55 3353 setHigh();
56 }
57 3365 }
58
59 3351 void InjectorOutputPin::close(efitick_t nowNt) {
60 #if FUEL_MATH_EXTREME_LOGGING
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3351 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 3351 times.
3351 if (printFuelDebug) {
62 printf("InjectorOutputPin::close %s %d %d\r\n", getName(), overlappingCounter, time2print(getTimeNowUs()));
63 }
64 #endif /* FUEL_MATH_EXTREME_LOGGING */
65
66 3351 overlappingCounter--;
67
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3339 times.
2/2
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 3339 times.
3351 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 3339 LogTriggerInjectorState(nowNt, injectorIndex, false);
76 #endif // EFI_TOOTH_LOGGER
77 3339 setLow();
78 }
79
80 // Don't allow negative overlap count
81
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3345 times.
2/2
✓ Decision 'true' taken 6 times.
✓ Decision 'false' taken 3345 times.
3351 if (overlappingCounter < 0) {
82 6 overlappingCounter = 0;
83 }
84 3351 }
85
86 3353 void InjectorOutputPin::setHigh() {
87 3353 NamedOutputPin::setHigh();
88 3353 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 878 times.
✓ Branch 1 taken 874 times.
✓ Branch 2 taken 786 times.
✓ Branch 3 taken 787 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
3353 switch (injectorIndex) {
91
1/1
✓ Decision 'true' taken 878 times.
878 case 0:
92 878 state->injectorState1 = true;
93 878 break;
94
1/1
✓ Decision 'true' taken 874 times.
874 case 1:
95 874 state->injectorState2 = true;
96 874 break;
97
1/1
✓ Decision 'true' taken 786 times.
786 case 2:
98 786 state->injectorState3 = true;
99 786 break;
100
1/1
✓ Decision 'true' taken 787 times.
787 case 3:
101 787 state->injectorState4 = true;
102 787 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 3353 }
111
112 3339 void InjectorOutputPin::setLow() {
113 3339 NamedOutputPin::setLow();
114 3339 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 875 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 783 times.
✓ Branch 3 taken 783 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
3339 switch (injectorIndex) {
117
1/1
✓ Decision 'true' taken 875 times.
875 case 0:
118 875 state->injectorState1 = false;
119 875 break;
120
1/1
✓ Decision 'true' taken 870 times.
870 case 1:
121 870 state->injectorState2 = false;
122 870 break;
123
1/1
✓ Decision 'true' taken 783 times.
783 case 2:
124 783 state->injectorState3 = false;
125 783 break;
126
1/1
✓ Decision 'true' taken 783 times.
783 case 3:
127 783 state->injectorState4 = false;
128 783 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 3339 }
137
138