GCC Code Coverage Report


Directory: ./
File: firmware/controllers/system/injection_gpio.cpp
Date: 2025-11-16 14:52:24
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 819 void startSimultaneousInjection() {
10 819 efitick_t nowNt = getTimeNowNt();
11
2/2
✓ Branch 0 taken 3264 times.
✓ Branch 1 taken 819 times.
2/2
✓ Decision 'true' taken 3264 times.
✓ Decision 'false' taken 819 times.
4083 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
12 3264 enginePins.injectors[i].open(nowNt);
13 }
14 819 }
15
16 819 void endSimultaneousInjectionOnlyTogglePins() {
17 819 efitick_t nowNt = getTimeNowNt();
18
2/2
✓ Branch 0 taken 3264 times.
✓ Branch 1 taken 819 times.
2/2
✓ Decision 'true' taken 3264 times.
✓ Decision 'false' taken 819 times.
4083 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
19 3264 enginePins.injectors[i].close(nowNt);
20 }
21 819 }
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 3778 void InjectorOutputPin::open(efitick_t nowNt) {
30 // per-output counter for error detection
31 3778 overlappingCounter++;
32 // global counter for logging
33 3778 getEngineState()->fuelInjectionCounter++;
34
35 #if FUEL_MATH_EXTREME_LOGGING
36
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3778 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 3778 times.
3778 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 3766 times.
2/2
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 3766 times.
3778 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 3766 LogTriggerInjectorState(nowNt, injectorIndex, true);
54 #endif // EFI_TOOTH_LOGGER
55 3766 setHigh();
56 }
57 3778 }
58
59 3765 void InjectorOutputPin::close(efitick_t nowNt) {
60 #if FUEL_MATH_EXTREME_LOGGING
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3765 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 3765 times.
3765 if (printFuelDebug) {
62 printf("InjectorOutputPin::close %s %d %d\r\n", getName(), overlappingCounter, time2print(getTimeNowUs()));
63 }
64 #endif /* FUEL_MATH_EXTREME_LOGGING */
65
66 3765 overlappingCounter--;
67
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3753 times.
2/2
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 3753 times.
3765 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 3753 LogTriggerInjectorState(nowNt, injectorIndex, false);
76 #endif // EFI_TOOTH_LOGGER
77 3753 setLow();
78 }
79
80 // Don't allow negative overlap count
81
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3759 times.
2/2
✓ Decision 'true' taken 6 times.
✓ Decision 'false' taken 3759 times.
3765 if (overlappingCounter < 0) {
82 6 overlappingCounter = 0;
83 }
84 3765 }
85
86 3766 void InjectorOutputPin::setHigh() {
87 3766 NamedOutputPin::setHigh();
88 3766 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 943 times.
✓ Branch 1 taken 939 times.
✓ Branch 2 taken 868 times.
✓ Branch 3 taken 868 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 74 times.
✗ Branch 6 not taken.
3766 switch (injectorIndex) {
91
1/1
✓ Decision 'true' taken 943 times.
943 case 0:
92 943 state->injectorState1 = true;
93 943 break;
94
1/1
✓ Decision 'true' taken 939 times.
939 case 1:
95 939 state->injectorState2 = true;
96 939 break;
97
1/1
✓ Decision 'true' taken 868 times.
868 case 2:
98 868 state->injectorState3 = true;
99 868 break;
100
1/1
✓ Decision 'true' taken 868 times.
868 case 3:
101 868 state->injectorState4 = true;
102 868 break;
103
1/1
✓ Decision 'true' taken 74 times.
74 case 4:
104 74 state->injectorState5 = true;
105 74 break;
106
1/1
✓ Decision 'true' taken 74 times.
74 case 5:
107 74 state->injectorState6 = true;
108 74 break;
109 }
110 3766 }
111
112 3753 void InjectorOutputPin::setLow() {
113 3753 NamedOutputPin::setLow();
114 3753 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 940 times.
✓ Branch 1 taken 936 times.
✓ Branch 2 taken 865 times.
✓ Branch 3 taken 864 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 74 times.
✗ Branch 6 not taken.
3753 switch (injectorIndex) {
117
1/1
✓ Decision 'true' taken 940 times.
940 case 0:
118 940 state->injectorState1 = false;
119 940 break;
120
1/1
✓ Decision 'true' taken 936 times.
936 case 1:
121 936 state->injectorState2 = false;
122 936 break;
123
1/1
✓ Decision 'true' taken 865 times.
865 case 2:
124 865 state->injectorState3 = false;
125 865 break;
126
1/1
✓ Decision 'true' taken 864 times.
864 case 3:
127 864 state->injectorState4 = false;
128 864 break;
129
1/1
✓ Decision 'true' taken 74 times.
74 case 4:
130 74 state->injectorState5 = false;
131 74 break;
132
1/1
✓ Decision 'true' taken 74 times.
74 case 5:
133 74 state->injectorState6 = false;
134 74 break;
135 }
136 3753 }
137
138