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

Detailed Description

Position sensor hardware layer.

Date
Dec 30, 2012
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file trigger_input.h.

Typedefs

typedef adcsample_t triggerAdcSample_t
 

Enumerations

enum  triggerAdcMode_t { TRIGGER_ADC_NONE = 0 , TRIGGER_ADC_ADC , TRIGGER_ADC_EXTI }
 

Functions

void onEcuStartTriggerImplementation ()
 
void onEcuStartDoSomethingTriggerInputPins ()
 
void startTriggerInputPins ()
 
void stopTriggerInputPins ()
 
adc_channel_e getAdcChannelForTrigger (void)
 
void addAdcChannelForTrigger (void)
 
void triggerAdcCallback (triggerAdcSample_t value)
 
void setTriggerAdcMode (triggerAdcMode_t adcMode)
 
void onTriggerChanged (efitick_t stamp, bool isPrimary, bool isRising)
 

Typedef Documentation

◆ triggerAdcSample_t

typedef uint16_t triggerAdcSample_t

Definition at line 21 of file trigger_input.h.

Enumeration Type Documentation

◆ triggerAdcMode_t

Enumerator
TRIGGER_ADC_NONE 
TRIGGER_ADC_ADC 
TRIGGER_ADC_EXTI 

Definition at line 27 of file trigger_input.h.

27 {
31};
@ TRIGGER_ADC_NONE
@ TRIGGER_ADC_ADC
@ TRIGGER_ADC_EXTI

Function Documentation

◆ addAdcChannelForTrigger()

void addAdcChannelForTrigger ( void  )

Definition at line 158 of file trigger_input_adc.cpp.

158 {
161 addFastAdcChannel("TRIG", channel);
162 }
163}
void addFastAdcChannel(const char *, adc_channel_e hwChannel)
bool isAdcChannelValid(adc_channel_e hwChannel)
Definition adc_inputs.h:23
uint16_t channel
Definition adc_inputs.h:104
adc_channel_e getAdcChannelForTrigger(void)

Referenced by setAdcChannelOverrides().

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

◆ getAdcChannelForTrigger()

adc_channel_e getAdcChannelForTrigger ( void  )

Definition at line 150 of file trigger_input_adc.cpp.

150 {
151 // todo: add other trigger or cam channels?
153 if (!isBrainPinValid(brainPin))
154 return EFI_ADC_NONE;
155 return getAdcChannel(brainPin);
156}
adc_channel_e getAdcChannel(brain_pin_e pin)
static constexpr engine_configuration_s * engineConfiguration
bool isBrainPinValid(brain_pin_e brainPin)
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]

Referenced by addAdcChannelForTrigger(), and calcFastAdcIndexes().

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

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:

◆ onTriggerChanged()

void onTriggerChanged ( efitick_t  stamp,
bool  isPrimary,
bool  isRising 
)

Definition at line 165 of file trigger_input_adc.cpp.

165 {
166#ifdef TRIGGER_ADC_DEBUG_LED
167 toggleLed(0, 0);
168#endif /* TRIGGER_ADC_DEBUG_LED */
169
170#if 1
171 // todo: support for 3rd trigger input channel
172 // todo: start using real event time from HW event, not just software timer?
173
174 // call the main trigger handler
175 hwHandleShaftSignal(isPrimary ? 0 : 1, isRising, stamp);
176#endif // 1
177}
void hwHandleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp)
void toggleLed(int led, int mode)

Referenced by TriggerAdcDetector::analogCallback(), and TriggerAdcDetector::digitalCallback().

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

◆ setTriggerAdcMode()

void setTriggerAdcMode ( triggerAdcMode_t  adcMode)

Definition at line 72 of file trigger_input_adc.cpp.

72 {
73 trigAdcState.curAdcMode = adcMode;
75
76 palSetPadMode(triggerInputPort, triggerInputPin,
77 (adcMode == TRIGGER_ADC_ADC) ? PAL_MODE_INPUT_ANALOG : PAL_MODE_EXTINT);
78}
triggerAdcMode_t curAdcMode
TriggerAdcDetector trigAdcState
static ioportmask_t triggerInputPin
static ioportid_t triggerInputPort

Referenced by adcTriggerTurnOnInputPin(), TriggerAdcDetector::analogCallback(), and TriggerAdcDetector::digitalCallback().

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:

◆ triggerAdcCallback()

void triggerAdcCallback ( triggerAdcSample_t  value)

Definition at line 92 of file trigger_input_adc.cpp.

92 {
93 efitick_t stamp = getTimeNowNt();
94 trigAdcState.analogCallback(stamp, value);
95}
void analogCallback(efitick_t stamp, triggerAdcSample_t value)
efitick_t getTimeNowNt()
Definition efitime.cpp:19

Referenced by onFastAdcComplete().

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

Go to the source code of this file.