GCC Code Coverage Report


Directory: ./
File: firmware/controllers/system/efi_gpio.h
Date: 2025-10-24 15:43:41
Coverage Exec Excl Total
Lines: 0.0% 0 0 2
Functions: 0.0% 0 0 1
Branches: -% 0 0 0
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 /**
2 * @file efi_gpio.h
3 * @brief EFI-related GPIO code
4 *
5 *
6 * @date Sep 26, 2014
7 * @author Andrey Belomutskiy, (c) 2012-2020
8 */
9
10 #pragma once
11
12 #include "global.h"
13 #include "io_pins.h"
14 #include "engine_configuration.h"
15 #include "injection_gpio.h"
16
17 void initPrimaryPins();
18 void initMiscOutputPins();
19
20 #if EFI_GPIO_HARDWARE
21 void turnAllPinsOff();
22 #else /* EFI_GPIO_HARDWARE */
23 #define turnAllPinsOff() {}
24 #endif /* EFI_GPIO_HARDWARE */
25
26 class IgnitionOutputPin : public NamedOutputPin {
27 public:
28 IgnitionOutputPin();
29 void setHigh() override;
30 void setLow() override;
31 void reset();
32 // 6000 RPM is 100Hz we can fit a few years worth of sparks into 32 bits, right?
33 // 2_000_000_000 / 100 = 20_000_000 seconds = 231 days?
34 // [tag:duration_limit]
35 int signalFallSparkId;
36 int8_t coilIndex;
37 };
38
39 /**
40 * OutputPin with semi-automated init/deinit on configuration change
41 */
42 class RegisteredOutputPin : public virtual OutputPin {
43 public:
44 RegisteredOutputPin(const char *registrationName, size_t pinOffset, size_t pinModeOffset);
45 RegisteredOutputPin(const char *registrationName, size_t pinOffset);
46 void init();
47 void unregister();
48 RegisteredOutputPin* const next;
49 const char* getRegistrationName() const {
50 return registrationName;
51 }
52 private:
53 const char* const registrationName;
54 const uint16_t m_pinOffset;
55 const bool m_hasPinMode;
56 const uint16_t m_pinModeOffset;
57 bool isPinConfigurationChanged();
58 };
59
60 class RegisteredNamedOutputPin : public RegisteredOutputPin, public NamedOutputPin {
61 public:
62 RegisteredNamedOutputPin(const char* name, size_t pinOffset, size_t pinModeOffset);
63 RegisteredNamedOutputPin(const char* name, size_t pinOffset);
64 };
65
66 class EnginePins {
67 public:
68 EnginePins();
69 void startPins();
70 void reset();
71 static void debug();
72 bool stopPins();
73 void unregisterPins();
74 OutputPin *getOutputPinForBenchMode(bench_mode_e idx);
75
76 RegisteredOutputPin mainRelay;
77 /**
78 * High Pressure Fuel Pump valve control
79 */
80 RegisteredNamedOutputPin hpfpValve;
81 // this one cranks engine
82 RegisteredOutputPin starterControl;
83 // this one prevents driver from cranking engine
84 RegisteredOutputPin starterRelayDisable;
85
86 RegisteredOutputPin fanRelay;
87 RegisteredOutputPin fanRelay2;
88
89 // see acRelayPin
90 RegisteredOutputPin acRelay;
91 RegisteredOutputPin fuelPumpRelay;
92 RegisteredOutputPin nitrousRelay;
93 RegisteredOutputPin vvlRelay;
94 #if EFI_HD_ACR
95 RegisteredNamedOutputPin harleyAcr;
96 RegisteredOutputPin harleyAcr2;
97 #endif // EFI_HD_ACR
98 // todo: shall we rename this to narrowBandO2heater or even remove the whole questionable feature?
99 OutputPin o2heater;
100 OutputPin luaOutputPins[LUA_PWM_COUNT];
101
102 /**
103 * brain board RED LED by default
104 */
105 OutputPin errorLedPin;
106 OutputPin communicationLedPin; // blue LED on brain board by default
107 OutputPin warningLedPin; // orange LED on brain board by default
108 OutputPin runningLedPin; // green LED on brain board by default
109
110 OutputPin debugTriggerSync;
111 RegisteredOutputPin boostPin;
112 RegisteredOutputPin idleSolenoidPin;
113 RegisteredOutputPin secondIdleSolenoidPin;
114 RegisteredOutputPin alternatorPin;
115 /**
116 * this one is usually on the gauge cluster, not on the ECU
117 */
118 RegisteredOutputPin checkEnginePin;
119
120 RegisteredOutputPin tachOut;
121 RegisteredOutputPin triggerDecoderErrorPin;
122 RegisteredOutputPin speedoOut;
123
124 OutputPin sdCsPin;
125 OutputPin accelerometerCs;
126
127 InjectorOutputPin injectors[MAX_CYLINDER_COUNT];
128 InjectorOutputPin injectorsStage2[MAX_CYLINDER_COUNT];
129 IgnitionOutputPin coils[MAX_CYLINDER_COUNT];
130 IgnitionOutputPin trailingCoils[MAX_CYLINDER_COUNT];
131 NamedOutputPin auxValve[AUX_DIGITAL_VALVE_COUNT];
132 OutputPin tcuSolenoids[TCU_SOLENOID_COUNT];
133 OutputPin tcuTccOnoffSolenoid;
134 OutputPin tcuTccPwmSolenoid;
135 OutputPin tcuPcSolenoid;
136 OutputPin tcu32Solenoid;
137
138 #ifdef EFI_UNIT_TEST
139 void resetForUnitTest();
140 #endif
141
142 private:
143 void startInjectionPins();
144 void startIgnitionPins();
145 void startAuxValves();
146
147 void stopInjectionPins();
148 void stopIgnitionPins();
149 void stopAuxValves();
150 };
151
152 /**
153 * it's a macro to be sure that stack is not used
154 * @return 0 for OM_DEFAULT and OM_OPENDRAIN
155 */
156
157 #define getElectricalValue0(mode) ((mode) == OM_INVERTED || (mode) == OM_OPENDRAIN_INVERTED)
158
159 /**
160 * it's a macro to be sure that stack is not used
161 * @return 1 for OM_DEFAULT and OM_OPENDRAIN
162 */
163 #define getElectricalValue1(mode) ((mode) == OM_DEFAULT || (mode) == OM_OPENDRAIN)
164
165 #define getElectricalValue(logicalValue, mode) \
166 (logicalValue ? getElectricalValue1(mode) : getElectricalValue0(mode))
167
168 #if EFI_GPIO_HARDWARE
169
170 ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin);
171 ioportid_t getHwPort(const char *msg, brain_pin_e brainPin);
172 /* Should return valid pointer in any case, not null, return "unknown" if argument is invalid */
173 const char *portname(ioportid_t GPIOx);
174
175 #endif /* EFI_GPIO_HARDWARE */
176
177 brain_pin_e parseBrainPin(const char *str);
178
179 extern EnginePins enginePins;
180
181 #ifndef LED_PIN_MODE
182 #define LED_PIN_MODE OM_DEFAULT
183 #endif /* LED_PIN_MODE */
184