rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Enumerations | Functions | Variables
trigger_input.cpp File Reference

Enumerations

enum  triggerType { TRIGGER_NONE , TRIGGER_EXTI , TRIGGER_ADC }
 

Functions

int extiTriggerTurnOnInputPin (const char *msg, int index, bool isTriggerShaft)
 
void extiTriggerTurnOffInputPin (brain_pin_e brainPin)
 
void adcTriggerTurnOnInputPins ()
 
int adcTriggerTurnOnInputPin (const char *msg, int index, bool isTriggerShaft)
 
void adcTriggerTurnOffInputPin (brain_pin_e brainPin)
 
static int turnOnTriggerInputPin (const char *msg, int index, bool isTriggerShaft)
 
static void turnOffTriggerInputPin (int index, bool isTriggerShaft)
 
void stopTriggerInputPins ()
 
void startTriggerInputPins ()
 
void onEcuStartTriggerImplementation ()
 
void onEcuStartDoSomethingTriggerInputPins ()
 

Variables

static triggerType shaftTriggerType [TRIGGER_INPUT_PIN_COUNT]
 
static triggerType camTriggerType [CAM_INPUTS_COUNT]
 
static const char *const camNames [] = { "cam1", "cam2", "cam3", "cam4"}
 

Enumeration Type Documentation

◆ triggerType

Enumerator
TRIGGER_NONE 
TRIGGER_EXTI 
TRIGGER_ADC 

Definition at line 49 of file trigger_input.cpp.

49 {
53};
@ TRIGGER_EXTI
@ TRIGGER_ADC
@ TRIGGER_NONE

Function Documentation

◆ adcTriggerTurnOffInputPin()

void adcTriggerTurnOffInputPin ( brain_pin_e  brainPin)

Definition at line 143 of file trigger_input_adc.cpp.

143 {
144 efiExtiDisablePin(brainPin);
145}
void efiExtiDisablePin(brain_pin_e brainPin)

Referenced by turnOffTriggerInputPin().

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

◆ adcTriggerTurnOnInputPin()

int adcTriggerTurnOnInputPin ( const char msg,
int  index,
bool  isTriggerShaft 
)

Definition at line 39 of file trigger_input.cpp.

39 {
40 UNUSED(msg);
41 UNUSED(index);
42 UNUSED(isTriggerShaft);
43
44 return -2;
45 }
UNUSED(samplingTimeSeconds)

Referenced by turnOnTriggerInputPin().

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

◆ adcTriggerTurnOnInputPins()

void adcTriggerTurnOnInputPins ( )

Definition at line 147 of file trigger_input_adc.cpp.

147 {
148}

◆ extiTriggerTurnOffInputPin()

void extiTriggerTurnOffInputPin ( brain_pin_e  brainPin)

Definition at line 75 of file trigger_input_exti.cpp.

75 {
76 efiExtiDisablePin(brainPin);
77}

Referenced by turnOffTriggerInputPin().

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

◆ extiTriggerTurnOnInputPin()

int extiTriggerTurnOnInputPin ( const char msg,
int  index,
bool  isTriggerShaft 
)

Definition at line 23 of file trigger_input.cpp.

23 {
24 UNUSED(msg);
25 UNUSED(index);
26 UNUSED(isTriggerShaft);
27
28 return -2;
29 }

Referenced by turnOnTriggerInputPin().

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

◆ onEcuStartDoSomethingTriggerInputPins()

void onEcuStartDoSomethingTriggerInputPins ( )

Definition at line 167 of file trigger_input.cpp.

167 {
168 if (hasFirmwareError()) {
169 return;
170 }
171
172#if EFI_PROD_CODE && EFI_SHAFT_POSITION_INPUT
174 // todo: we have another 'rpmCalculator.Register' for UNIT_TEST would be great to unify
176 } else {
177 // if we do not have primary input channel maybe it's BCM mode and we inject RPM value via Lua?
179 }
180#endif /* EFI_PROD_CODE && EFI_SHAFT_POSITION_INPUT */
181}
RpmCalculator rpmCalculator
Definition engine.h:306
bool Register()
Definition sensor.cpp:131
void unregister()
Definition sensor.cpp:135
static EngineAccessor engine
Definition engine.h:413
static constexpr engine_configuration_s * engineConfiguration
bool isBrainPinValid(brain_pin_e brainPin)
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]

Referenced by initHardware().

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

◆ onEcuStartTriggerImplementation()

void onEcuStartTriggerImplementation ( )

Definition at line 160 of file trigger_input.cpp.

160 {
161}

Referenced by initHardware().

Here is the caller graph for this function:

◆ startTriggerInputPins()

void startTriggerInputPins ( )

Definition at line 145 of file trigger_input.cpp.

145 {
146 for (int i = 0; i < TRIGGER_INPUT_PIN_COUNT; i++) {
147 if (isConfigurationChanged(triggerInputPins[i])) {
148 const char * msg = (i == 0 ? "Trigger #1" : "Trigger #2");
149 turnOnTriggerInputPin(msg, i, /*isTriggerShaft*/true);
150 }
151 }
152
153 for (int i = 0; i < CAM_INPUTS_COUNT; i++) {
154 if (isConfigurationChanged(camInputs[i])) {
155 turnOnTriggerInputPin(camNames[i], i, /*isTriggerShaft*/false);
156 }
157 }
158}
static const char *const camNames[]
static int turnOnTriggerInputPin(const char *msg, int index, bool isTriggerShaft)

Referenced by startHardware().

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

◆ stopTriggerInputPins()

void stopTriggerInputPins ( )

Definition at line 130 of file trigger_input.cpp.

130 {
131 for (int i = 0; i < TRIGGER_INPUT_PIN_COUNT; i++) {
132 if (isConfigurationChanged(triggerInputPins[i])) {
133 turnOffTriggerInputPin(i, /*isTriggerShaft*/true);
134 }
135 }
136 for (int i = 0; i < CAM_INPUTS_COUNT; i++) {
137 if (isConfigurationChanged(camInputs[i])) {
138 turnOffTriggerInputPin(i, /*isTriggerShaft*/false);
139 }
140 }
141}
static void turnOffTriggerInputPin(int index, bool isTriggerShaft)

Referenced by applyNewHardwareSettings().

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

◆ turnOffTriggerInputPin()

static void turnOffTriggerInputPin ( int  index,
bool  isTriggerShaft 
)
static

Definition at line 99 of file trigger_input.cpp.

99 {
100 brain_pin_e brainPin = isTriggerShaft ?
102
103 if (isTriggerShaft) {
104 if (shaftTriggerType[index] == TRIGGER_ADC) {
106 }
107
108 if (shaftTriggerType[index] == TRIGGER_EXTI) {
110 }
111
113 } else {
114 if (camTriggerType[index] == TRIGGER_ADC) {
116 }
117
118 if (camTriggerType[index] == TRIGGER_EXTI) {
120 }
121
123 }
124}
engine_configuration_s & activeConfiguration
void adcTriggerTurnOffInputPin(brain_pin_e brainPin)
void extiTriggerTurnOffInputPin(brain_pin_e brainPin)
static triggerType shaftTriggerType[TRIGGER_INPUT_PIN_COUNT]
static triggerType camTriggerType[CAM_INPUTS_COUNT]

Referenced by stopTriggerInputPins().

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

◆ turnOnTriggerInputPin()

static int turnOnTriggerInputPin ( const char msg,
int  index,
bool  isTriggerShaft 
)
static

Definition at line 58 of file trigger_input.cpp.

58 {
59 brain_pin_e brainPin = isTriggerShaft ?
61
62 if (isTriggerShaft) {
64 } else {
66 }
67
68 if (!isBrainPinValid(brainPin)) {
69 return 0;
70 }
71
72 /* ... then ADC */
73#if HAL_TRIGGER_USE_ADC
74 if (adcTriggerTurnOnInputPin(msg, index, isTriggerShaft) >= 0) {
75 if (isTriggerShaft) {
77 } else {
79 }
80 return 0;
81 }
82#endif
83
84 /* ... then EXTI */
85 if (extiTriggerTurnOnInputPin(msg, index, isTriggerShaft) >= 0) {
86 if (isTriggerShaft) {
88 } else {
90 }
91 return 0;
92 }
93
94 firmwareError(ObdCode::CUSTOM_ERR_NOT_INPUT_PIN, "%s: Not input pin %s", msg, hwPortname(brainPin));
95
96 return -1;
97}
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_NOT_INPUT_PIN
const char * hwPortname(brain_pin_e brainPin)
int adcTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft)
int extiTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft)

Referenced by startTriggerInputPins().

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

Variable Documentation

◆ camNames

const char* const camNames[] = { "cam1", "cam2", "cam3", "cam4"}
static

Definition at line 143 of file trigger_input.cpp.

143{ "cam1", "cam2", "cam3", "cam4"};

Referenced by startTriggerInputPins().

◆ camTriggerType

triggerType camTriggerType[CAM_INPUTS_COUNT]
static

Definition at line 56 of file trigger_input.cpp.

Referenced by turnOffTriggerInputPin(), and turnOnTriggerInputPin().

◆ shaftTriggerType

triggerType shaftTriggerType[TRIGGER_INPUT_PIN_COUNT]
static

Definition at line 55 of file trigger_input.cpp.

Referenced by turnOffTriggerInputPin(), and turnOnTriggerInputPin().

Go to the source code of this file.