openblt preparation
This commit is contained in:
parent
2bcda4450b
commit
a3f3f536e8
|
@ -817,132 +817,3 @@ void turnAllPinsOff(void) {
|
||||||
}
|
}
|
||||||
#endif /* EFI_GPIO_HARDWARE */
|
#endif /* EFI_GPIO_HARDWARE */
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
|
||||||
/**
|
|
||||||
* this method returns the numeric part of pin name. For instance, for PC13 this would return '13'
|
|
||||||
*/
|
|
||||||
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) {
|
|
||||||
if (!isBrainPinValid(brainPin))
|
|
||||||
return EFI_ERROR_CODE;
|
|
||||||
|
|
||||||
if (brain_pin_is_onchip(brainPin))
|
|
||||||
return getBrainPinIndex(brainPin);
|
|
||||||
|
|
||||||
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin);
|
|
||||||
return EFI_ERROR_CODE;
|
|
||||||
}
|
|
||||||
#endif // EFI_PROD_CODE
|
|
||||||
|
|
||||||
#if EFI_GPIO_HARDWARE && !EFI_UNIT_TEST
|
|
||||||
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) {
|
|
||||||
(void)msg;
|
|
||||||
|
|
||||||
if (!isBrainPinValid(brainPin)) {
|
|
||||||
/*
|
|
||||||
* https://github.com/dron0gus please help
|
|
||||||
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
|
|
||||||
*/
|
|
||||||
return GPIO_NULL;
|
|
||||||
}
|
|
||||||
return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE];
|
|
||||||
}
|
|
||||||
|
|
||||||
int getBrainPinIndex(brain_pin_e brainPin) {
|
|
||||||
return (brainPin - Gpio::A0) % PORT_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ioportid_t getBrainPinPort(brain_pin_e brainPin) {
|
|
||||||
return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated - use hwPortname() instead
|
|
||||||
*/
|
|
||||||
const char *portname(ioportid_t GPIOx) {
|
|
||||||
if (GPIOx == GPIOA)
|
|
||||||
return "PA";
|
|
||||||
if (GPIOx == GPIOB)
|
|
||||||
return "PB";
|
|
||||||
if (GPIOx == GPIOC)
|
|
||||||
return "PC";
|
|
||||||
if (GPIOx == GPIOD)
|
|
||||||
return "PD";
|
|
||||||
#if defined(GPIOF)
|
|
||||||
if (GPIOx == GPIOE)
|
|
||||||
return "PE";
|
|
||||||
#endif /* GPIOE */
|
|
||||||
#if defined(GPIOF)
|
|
||||||
if (GPIOx == GPIOF)
|
|
||||||
return "PF";
|
|
||||||
#endif /* GPIOF */
|
|
||||||
#if defined(GPIOG)
|
|
||||||
if (GPIOx == GPIOG)
|
|
||||||
return "PG";
|
|
||||||
#endif /* GPIOG */
|
|
||||||
#if defined(GPIOH)
|
|
||||||
if (GPIOx == GPIOH)
|
|
||||||
return "PH";
|
|
||||||
#endif /* GPIOH */
|
|
||||||
#if defined(GPIOI)
|
|
||||||
if (GPIOx == GPIOI)
|
|
||||||
return "PI";
|
|
||||||
#endif /* GPIOI */
|
|
||||||
#if defined(GPIOJ_BASE)
|
|
||||||
if (GPIOx == GPIOJ)
|
|
||||||
return "PJ";
|
|
||||||
#endif /* GPIOJ_BASE */
|
|
||||||
#if defined(GPIOK_BASE)
|
|
||||||
if (GPIOx == GPIOK)
|
|
||||||
return "PK";
|
|
||||||
#endif /* GPIOK_BASE */
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
static int getPortIndex(ioportid_t port) {
|
|
||||||
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
|
|
||||||
if (port == GPIOA)
|
|
||||||
return 0;
|
|
||||||
if (port == GPIOB)
|
|
||||||
return 1;
|
|
||||||
if (port == GPIOC)
|
|
||||||
return 2;
|
|
||||||
if (port == GPIOD)
|
|
||||||
return 3;
|
|
||||||
#if defined(GPIOF)
|
|
||||||
if (port == GPIOE)
|
|
||||||
return 4;
|
|
||||||
#endif /* GPIOE */
|
|
||||||
#if defined(GPIOF)
|
|
||||||
if (port == GPIOF)
|
|
||||||
return 5;
|
|
||||||
#endif /* GPIOF */
|
|
||||||
#if defined(GPIOG)
|
|
||||||
if (port == GPIOG)
|
|
||||||
return 6;
|
|
||||||
#endif /* GPIOG */
|
|
||||||
#if defined(GPIOH)
|
|
||||||
if (port == GPIOH)
|
|
||||||
return 7;
|
|
||||||
#endif /* GPIOH */
|
|
||||||
#if defined(GPIOI)
|
|
||||||
if (port == GPIOI)
|
|
||||||
return 8;
|
|
||||||
#endif /* STM32_HAS_GPIOI */
|
|
||||||
#if defined(GPIOJ_BASE)
|
|
||||||
if (port == GPIOJ)
|
|
||||||
return 9;
|
|
||||||
#endif /* GPIOJ_BASE */
|
|
||||||
#if defined(GPIOK_BASE)
|
|
||||||
if (port == GPIOK)
|
|
||||||
return 10;
|
|
||||||
#endif /* GPIOK_BASE */
|
|
||||||
firmwareError(ObdCode::CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getPortPinIndex(ioportid_t port, ioportmask_t pin) {
|
|
||||||
int portIndex = getPortIndex(port);
|
|
||||||
return portIndex * PORT_SIZE + pin;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // EFI_GPIO_HARDWARE
|
|
||||||
|
|
|
@ -36,6 +36,131 @@ ioportid_t * getGpioPorts() {
|
||||||
return ports;
|
return ports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getBrainPinIndex(brain_pin_e brainPin) {
|
||||||
|
return (brainPin - Gpio::A0) % PORT_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioportid_t getBrainPinPort(brain_pin_e brainPin) {
|
||||||
|
return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated - use hwPortname() instead
|
||||||
|
*/
|
||||||
|
const char *portname(ioportid_t GPIOx) {
|
||||||
|
if (GPIOx == GPIOA)
|
||||||
|
return "PA";
|
||||||
|
if (GPIOx == GPIOB)
|
||||||
|
return "PB";
|
||||||
|
if (GPIOx == GPIOC)
|
||||||
|
return "PC";
|
||||||
|
if (GPIOx == GPIOD)
|
||||||
|
return "PD";
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (GPIOx == GPIOE)
|
||||||
|
return "PE";
|
||||||
|
#endif /* GPIOE */
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (GPIOx == GPIOF)
|
||||||
|
return "PF";
|
||||||
|
#endif /* GPIOF */
|
||||||
|
#if defined(GPIOG)
|
||||||
|
if (GPIOx == GPIOG)
|
||||||
|
return "PG";
|
||||||
|
#endif /* GPIOG */
|
||||||
|
#if defined(GPIOH)
|
||||||
|
if (GPIOx == GPIOH)
|
||||||
|
return "PH";
|
||||||
|
#endif /* GPIOH */
|
||||||
|
#if defined(GPIOI)
|
||||||
|
if (GPIOx == GPIOI)
|
||||||
|
return "PI";
|
||||||
|
#endif /* GPIOI */
|
||||||
|
#if defined(GPIOJ_BASE)
|
||||||
|
if (GPIOx == GPIOJ)
|
||||||
|
return "PJ";
|
||||||
|
#endif /* GPIOJ_BASE */
|
||||||
|
#if defined(GPIOK_BASE)
|
||||||
|
if (GPIOx == GPIOK)
|
||||||
|
return "PK";
|
||||||
|
#endif /* GPIOK_BASE */
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getPortIndex(ioportid_t port) {
|
||||||
|
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
|
||||||
|
if (port == GPIOA)
|
||||||
|
return 0;
|
||||||
|
if (port == GPIOB)
|
||||||
|
return 1;
|
||||||
|
if (port == GPIOC)
|
||||||
|
return 2;
|
||||||
|
if (port == GPIOD)
|
||||||
|
return 3;
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (port == GPIOE)
|
||||||
|
return 4;
|
||||||
|
#endif /* GPIOE */
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (port == GPIOF)
|
||||||
|
return 5;
|
||||||
|
#endif /* GPIOF */
|
||||||
|
#if defined(GPIOG)
|
||||||
|
if (port == GPIOG)
|
||||||
|
return 6;
|
||||||
|
#endif /* GPIOG */
|
||||||
|
#if defined(GPIOH)
|
||||||
|
if (port == GPIOH)
|
||||||
|
return 7;
|
||||||
|
#endif /* GPIOH */
|
||||||
|
#if defined(GPIOI)
|
||||||
|
if (port == GPIOI)
|
||||||
|
return 8;
|
||||||
|
#endif /* STM32_HAS_GPIOI */
|
||||||
|
#if defined(GPIOJ_BASE)
|
||||||
|
if (port == GPIOJ)
|
||||||
|
return 9;
|
||||||
|
#endif /* GPIOJ_BASE */
|
||||||
|
#if defined(GPIOK_BASE)
|
||||||
|
if (port == GPIOK)
|
||||||
|
return 10;
|
||||||
|
#endif /* GPIOK_BASE */
|
||||||
|
firmwareError(ObdCode::CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPortPinIndex(ioportid_t port, ioportmask_t pin) {
|
||||||
|
int portIndex = getPortIndex(port);
|
||||||
|
return portIndex * PORT_SIZE + pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) {
|
||||||
|
(void)msg;
|
||||||
|
|
||||||
|
if (!isBrainPinValid(brainPin)) {
|
||||||
|
/*
|
||||||
|
* https://github.com/dron0gus please help
|
||||||
|
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
|
||||||
|
*/
|
||||||
|
return GPIO_NULL;
|
||||||
|
}
|
||||||
|
return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method returns the numeric part of pin name. For instance, for PC13 this would return '13'
|
||||||
|
*/
|
||||||
|
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) {
|
||||||
|
if (!isBrainPinValid(brainPin))
|
||||||
|
return EFI_ERROR_CODE;
|
||||||
|
|
||||||
|
if (brain_pin_is_onchip(brainPin))
|
||||||
|
return getBrainPinIndex(brainPin);
|
||||||
|
|
||||||
|
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin);
|
||||||
|
return EFI_ERROR_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse string representation of physical pin into brain_pin_e ordinal.
|
* Parse string representation of physical pin into brain_pin_e ordinal.
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,6 +22,131 @@ ioportid_t * getGpioPorts() {
|
||||||
return ports;
|
return ports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getBrainPinIndex(brain_pin_e brainPin) {
|
||||||
|
return (brainPin - Gpio::A0) % PORT_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioportid_t getBrainPinPort(brain_pin_e brainPin) {
|
||||||
|
return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated - use hwPortname() instead
|
||||||
|
*/
|
||||||
|
const char *portname(ioportid_t GPIOx) {
|
||||||
|
if (GPIOx == GPIOA)
|
||||||
|
return "PA";
|
||||||
|
if (GPIOx == GPIOB)
|
||||||
|
return "PB";
|
||||||
|
if (GPIOx == GPIOC)
|
||||||
|
return "PC";
|
||||||
|
if (GPIOx == GPIOD)
|
||||||
|
return "PD";
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (GPIOx == GPIOE)
|
||||||
|
return "PE";
|
||||||
|
#endif /* GPIOE */
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (GPIOx == GPIOF)
|
||||||
|
return "PF";
|
||||||
|
#endif /* GPIOF */
|
||||||
|
#if defined(GPIOG)
|
||||||
|
if (GPIOx == GPIOG)
|
||||||
|
return "PG";
|
||||||
|
#endif /* GPIOG */
|
||||||
|
#if defined(GPIOH)
|
||||||
|
if (GPIOx == GPIOH)
|
||||||
|
return "PH";
|
||||||
|
#endif /* GPIOH */
|
||||||
|
#if defined(GPIOI)
|
||||||
|
if (GPIOx == GPIOI)
|
||||||
|
return "PI";
|
||||||
|
#endif /* GPIOI */
|
||||||
|
#if defined(GPIOJ_BASE)
|
||||||
|
if (GPIOx == GPIOJ)
|
||||||
|
return "PJ";
|
||||||
|
#endif /* GPIOJ_BASE */
|
||||||
|
#if defined(GPIOK_BASE)
|
||||||
|
if (GPIOx == GPIOK)
|
||||||
|
return "PK";
|
||||||
|
#endif /* GPIOK_BASE */
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getPortIndex(ioportid_t port) {
|
||||||
|
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
|
||||||
|
if (port == GPIOA)
|
||||||
|
return 0;
|
||||||
|
if (port == GPIOB)
|
||||||
|
return 1;
|
||||||
|
if (port == GPIOC)
|
||||||
|
return 2;
|
||||||
|
if (port == GPIOD)
|
||||||
|
return 3;
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (port == GPIOE)
|
||||||
|
return 4;
|
||||||
|
#endif /* GPIOE */
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (port == GPIOF)
|
||||||
|
return 5;
|
||||||
|
#endif /* GPIOF */
|
||||||
|
#if defined(GPIOG)
|
||||||
|
if (port == GPIOG)
|
||||||
|
return 6;
|
||||||
|
#endif /* GPIOG */
|
||||||
|
#if defined(GPIOH)
|
||||||
|
if (port == GPIOH)
|
||||||
|
return 7;
|
||||||
|
#endif /* GPIOH */
|
||||||
|
#if defined(GPIOI)
|
||||||
|
if (port == GPIOI)
|
||||||
|
return 8;
|
||||||
|
#endif /* STM32_HAS_GPIOI */
|
||||||
|
#if defined(GPIOJ_BASE)
|
||||||
|
if (port == GPIOJ)
|
||||||
|
return 9;
|
||||||
|
#endif /* GPIOJ_BASE */
|
||||||
|
#if defined(GPIOK_BASE)
|
||||||
|
if (port == GPIOK)
|
||||||
|
return 10;
|
||||||
|
#endif /* GPIOK_BASE */
|
||||||
|
firmwareError(ObdCode::CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPortPinIndex(ioportid_t port, ioportmask_t pin) {
|
||||||
|
int portIndex = getPortIndex(port);
|
||||||
|
return portIndex * PORT_SIZE + pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) {
|
||||||
|
(void)msg;
|
||||||
|
|
||||||
|
if (!isBrainPinValid(brainPin)) {
|
||||||
|
/*
|
||||||
|
* https://github.com/dron0gus please help
|
||||||
|
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
|
||||||
|
*/
|
||||||
|
return GPIO_NULL;
|
||||||
|
}
|
||||||
|
return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method returns the numeric part of pin name. For instance, for PC13 this would return '13'
|
||||||
|
*/
|
||||||
|
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) {
|
||||||
|
if (!isBrainPinValid(brainPin))
|
||||||
|
return EFI_ERROR_CODE;
|
||||||
|
|
||||||
|
if (brain_pin_is_onchip(brainPin))
|
||||||
|
return getBrainPinIndex(brainPin);
|
||||||
|
|
||||||
|
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin);
|
||||||
|
return EFI_ERROR_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse string representation of physical pin into Gpio ordinal.
|
* Parse string representation of physical pin into Gpio ordinal.
|
||||||
*
|
*
|
||||||
|
|
|
@ -57,6 +57,131 @@ ioportid_t * getGpioPorts() {
|
||||||
return ports;
|
return ports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getBrainPinIndex(brain_pin_e brainPin) {
|
||||||
|
return (brainPin - Gpio::A0) % PORT_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioportid_t getBrainPinPort(brain_pin_e brainPin) {
|
||||||
|
return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated - use hwPortname() instead
|
||||||
|
*/
|
||||||
|
const char *portname(ioportid_t GPIOx) {
|
||||||
|
if (GPIOx == GPIOA)
|
||||||
|
return "PA";
|
||||||
|
if (GPIOx == GPIOB)
|
||||||
|
return "PB";
|
||||||
|
if (GPIOx == GPIOC)
|
||||||
|
return "PC";
|
||||||
|
if (GPIOx == GPIOD)
|
||||||
|
return "PD";
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (GPIOx == GPIOE)
|
||||||
|
return "PE";
|
||||||
|
#endif /* GPIOE */
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (GPIOx == GPIOF)
|
||||||
|
return "PF";
|
||||||
|
#endif /* GPIOF */
|
||||||
|
#if defined(GPIOG)
|
||||||
|
if (GPIOx == GPIOG)
|
||||||
|
return "PG";
|
||||||
|
#endif /* GPIOG */
|
||||||
|
#if defined(GPIOH)
|
||||||
|
if (GPIOx == GPIOH)
|
||||||
|
return "PH";
|
||||||
|
#endif /* GPIOH */
|
||||||
|
#if defined(GPIOI)
|
||||||
|
if (GPIOx == GPIOI)
|
||||||
|
return "PI";
|
||||||
|
#endif /* GPIOI */
|
||||||
|
#if defined(GPIOJ_BASE)
|
||||||
|
if (GPIOx == GPIOJ)
|
||||||
|
return "PJ";
|
||||||
|
#endif /* GPIOJ_BASE */
|
||||||
|
#if defined(GPIOK_BASE)
|
||||||
|
if (GPIOx == GPIOK)
|
||||||
|
return "PK";
|
||||||
|
#endif /* GPIOK_BASE */
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getPortIndex(ioportid_t port) {
|
||||||
|
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
|
||||||
|
if (port == GPIOA)
|
||||||
|
return 0;
|
||||||
|
if (port == GPIOB)
|
||||||
|
return 1;
|
||||||
|
if (port == GPIOC)
|
||||||
|
return 2;
|
||||||
|
if (port == GPIOD)
|
||||||
|
return 3;
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (port == GPIOE)
|
||||||
|
return 4;
|
||||||
|
#endif /* GPIOE */
|
||||||
|
#if defined(GPIOF)
|
||||||
|
if (port == GPIOF)
|
||||||
|
return 5;
|
||||||
|
#endif /* GPIOF */
|
||||||
|
#if defined(GPIOG)
|
||||||
|
if (port == GPIOG)
|
||||||
|
return 6;
|
||||||
|
#endif /* GPIOG */
|
||||||
|
#if defined(GPIOH)
|
||||||
|
if (port == GPIOH)
|
||||||
|
return 7;
|
||||||
|
#endif /* GPIOH */
|
||||||
|
#if defined(GPIOI)
|
||||||
|
if (port == GPIOI)
|
||||||
|
return 8;
|
||||||
|
#endif /* STM32_HAS_GPIOI */
|
||||||
|
#if defined(GPIOJ_BASE)
|
||||||
|
if (port == GPIOJ)
|
||||||
|
return 9;
|
||||||
|
#endif /* GPIOJ_BASE */
|
||||||
|
#if defined(GPIOK_BASE)
|
||||||
|
if (port == GPIOK)
|
||||||
|
return 10;
|
||||||
|
#endif /* GPIOK_BASE */
|
||||||
|
firmwareError(ObdCode::CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPortPinIndex(ioportid_t port, ioportmask_t pin) {
|
||||||
|
int portIndex = getPortIndex(port);
|
||||||
|
return portIndex * PORT_SIZE + pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) {
|
||||||
|
(void)msg;
|
||||||
|
|
||||||
|
if (!isBrainPinValid(brainPin)) {
|
||||||
|
/*
|
||||||
|
* https://github.com/dron0gus please help
|
||||||
|
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
|
||||||
|
*/
|
||||||
|
return GPIO_NULL;
|
||||||
|
}
|
||||||
|
return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method returns the numeric part of pin name. For instance, for PC13 this would return '13'
|
||||||
|
*/
|
||||||
|
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) {
|
||||||
|
if (!isBrainPinValid(brainPin))
|
||||||
|
return EFI_ERROR_CODE;
|
||||||
|
|
||||||
|
if (brain_pin_is_onchip(brainPin))
|
||||||
|
return getBrainPinIndex(brainPin);
|
||||||
|
|
||||||
|
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin);
|
||||||
|
return EFI_ERROR_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse string representation of physical pin into Gpio ordinal.
|
* Parse string representation of physical pin into Gpio ordinal.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue