rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
injection_gpio.cpp
Go to the documentation of this file.
1/*
2 * injection_gpio.cpp
3 */
4
5#include "pch.h"
6
7extern bool printFuelDebug;
8
10 efitick_t nowNt = getTimeNowNt();
11 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
12 enginePins.injectors[i].open(nowNt);
13 }
14}
15
17 efitick_t nowNt = getTimeNowNt();
18 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
19 enginePins.injectors[i].close(nowNt);
20 }
21}
22
24 overlappingCounter = 1; // Force update in reset
25 reset();
26 injectorIndex = -1;
27}
28
29void InjectorOutputPin::open(efitick_t nowNt) {
30 // per-output counter for error detection
32 // global counter for logging
34
35#if FUEL_MATH_EXTREME_LOGGING
36 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 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 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
54#endif // EFI_TOOTH_LOGGER
55 setHigh();
56 }
57}
58
59void InjectorOutputPin::close(efitick_t nowNt) {
60#if FUEL_MATH_EXTREME_LOGGING
61 if (printFuelDebug) {
62 printf("InjectorOutputPin::close %s %d %d\r\n", getName(), overlappingCounter, time2print(getTimeNowUs()));
63 }
64#endif /* FUEL_MATH_EXTREME_LOGGING */
65
67 if (overlappingCounter > 0) {
68#if FUEL_MATH_EXTREME_LOGGING
69 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
76#endif // EFI_TOOTH_LOGGER
77 setLow();
78 }
79
80 // Don't allow negative overlap count
81 if (overlappingCounter < 0) {
83 }
84}
85
89 // this is NASTY but what's the better option? bytes? At cost of 22 extra bytes in output status packet?
90 switch (injectorIndex) {
91 case 0:
92 state->injectorState1 = true;
93 break;
94 case 1:
95 state->injectorState2 = true;
96 break;
97 case 2:
98 state->injectorState3 = true;
99 break;
100 case 3:
101 state->injectorState4 = true;
102 break;
103 case 4:
104 state->injectorState5 = true;
105 break;
106 case 5:
107 state->injectorState6 = true;
108 break;
109 }
110}
111
115 // this is NASTY but what's the better option? bytes? At cost of 22 extra bytes in output status packet?
116 switch (injectorIndex) {
117 case 0:
118 state->injectorState1 = false;
119 break;
120 case 1:
121 state->injectorState2 = false;
122 break;
123 case 2:
124 state->injectorState3 = false;
125 break;
126 case 3:
127 state->injectorState4 = false;
128 break;
129 case 4:
130 state->injectorState5 = false;
131 break;
132 case 5:
133 state->injectorState6 = false;
134 break;
135 }
136}
137
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:127
void open(efitick_t nowNt)
void close(efitick_t nowNt)
void setHigh() override
void setLow() override
const char * getName() const
Definition efi_gpio.cpp:422
virtual void setLow()
Definition efi_gpio.cpp:460
virtual void setHigh()
Definition efi_gpio.cpp:438
EnginePins enginePins
Definition efi_gpio.cpp:24
efitick_t getTimeNowNt()
Definition efitime.cpp:19
efitimeus_t getTimeNowUs()
Definition efitime.cpp:26
int time2print(int64_t time)
Definition efitime.h:22
EngineState * getEngineState()
Definition engine.cpp:577
static constexpr engine_configuration_s * engineConfiguration
void startSimultaneousInjection()
bool printFuelDebug
void endSimultaneousInjectionOnlyTogglePins()
bool printFuelDebug
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")
void LogTriggerInjectorState(efitick_t timestamp, size_t index, bool state)
TunerStudioOutputChannels * getTunerStudioOutputChannels()
Definition engine.cpp:581
printf("\n")