rusEFI
The most advanced open source ECU
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 (void)
 
ioportmask_t getHwPin (const char *msg, brain_pin_e brainPin)
 
ioportid_t getHwPort (const char *msg, brain_pin_e brainPin)
 
const char * portname (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(), startHip9011_pins(), 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 GPIO_NULL;
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(), startHip9011_pins(), and writePad().

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

◆ initMiscOutputPins()

void initMiscOutputPins ( )

Definition at line 676 of file efi_gpio.cpp.

676  {
677 #if EFI_GPIO_HARDWARE
678 
679 #if HAL_USE_SPI
681 #endif /* HAL_USE_SPI */
682 
683 #if EFI_SHAFT_POSITION_INPUT
684  // todo: migrate remaining OutputPin to RegisteredOutputPin in order to get consistent dynamic pin init/deinit
686 #endif // EFI_SHAFT_POSITION_INPUT
687 
689 
690 #endif /* EFI_GPIO_HARDWARE */
691 }
OutputPin o2heater
Definition: efi_gpio.h:98
OutputPin debugTriggerSync
Definition: efi_gpio.h:109
OutputPin sdCsPin
Definition: efi_gpio.h:123
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition: efi_gpio.cpp:697
EnginePins enginePins
Definition: efi_gpio.cpp:24
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 828 of file efi_gpio.cpp.

828  {
829 #if EFI_PROD_CODE
830  initErrorLed(LED_CRITICAL_ERROR_BRAIN_PIN);
831 
832  addConsoleAction("gpio_pins", EnginePins::debug);
833 #endif /* EFI_PROD_CODE */
834 }
static void debug()
Definition: efi_gpio.cpp:253
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
static void initErrorLed(Gpio led)
Definition: efi_gpio.cpp:820

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 }
Gpio
@ 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 getPinNameByAdcChannel(), gpio_pin_markUsed(), hwOnChipPhysicalPinName(), printAdcChannedReport(), and reportPins().

Here is the caller graph for this function:

◆ turnAllPinsOff()

void turnAllPinsOff ( void  )

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

Definition at line 840 of file efi_gpio.cpp.

840  {
841  for (int i = 0; i < MAX_CYLINDER_COUNT; i++) {
842  enginePins.injectors[i].setValue(false);
843  enginePins.coils[i].setValue(false);
845  }
848  enginePins.checkEnginePin.setValue(true); // yes this one can go ON
849 }
RegisteredOutputPin mainRelay
Definition: efi_gpio.h:76
IgnitionOutputPin trailingCoils[MAX_CYLINDER_COUNT]
Definition: efi_gpio.h:129
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
Definition: efi_gpio.h:126
RegisteredOutputPin fuelPumpRelay
Definition: efi_gpio.h:91
IgnitionOutputPin coils[MAX_CYLINDER_COUNT]
Definition: efi_gpio.h:128
RegisteredOutputPin checkEnginePin
Definition: efi_gpio.h:117
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition: efi_gpio.cpp:590
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(), TriggerDecoderBase::decodeTriggerEvent(), disengageStarterIfNeeded(), doRunBenchTestLuaOutput(), doRunFuelInjBench(), doRunSolenoidBench(), doRunSparkBench(), doStartCranking(), Engine::efiWatchdog(), endSimultaneousInjectionOnlyTogglePins(), EnginePins::EnginePins(), fan2Bench(), fanBenchExt(), firmwareError(), fuelPumpBenchExt(), FanControl1::getPin(), FanControl2::getPin(), IdleController::getRunningOpenLoop(), hdAcrBench(), hpfpValveBench(), SimpleTransmissionController::init(), Generic4TransmissionController::init(), Gm4l6xTransmissionController::init(), initAlternatorCtrl(), initErrorLed(), initMiscOutputPins(), initSpeedometer(), initStatusLeds(), initTachometer(), initWarningRunningPins(), isGdiEngine(), Engine::isMainRelayEnabled(), lua_fan(), luaDeInitPins(), mainRelayBench(), milBench(), Engine::onEngineHasStopped(), HpfpController::onFastCallback(), AcController::onSlowCallback(), FuelPumpController::onSlowCallback(), HarleyAcr::onSlowCallback(), MainRelayController::onSlowCallback(), NitrousController::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.