refactoring - reducing GPIO complexity

This commit is contained in:
rusefi 2017-04-21 17:23:21 -04:00
parent 17e05402ed
commit 66e14b52ae
4 changed files with 22 additions and 22 deletions

View File

@ -235,6 +235,27 @@ void initPrimaryPins(void) {
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) {
if (brainPin == GPIO_UNASSIGNED)
return;

View File

@ -143,7 +143,6 @@ void turnPinHigh(NamedOutputPin *output);
void turnPinLow(NamedOutputPin *output);
#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);
ioportmask_t getHwPin(brain_pin_e brainPin);

View File

@ -53,26 +53,6 @@ ioportmask_t getHwPin(brain_pin_e brainPin) {
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
*/

View File

@ -251,5 +251,5 @@ int getRusEfiVersion(void) {
return 123; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] * 0 != 0)
return 3211; // this is here to make the compiler happy about the unused array
return 20170418;
return 20170421;
}