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

Detailed Description

his file is about general input/output utility methods, not much EFI-specifics

Date
Jan 24, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file io_pins.cpp.

Functions

void efiSetPadUnused (brain_pin_e brainPin)
 
void efiSetPadMode (const char *msg, brain_pin_e brainPin, iomode_t mode)
 
void efiSetPadModeWithoutOwnershipAcquisition (const char *msg, brain_pin_e brainPin, iomode_t mode)
 
bool efiReadPin (brain_pin_e pin)
 
iomode_t getInputMode (pin_input_mode_e mode)
 
void writePad (const char *msg, brain_pin_e pin, int bit)
 
void setMockState (brain_pin_e pin, bool state)
 
bool efiIsInputPinInverted (pin_input_mode_e mode)
 
bool efiReadPin (brain_pin_e pin, pin_input_mode_e mode)
 

Variables

bool mockPinStates [BRAIN_PIN_COUNT]
 

Function Documentation

◆ efiIsInputPinInverted()

bool efiIsInputPinInverted ( pin_input_mode_e  mode)

Definition at line 138 of file io_pins.cpp.

138 {
139 return ((mode == PI_INVERTED_DEFAULT) ||
140 (mode == PI_INVERTED_PULLUP) ||
141 (mode == PI_INVERTED_PULLDOWN));
142}

Referenced by efiReadPin().

Here is the caller graph for this function:

◆ efiReadPin() [1/2]

bool efiReadPin ( brain_pin_e  pin)

Definition at line 89 of file io_pins.cpp.

89 {
90 if (!isBrainPinValid(pin))
91 return false;
93 return palReadPad(getHwPort("readPin", pin), getHwPin("readPin", pin));
94 #if (BOARD_EXT_GPIOCHIPS > 0)
95 else if (brain_pin_is_ext(pin))
96 return (gpiochips_readPad(pin) > 0);
97 #endif
98
99 /* incorrect pin */
100 return false;
101}
int gpiochips_readPad(brain_pin_e pin)
Get value to gpio of gpiochip.
Definition core.cpp:363
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
bool brain_pin_is_onchip(brain_pin_e brainPin)
bool isBrainPinValid(brain_pin_e brainPin)
bool brain_pin_is_ext(brain_pin_e brainPin)
brain_pin_e pin
Definition stm32_adc.cpp:15

Referenced by boardGetAnalogDiagnostic(), NitrousController::checkTriggerPinState(), efiReadPin(), flexExtiCallback(), getAuxDigital(), getBrakePedalState(), getClutchDownState(), getClutchUpState(), isIgnVoltage(), AntilagSystemBase::isInsideALSSwitchCondition(), LaunchControlBase::isInsideSwitchCondition(), HellaOilLevelSensor::onEdge(), ButtonDebounce::stopConfiguration(), GenericGearController::update(), and ShiftTorqueReductionController::updateTriggerPinState().

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

◆ efiReadPin() [2/2]

bool efiReadPin ( brain_pin_e  pin,
pin_input_mode_e  mode 
)

Definition at line 144 of file io_pins.cpp.

144 {
145 return efiReadPin(pin) ^ efiIsInputPinInverted(mode);
146}
bool efiIsInputPinInverted(pin_input_mode_e mode)
Definition io_pins.cpp:138
bool efiReadPin(brain_pin_e pin)
Definition io_pins.cpp:89
Here is the call graph for this function:

◆ efiSetPadMode()

void efiSetPadMode ( const char msg,
brain_pin_e  brainPin,
iomode_t  mode 
)

This method would set an error condition if pin is already used

Definition at line 48 of file io_pins.cpp.

48 {
49 if (!isBrainPinValid(brainPin)) {
50 // No pin configured, nothing to do here.
51 return;
52 }
53
54 bool wasUsed = brain_pin_markUsed(brainPin, msg);
55
56 if (!wasUsed) {
58 }
59}
void efiSetPadModeWithoutOwnershipAcquisition(const char *msg, brain_pin_e brainPin, iomode_t mode)
Definition io_pins.cpp:61
bool brain_pin_markUsed(Gpio brainPin, const char *msg)
Here is the call graph for this function:

◆ efiSetPadModeWithoutOwnershipAcquisition()

void efiSetPadModeWithoutOwnershipAcquisition ( const char msg,
brain_pin_e  brainPin,
iomode_t  mode 
)

Definition at line 61 of file io_pins.cpp.

61 {
62#if EFI_PROD_CODE
63 /*check if on-chip pin or external */
64 if (brain_pin_is_onchip(brainPin)) {
65 /* on-chip */
66 ioportid_t port = getHwPort(msg, brainPin);
67 ioportmask_t pin = getHwPin(msg, brainPin);
68 /* paranoid */
69 if (!port)
70 return;
71
72 palSetPadMode(port, pin, mode);
73 }
74 #if (BOARD_EXT_GPIOCHIPS > 0)
75 else {
76 gpiochips_setPadMode(brainPin, mode);
77 }
78 #endif
79
80#endif /* EFI_PROD_CODE */
81}
int gpiochips_setPadMode(brain_pin_e pin, iomode_t mode)
Set pin mode of gpiochip.
Definition core.cpp:317
uint32_t ioportmask_t
Digital I/O port sized unsigned type.
Definition hal_pal_lld.h:78
GPIO_TypeDef * ioportid_t
Port Identifier.

Referenced by benchSetPinValue(), efiSetPadMode(), initQcBenchControls(), initSettings(), qcSetEtbState(), and setPin().

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

◆ efiSetPadUnused()

void efiSetPadUnused ( brain_pin_e  brainPin)

Definition at line 20 of file io_pins.cpp.

20 {
21#if EFI_PROD_CODE
22 /* input with pull up, is it safe? */
23 iomode_t mode = PAL_STM32_MODE_INPUT | PAL_STM32_PUPDR_PULLUP;
24
25 if (brain_pin_is_onchip(brainPin)) {
26 ioportid_t port = getHwPort("unused", brainPin);
27 ioportmask_t pin = getHwPin("unused", brainPin);
28
29 /* input with pull up, is it safe?
30 * todo: shall we reuse 'default state' constants with board.h?
31 * */
32 palSetPadMode(port, pin, mode);
33 palWritePad(port, pin, 0);
34 }
35 #if (BOARD_EXT_GPIOCHIPS > 0)
36 else {
37 gpiochips_setPadMode(brainPin, mode);
38 }
39 #endif
40#endif /* EFI_PROD_CODE */
41
42 brain_pin_markUnused(brainPin);
43}
uint32_t iomode_t
Digital I/O modes.
Definition hal_pal_lld.h:83
void brain_pin_markUnused(brain_pin_e brainPin)

Referenced by applyNewHardwareSettings(), OutputPin::deInit(), deInitIfValid(), ButtonDebounce::stopConfiguration(), stopKLine(), stopSent(), stopSmartCsPins(), and stopSpi().

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

◆ getInputMode()

iomode_t getInputMode ( pin_input_mode_e  mode)

Definition at line 103 of file io_pins.cpp.

103 {
104 switch (mode) {
105 case PI_PULLUP:
106 case PI_INVERTED_PULLUP:
107 return PAL_MODE_INPUT_PULLUP;
108 case PI_PULLDOWN:
109 case PI_INVERTED_PULLDOWN:
110 return PAL_MODE_INPUT_PULLDOWN;
111 case PI_DEFAULT:
112 case PI_INVERTED_DEFAULT:
113 default:
114 return PAL_MODE_INPUT;
115 }
116}

Referenced by GenericGearController::init(), startInputPinIfValid(), and ButtonDebounce::stopConfiguration().

Here is the caller graph for this function:

◆ setMockState()

void setMockState ( brain_pin_e  pin,
bool  state 
)

Definition at line 132 of file io_pins.cpp.

132 {
133 mockPinStates[static_cast<int>(pin)] = state;
134}
bool mockPinStates[BRAIN_PIN_COUNT]
Definition io_pins.cpp:126
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")

Referenced by OutputPin::setValue().

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

◆ writePad()

void writePad ( const char msg,
brain_pin_e  pin,
int  bit 
)

Definition at line 118 of file io_pins.cpp.

118 {
119 palWritePad(getHwPort(msg, pin), getHwPin(msg, pin), bit);
120}
Here is the call graph for this function:

Variable Documentation

◆ mockPinStates

bool mockPinStates[BRAIN_PIN_COUNT]

Definition at line 126 of file io_pins.cpp.

Referenced by setMockState().

Go to the source code of this file.