refactoring - reducing GPIO complexity
This commit is contained in:
parent
e3affd2fa6
commit
17e05402ed
|
@ -231,12 +231,19 @@ void initOutputPins(void) {
|
||||||
|
|
||||||
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
|
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/**
|
void initPrimaryPins(void) {
|
||||||
* This method is used for digital GPIO pins only, for peripheral pins see mySetPadMode
|
outputPinRegisterExt2("led: ERROR status", &enginePins.errorLedPin, LED_ERROR_BRAIN_PIN, &DEFAULT_OUTPUT);
|
||||||
*/
|
}
|
||||||
static void outputPinRegisterExt(const char *msg, OutputPin *output, ioportid_t port, uint32_t pin,
|
|
||||||
pin_output_mode_e *outputMode) {
|
void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode) {
|
||||||
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
|
if (brainPin == GPIO_UNASSIGNED)
|
||||||
|
return;
|
||||||
|
ioportid_t port = getHwPort(brainPin);
|
||||||
|
int pin = getHwPin(brainPin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used for digital GPIO pins only, for peripheral pins see mySetPadMode
|
||||||
|
*/
|
||||||
if (port == GPIO_NULL) {
|
if (port == GPIO_NULL) {
|
||||||
// that's for GRIO_NONE
|
// that's for GRIO_NONE
|
||||||
output->port = port;
|
output->port = port;
|
||||||
|
@ -245,25 +252,11 @@ static void outputPinRegisterExt(const char *msg, OutputPin *output, ioportid_t
|
||||||
|
|
||||||
assertOMode(*outputMode);
|
assertOMode(*outputMode);
|
||||||
iomode_t mode = (*outputMode == OM_DEFAULT || *outputMode == OM_INVERTED) ?
|
iomode_t mode = (*outputMode == OM_DEFAULT || *outputMode == OM_INVERTED) ?
|
||||||
PAL_MODE_OUTPUT_PUSHPULL : PAL_MODE_OUTPUT_OPENDRAIN;
|
PAL_MODE_OUTPUT_PUSHPULL : PAL_MODE_OUTPUT_OPENDRAIN;
|
||||||
|
|
||||||
initOutputPinExt(msg, output, port, pin, mode);
|
initOutputPinExt(msg, output, port, pin, mode);
|
||||||
|
|
||||||
output->setDefaultPinState(outputMode);
|
output->setDefaultPinState(outputMode);
|
||||||
#endif /* EFI_GPIO_HARDWARE */
|
|
||||||
}
|
|
||||||
|
|
||||||
void initPrimaryPins(void) {
|
|
||||||
outputPinRegisterExt2("led: ERROR status", &enginePins.errorLedPin, LED_ERROR_BRAIN_PIN, &DEFAULT_OUTPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode) {
|
|
||||||
if (brainPin == GPIO_UNASSIGNED)
|
|
||||||
return;
|
|
||||||
ioportid_t hwPort = getHwPort(brainPin);
|
|
||||||
int hwPin = getHwPin(brainPin);
|
|
||||||
|
|
||||||
outputPinRegisterExt(msg, output, hwPort, hwPin, outputMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,7 +53,6 @@ ioportmask_t getHwPin(brain_pin_e brainPin) {
|
||||||
return brainPin % PORT_SIZE;
|
return brainPin % PORT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize the hardware output pin while also assigning it a logical name
|
* @brief Initialize the hardware output pin while also assigning it a logical name
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue