rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Private Attributes
InjectorOutputPin Class Referencefinal

#include <injection_gpio.h>

Inheritance diagram for InjectorOutputPin:
Inheritance graph
[legend]
Collaboration diagram for InjectorOutputPin:
Collaboration graph
[legend]

Public Member Functions

 InjectorOutputPin ()
 
void reset ()
 
void open (efitick_t nowNt)
 
void close (efitick_t nowNt)
 
void setHigh () override
 
void setLow () override
 
int8_t getOverlappingCounter () const
 
- Public Member Functions inherited from NamedOutputPin
 NamedOutputPin ()
 
 NamedOutputPin (const char *name)
 
virtual void setHigh (const char *msg)
 
virtual void setLow (const char *msg)
 
const chargetName () const
 
void setName (const char *)
 
const chargetShortName () const
 
bool stop ()
 
- Public Member Functions inherited from OutputPin
void initPin (const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
 
void initPin (const char *msg, brain_pin_e brainPin)
 
void deInit ()
 
bool isInitialized () const
 
bool getAndSet (int logicValue)
 
void setValue (const char *msg, int logicValue, bool isForce=false)
 
TEST_VIRTUAL void setValue (int logicValue, bool isForce=false)
 
void toggle ()
 
bool getLogicValue () const
 
brain_pin_diag_e getDiag () const
 
void resetToggleStats ()
 

Data Fields

int8_t injectorIndex
 
- Data Fields inherited from NamedOutputPin
const charshortName = nullptr
 
- Data Fields inherited from OutputPin
ioportid_t m_port = 0
 
uint8_t m_pin = 0
 
int pinToggleCounter = 0
 
Timer pinToggleTimer
 
uint32_t durationsInStateMs [2]
 
brain_pin_e brainPin = Gpio::Unassigned
 
bool ext = false
 
int8_t currentLogicValue = INITIAL_PIN_STATE
 

Private Attributes

int8_t overlappingCounter
 

Detailed Description

Definition at line 12 of file injection_gpio.h.

Constructor & Destructor Documentation

◆ InjectorOutputPin()

InjectorOutputPin::InjectorOutputPin ( )

Definition at line 23 of file injection_gpio.cpp.

23 : NamedOutputPin() {
24 overlappingCounter = 1; // Force update in reset
25 reset();
26 injectorIndex = -1;
27}
Here is the call graph for this function:

Member Function Documentation

◆ close()

void InjectorOutputPin::close ( efitick_t  nowNt)

Definition at line 59 of file injection_gpio.cpp.

59 {
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}
void setLow() override
const char * getName() const
Definition efi_gpio.cpp:422
efitimeus_t getTimeNowUs()
Definition efitime.cpp:26
int time2print(int64_t time)
Definition efitime.h:22
bool printFuelDebug
void LogTriggerInjectorState(efitick_t timestamp, size_t index, bool state)
printf("\n")

Referenced by endSimultaneousInjectionOnlyTogglePins(), turnInjectionPinLow(), and turnInjectionPinLowStage2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOverlappingCounter()

int8_t InjectorOutputPin::getOverlappingCounter ( ) const
inline

Definition at line 22 of file injection_gpio.h.

22{ return overlappingCounter; }

◆ open()

void InjectorOutputPin::open ( efitick_t  nowNt)

Definition at line 29 of file injection_gpio.cpp.

29 {
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}
void setHigh() override
EngineState * getEngineState()
Definition engine.cpp:577

Referenced by startSimultaneousInjection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void InjectorOutputPin::reset ( )

Definition at line 490 of file efi_gpio.cpp.

490 {
491 // If this injector was open, close it and reset state
492 if (overlappingCounter != 0) {
494 setValue("reset", 0);
495 }
496
497 // todo: this could be refactored by calling some super-reset method
499}
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
int8_t currentLogicValue
Definition efi_output.h:93

Referenced by InjectorOutputPin(), and EnginePins::reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHigh()

void InjectorOutputPin::setHigh ( )
overridevirtual

Reimplemented from NamedOutputPin.

Definition at line 86 of file injection_gpio.cpp.

86 {
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}
virtual void setHigh()
Definition efi_gpio.cpp:438
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")
TunerStudioOutputChannels * getTunerStudioOutputChannels()
Definition engine.cpp:581

Referenced by open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLow()

void InjectorOutputPin::setLow ( )
overridevirtual

Reimplemented from NamedOutputPin.

Definition at line 112 of file injection_gpio.cpp.

112 {
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}
virtual void setLow()
Definition efi_gpio.cpp:460

Referenced by close(), and setPinConfigurationOverrides().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ injectorIndex

int8_t InjectorOutputPin::injectorIndex

Definition at line 25 of file injection_gpio.h.

Referenced by close(), EnginePins::EnginePins(), InjectorOutputPin(), open(), setHigh(), and setLow().

◆ overlappingCounter

int8_t InjectorOutputPin::overlappingCounter
private

Definition at line 28 of file injection_gpio.h.

Referenced by close(), getOverlappingCounter(), InjectorOutputPin(), open(), and reset().


The documentation for this class was generated from the following files: