refactoring - reducing GPIO complexity
This commit is contained in:
parent
17e05402ed
commit
66e14b52ae
|
@ -235,6 +235,27 @@ void initPrimaryPins(void) {
|
||||||
outputPinRegisterExt2("led: ERROR status", &enginePins.errorLedPin, LED_ERROR_BRAIN_PIN, &DEFAULT_OUTPUT);
|
outputPinRegisterExt2("led: ERROR status", &enginePins.errorLedPin, LED_ERROR_BRAIN_PIN, &DEFAULT_OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize the hardware output pin while also assigning it a logical name
|
||||||
|
*/
|
||||||
|
static void initOutputPinExt(const char *msg, OutputPin *outputPin, ioportid_t port, uint32_t pinNumber, iomode_t mode) {
|
||||||
|
if (outputPin->port != NULL && (outputPin->port != port || outputPin->pin != pinNumber)) {
|
||||||
|
/**
|
||||||
|
* here we check if another physical pin is already assigned to this logical output
|
||||||
|
*/
|
||||||
|
// todo: need to clear '&outputs' in io_pins.c
|
||||||
|
warning(CUSTOM_OBD_PIN_CONFLICT, "outputPin [%s] already assigned to %x%d", msg, outputPin->port, outputPin->pin);
|
||||||
|
engine->withError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
outputPin->currentLogicValue = INITIAL_PIN_STATE;
|
||||||
|
outputPin->port = port;
|
||||||
|
outputPin->pin = pinNumber;
|
||||||
|
|
||||||
|
mySetPadMode(msg, port, pinNumber, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode) {
|
void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode) {
|
||||||
if (brainPin == GPIO_UNASSIGNED)
|
if (brainPin == GPIO_UNASSIGNED)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -143,7 +143,6 @@ void turnPinHigh(NamedOutputPin *output);
|
||||||
void turnPinLow(NamedOutputPin *output);
|
void turnPinLow(NamedOutputPin *output);
|
||||||
|
|
||||||
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
|
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
|
||||||
void initOutputPinExt(const char *msg, OutputPin *outputPin, ioportid_t port, uint32_t pinNumber, iomode_t mode);
|
|
||||||
void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode);
|
void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode);
|
||||||
|
|
||||||
ioportmask_t getHwPin(brain_pin_e brainPin);
|
ioportmask_t getHwPin(brain_pin_e brainPin);
|
||||||
|
|
|
@ -53,26 +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
|
|
||||||
*/
|
|
||||||
void initOutputPinExt(const char *msg, OutputPin *outputPin, ioportid_t port, uint32_t pinNumber, iomode_t mode) {
|
|
||||||
if (outputPin->port != NULL && (outputPin->port != port || outputPin->pin != pinNumber)) {
|
|
||||||
/**
|
|
||||||
* here we check if another physical pin is already assigned to this logical output
|
|
||||||
*/
|
|
||||||
// todo: need to clear '&outputs' in io_pins.c
|
|
||||||
warning(CUSTOM_OBD_PIN_CONFLICT, "outputPin [%s] already assigned to %x%d", msg, outputPin->port, outputPin->pin);
|
|
||||||
engine->withError = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
outputPin->currentLogicValue = INITIAL_PIN_STATE;
|
|
||||||
outputPin->port = port;
|
|
||||||
outputPin->pin = pinNumber;
|
|
||||||
|
|
||||||
mySetPadMode(msg, port, pinNumber, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method would set an error condition if pin is already used
|
* This method would set an error condition if pin is already used
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -251,5 +251,5 @@ int getRusEfiVersion(void) {
|
||||||
return 123; // this is here to make the compiler happy about the unused array
|
return 123; // this is here to make the compiler happy about the unused array
|
||||||
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
||||||
return 3211; // this is here to make the compiler happy about the unused array
|
return 3211; // this is here to make the compiler happy about the unused array
|
||||||
return 20170418;
|
return 20170421;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue