rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
efi_gpio.h File Reference

Detailed Description

EFI-related GPIO code.

Date
Sep 26, 2014
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file efi_gpio.h.

Data Structures

class  IgnitionOutputPin
 
class  RegisteredOutputPin
 
class  RegisteredNamedOutputPin
 
class  EnginePins
 

Functions

void initPrimaryPins ()
 
void initMiscOutputPins ()
 
void turnAllPinsOff ()
 
ioportmask_t getHwPin (const char *msg, brain_pin_e brainPin)
 
ioportid_t getHwPort (const char *msg, brain_pin_e brainPin)
 
const charportname (ioportid_t GPIOx)
 
brain_pin_e parseBrainPin (const char *str)
 

Variables

EnginePins enginePins
 

Function Documentation

◆ getHwPin()

ioportmask_t getHwPin ( const char msg,
brain_pin_e  brainPin 
)

this method returns the numeric part of pin name. For instance, for PC13 this would return '13'

Definition at line 153 of file cypress_pins.cpp.

153 {
154 if (!isBrainPinValid(brainPin))
155 return EFI_ERROR_CODE;
156
157 if (brain_pin_is_onchip(brainPin))
158 return getBrainPinIndex(brainPin);
159
160 firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin);
161 return EFI_ERROR_CODE;
162}
int getBrainPinIndex(brain_pin_e brainPin)
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_INVALID_PIN
bool brain_pin_is_onchip(brain_pin_e brainPin)
bool isBrainPinValid(brain_pin_e brainPin)

Referenced by adcTriggerTurnOnInputPin(), benchSetPinValue(), directWritePad(), efiExtiDisablePin(), efiExtiEnablePin(), efiReadPin(), efiSetPadMode(), efiSetPadModeWithoutOwnershipAcquisition(), efiSetPadUnused(), extiTriggerTurnOnInputPin(), getAdcChannelPin(), hwPhysicalPinName(), BitbangI2c::init(), initAccelerometer(), initErrorLed(), initializeMmcBlockDevice(), OutputPin::initPin(), initQcBenchControls(), initSmartGpio(), initSpiCsNoOccupy(), initWave(), lua_readpin(), readPin(), and writePad().

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

◆ getHwPort()

ioportid_t getHwPort ( const char msg,
brain_pin_e  brainPin 
)

Definition at line 137 of file cypress_pins.cpp.

137 {
138 (void)msg;
139
140 if (!isBrainPinValid(brainPin)) {
141/*
142 * https://github.com/dron0gus please help
143 firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
144 */
145 return nullptr;
146 }
147 return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE];
148}
ioportid_t * getGpioPorts()

Referenced by adcTriggerTurnOnInputPin(), benchSetPinValue(), directWritePad(), efiExtiDisablePin(), efiExtiEnablePin(), efiReadPin(), efiSetPadMode(), efiSetPadModeWithoutOwnershipAcquisition(), efiSetPadUnused(), extiTriggerTurnOnInputPin(), getAdcChannelPort(), hwPhysicalPinName(), BitbangI2c::init(), initAccelerometer(), initErrorLed(), initializeMmcBlockDevice(), OutputPin::initPin(), initQcBenchControls(), initSmartGpio(), initSpiCsNoOccupy(), initWave(), lua_readpin(), readPin(), and writePad().

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

◆ initMiscOutputPins()

void initMiscOutputPins ( )

Definition at line 690 of file efi_gpio.cpp.

690 {
691#if EFI_GPIO_HARDWARE
692
693#if HAL_USE_SPI
695#endif /* HAL_USE_SPI */
696
697#if EFI_SHAFT_POSITION_INPUT
698 // todo: migrate remaining OutputPin to RegisteredOutputPin in order to get consistent dynamic pin init/deinit
700#endif // EFI_SHAFT_POSITION_INPUT
701
703
704#endif /* EFI_GPIO_HARDWARE */
705}
OutputPin o2heater
Definition efi_gpio.h:99
OutputPin debugTriggerSync
Definition efi_gpio.h:110
OutputPin sdCsPin
Definition efi_gpio.h:124
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
EnginePins enginePins
Definition efi_gpio.cpp:24
static constexpr engine_configuration_s * engineConfiguration

Referenced by initHardware().

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

◆ initPrimaryPins()

void initPrimaryPins ( )

Definition at line 842 of file efi_gpio.cpp.

842 {
843#if EFI_PROD_CODE
844 initErrorLed(LED_CRITICAL_ERROR_BRAIN_PIN);
845
847#endif /* EFI_PROD_CODE */
848}
static void debug()
Definition efi_gpio.cpp:250
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
static void initErrorLed(Gpio led)
Definition efi_gpio.cpp:834

Referenced by initHardwareNoConfig().

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

◆ parseBrainPin()

brain_pin_e parseBrainPin ( const char str)

Parse string representation of physical pin into brain_pin_e ordinal.

Returns
Gpio::Unassigned for "none", Gpio::Invalid for invalid entry

Parse string representation of physical pin into Gpio ordinal.

Returns
Gpio::Unassigned for "none", Gpio::Invalid for invalid entry

Definition at line 169 of file cypress_pins.cpp.

169 {
170 if (strEqual(str, "none"))
171 return Gpio::Unassigned;
172 // todo: create method toLowerCase?
173 if (str[0] != 'p' && str[0] != 'P') {
174 return Gpio::Invalid;
175 }
176 char port = str[1];
177 if (port >= 'a' && port <= 'z') {
178 port = 10 + (port - 'a');
179 } else if (port >= 'A' && port <= 'Z') {
180 port = 10 + (port - 'A');
181 } else if (port >= '0' && port <= '9') {
182// cypress-specific code
183 port = 0 + (port - '0');
184 } else {
185 return Gpio::Invalid;
186 }
187 brain_pin_e basePin = portMap[(int)port];
188 if (basePin == Gpio::Invalid)
189 return Gpio::Invalid;
190 const char *pinStr = str + 2;
191 int pin = atoi(pinStr);
192 return basePin + pin;
193}
@ Unassigned
@ Invalid
static brain_pin_e portMap[16]
brain_pin_e pin
Definition stm32_adc.cpp:15

Referenced by lua_readpin(), and parseBrainPinWithErrorMessage().

Here is the caller graph for this function:

◆ portname()

const char * portname ( ioportid_t  GPIOx)
Deprecated:
Deprecated:

Definition at line 50 of file cypress_pins.cpp.

50 {
51 if (GPIOx == GPIOA)
52 return "PA";
53 if (GPIOx == GPIOB)
54 return "PB";
55 if (GPIOx == GPIOC)
56 return "PC";
57 if (GPIOx == GPIOD)
58 return "PD";
59#if defined(GPIOF)
60 if (GPIOx == GPIOE)
61 return "PE";
62#endif /* GPIOE */
63#if defined(GPIOF)
64 if (GPIOx == GPIOF)
65 return "PF";
66#endif /* GPIOF */
67#if defined(GPIOG)
68 if (GPIOx == GPIOG)
69 return "PG";
70#endif /* GPIOG */
71#if defined(GPIOH)
72 if (GPIOx == GPIOH)
73 return "PH";
74#endif /* GPIOH */
75#if defined(GPIOI)
76 if (GPIOx == GPIOI)
77 return "PI";
78#endif /* GPIOI */
79#if defined(GPIOJ_BASE)
80 if (GPIOx == GPIOJ)
81 return "PJ";
82#endif /* GPIOJ_BASE */
83#if defined(GPIOK_BASE)
84 if (GPIOx == GPIOK)
85 return "PK";
86#endif /* GPIOK_BASE */
87 return "unknown";
88}

Referenced by adcPrintChannelReport(), getPinNameByAdcChannel(), gpio_pin_markUsed(), hwOnChipPhysicalPinName(), and reportPins().

Here is the caller graph for this function:

◆ turnAllPinsOff()

void turnAllPinsOff ( )

This method is part of fatal error handling. The whole method is pretty naive, but that's at least something.

Definition at line 854 of file efi_gpio.cpp.

854 {
855 for (int i = 0; i < MAX_CYLINDER_COUNT; i++) {
856 enginePins.injectors[i].setValue(false);
857 enginePins.coils[i].setValue(false);
859 }
862 enginePins.checkEnginePin.setValue(true); // yes this one can go ON
863#if EFI_PROD_CODE && HW_HELLEN
865#endif
866}
RegisteredOutputPin mainRelay
Definition efi_gpio.h:76
IgnitionOutputPin trailingCoils[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:130
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:127
RegisteredOutputPin fuelPumpRelay
Definition efi_gpio.h:91
IgnitionOutputPin coils[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:129
RegisteredOutputPin checkEnginePin
Definition efi_gpio.h:118
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
void hellenDisableEnSilently()
Here is the call graph for this function:

Variable Documentation

◆ enginePins

EnginePins enginePins
extern

Definition at line 24 of file efi_gpio.cpp.

Referenced by acRelayBench(), applyIACposition(), applyNewHardwareSettings(), auxPlainPinTurnOn(), blink_digits(), canDashboardHaltech(), configureRusefiLuaHooks(), TriggerDecoderBase::decodeTriggerEvent(), disengageStarterIfNeeded(), doRunBenchTestLuaOutput(), doRunFuelInjBench(), doRunSolenoidBench(), doRunSparkBench(), doStartCranking(), Engine::efiWatchdog(), endSimultaneousInjectionOnlyTogglePins(), EnginePins::EnginePins(), errorHandlerWriteReportFile(), fan2Bench(), fanBenchExt(), fireSparkAndPrepareNextSchedule(), firmwareErrorV(), fuelPumpBenchExt(), IdleController::getIdlePosition(), FanControl1::getPin(), FanControl2::getPin(), IdleController::getRunningOpenLoop(), hdAcrBench(), hpfpValveBench(), TachometerModule::init(), SimpleTransmissionController::init(), Generic4TransmissionController::init(), Gm4l6xTransmissionController::init(), initAlternatorCtrl(), initErrorLed(), initMiscOutputPins(), initSpeedometer(), initStatusLeds(), initWarningRunningPins(), isGdiEngine(), Engine::isMainRelayEnabled(), luaDeInitPins(), mainRelayBench(), milBench(), Engine::onEngineHasStopped(), HpfpController::onFastCallback(), AcController::onSlowCallback(), HarleyAcr::onSlowCallback(), MainRelayController::onSlowCallback(), NitrousController::onSlowCallback(), FuelPumpController::onSlowCallback(), VvlController::onSlowCallback(), SensorChecker::onSlowCallback(), Engine::OnTriggerSynchronization(), Engine::periodicSlowCallback(), HpfpController::pinTurnOff(), HpfpController::pinTurnOn(), populateFrame(), prepareCylinderIgnitionSchedule(), printEngineSnifferPinMappings(), resetConfigurationExt(), FuelSchedule::resetOverlapping(), resetPinStats(), HpfpController::scheduleNextCycle(), sendPinStatePackets(), setPinConfigurationOverrides(), Generic4TransmissionController::setTccState(), slowStartStopButtonCallback(), EnginePins::startAuxValves(), startBoostPin(), starterRelayBench(), startHardware(), EnginePins::startIgnitionPins(), EnginePins::startInjectionPins(), startPwm(), startSimultaneousInjection(), EnginePins::stopAuxValves(), EnginePins::stopIgnitionPins(), EnginePins::stopInjectionPins(), turnAllPinsOff(), turnSparkPinHighStartCharging(), InjectionEvent::update(), SimpleTransmissionController::update(), updateFlags(), and updateTunerStudioState().

Go to the source code of this file.