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

Typedefs

using ExtiCallback = void(*)(void *, efitick_t)
 

Functions

void efiExtiInit ()
 
int efiExtiEnablePin (const char *msg, brain_pin_e pin, uint32_t mode, ExtiCallback cb, void *cb_data)
 
void efiExtiDisablePin (brain_pin_e brainPin)
 
uint8_t getExtiOverflowCounter ()
 

Typedef Documentation

◆ ExtiCallback

using ExtiCallback = void(*)(void*, efitick_t)

Definition at line 12 of file digital_input_exti.h.

Function Documentation

◆ efiExtiDisablePin()

void efiExtiDisablePin ( brain_pin_e  brainPin)

Definition at line 78 of file digital_input_exti.cpp.

79{
80 /* paranoid check, in case of Gpio::Unassigned getHwPort will return NULL
81 * and we will fail on next check */
82 if (!isBrainPinValid(brainPin))
83 return;
84
85 ioportid_t port = getHwPort("exti", brainPin);
86 if (port == NULL)
87 return;
88 brain_pin_markUnused(brainPin);
89
90 int index = getHwPin("exti", brainPin);
91
92 auto& channel = channels[index];
93
94 /* is this index was used? */
95 if (!channel.Callback) {
96 return;
97 }
98
99 ioline_t line = PAL_LINE(port, index);
100 palDisableLineEvent(line);
101
102 /* mark unused */
103 channel.Name = nullptr;
104 channel.Callback = nullptr;
105 channel.CallbackData = nullptr;
106}
uint16_t channel
Definition adc_inputs.h:104
static ExtiChannel channels[16]
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
GPIO_TypeDef * ioportid_t
Port Identifier.
uint32_t ioline_t
Type of an I/O line.
Definition hal_pal_lld.h:88
void brain_pin_markUnused(brain_pin_e brainPin)
bool isBrainPinValid(brain_pin_e brainPin)

Referenced by adcTriggerTurnOffInputPin(), FrequencySensor::deInit(), HellaOilLevelSensor::deInit(), deInitFlexSensor(), detectHellenBoardId(), extiTriggerTurnOffInputPin(), HellenBoardIdFinder< NumPins >::measureChargingTimes(), nm_bsp_interrupt_ctrl(), and stopLogicAnalyzerPins().

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

◆ efiExtiEnablePin()

int efiExtiEnablePin ( const char msg,
brain_pin_e  pin,
uint32_t  mode,
ExtiCallback  cb,
void *  cb_data 
)

Definition at line 38 of file digital_input_exti.cpp.

38 {
39 /* paranoid check, in case of Gpio::Unassigned getHwPort will return NULL
40 * and we will fail on next check */
41 if (!isBrainPinValid(brainPin)) {
42 return -1;
43 }
44
45 criticalAssert(msg, "efiExtiEnablePin msg must not be null", -1);
46
47 ioportid_t port = getHwPort(msg, brainPin);
48 if (port == NULL) {
49 return -1;
50 }
51
52 efiSetPadMode(msg, brainPin, PAL_MODE_INPUT);
53
54 int index = getHwPin(msg, brainPin);
55
56 auto& channel = channels[index];
57
58 /* is this index already used? */
59 if (channel.Callback) {
60 firmwareError(ObdCode::CUSTOM_ERR_PIN_ALREADY_USED_2, "%s: pin %s/index %d: exti index already used by %s (stm32 limitation, cannot use those two pins as event inputs simultaneously)",
61 msg,
62 hwPortname(brainPin),
63 index,
64 channel.Name);
65 return -1;
66 }
67
68 channel.Callback = cb;
69 channel.CallbackData = cb_data;
70 channel.Name = msg;
71
72 ioline_t line = PAL_LINE(port, index);
73 palEnableLineEvent(line, mode);
74
75 return 0;
76}
void efiSetPadMode(const char *msg, brain_pin_e brainPin, iomode_t mode)
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_PIN_ALREADY_USED_2
const char * hwPortname(brain_pin_e brainPin)

Referenced by adcTriggerTurnOnInputPin(), cdmIonInit(), extiTriggerTurnOnInputPin(), HellaOilLevelSensor::init(), initFlexSensor(), FrequencySensor::initIfValid(), initWave(), HellenBoardIdFinder< NumPins >::measureChargingTimes(), and nm_bsp_interrupt_ctrl().

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

◆ efiExtiInit()

void efiExtiInit ( )

EXTI is a funny thing: you can only use same pin on one port. For example, you can use PA0 PB5 PE2 PD7 but you cannot use PA0 PB0 PE2 PD7 because pin '0' would be used on two different ports

Definition at line 22 of file digital_input_exti.cpp.

22 {
23 nvicEnableVector(I2C1_EV_IRQn, STM32_I2C_I2C1_IRQ_PRIORITY);
24}

Referenced by initHardwareNoConfig().

Here is the caller graph for this function:

◆ getExtiOverflowCounter()

uint8_t getExtiOverflowCounter ( )

Definition at line 196 of file digital_input_exti.cpp.

196 {
197 return overflowCounter;
198}
static uint8_t overflowCounter

Referenced by updateTunerStudioState().

Here is the caller graph for this function:

Go to the source code of this file.