From 5d6ec1d68b1adac70ff0030cee055eb688290e27 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 2 May 2020 23:47:10 -0400 Subject: [PATCH] refactoring: using brain_pin like the rest of the code --- firmware/config/boards/prometheus/efifeatures.h | 14 ++++++-------- firmware/config/boards/subaru-ej20gn/efifeatures.h | 14 ++++++-------- firmware/config/stm32f4ems/efifeatures.h | 14 ++++---------- firmware/config/stm32f7ems/efifeatures.h | 13 +++++-------- firmware/console/console_io.cpp | 8 ++++---- 5 files changed, 25 insertions(+), 38 deletions(-) diff --git a/firmware/config/boards/prometheus/efifeatures.h b/firmware/config/boards/prometheus/efifeatures.h index d33c8ecbaa..8c948002d9 100644 --- a/firmware/config/boards/prometheus/efifeatures.h +++ b/firmware/config/boards/prometheus/efifeatures.h @@ -68,14 +68,12 @@ #endif -#undef EFI_CONSOLE_TX_PORT -#define EFI_CONSOLE_TX_PORT GPIOA -#undef EFI_CONSOLE_TX_PIN -#define EFI_CONSOLE_TX_PIN 0 -#undef EFI_CONSOLE_RX_PORT -#define EFI_CONSOLE_RX_PORT GPIOA -#undef EFI_CONSOLE_RX_PIN -#define EFI_CONSOLE_RX_PIN 1 +#undef EFI_CONSOLE_TX_BRAIN_PIN +#define EFI_CONSOLE_TX_BRAIN_PIN GPIOA_0 + +#undef EFI_CONSOLE_RX_BRAIN_PIN +#define EFI_CONSOLE_RX_BRAIN_PIN GPIOA_1 + #undef EFI_CONSOLE_AF #define EFI_CONSOLE_AF 8 diff --git a/firmware/config/boards/subaru-ej20gn/efifeatures.h b/firmware/config/boards/subaru-ej20gn/efifeatures.h index 5a9ebc6ef2..cf86f9b2f5 100644 --- a/firmware/config/boards/subaru-ej20gn/efifeatures.h +++ b/firmware/config/boards/subaru-ej20gn/efifeatures.h @@ -57,14 +57,12 @@ #define SERIAL_SPEED 115200 #ifdef EFI_CONSOLE_SERIAL_DEVICE - #undef EFI_CONSOLE_TX_PORT - #define EFI_CONSOLE_TX_PORT GPIOA - #undef EFI_CONSOLE_TX_PIN - #define EFI_CONSOLE_TX_PIN 9 - #undef EFI_CONSOLE_RX_PORT - #define EFI_CONSOLE_RX_PORT GPIOA - #undef EFI_CONSOLE_RX_PIN - #define EFI_CONSOLE_RX_PIN 10 + #undef EFI_CONSOLE_TX_BRAIN_PIN + #define EFI_CONSOLE_TX_BRAIN_PIN GPIOA_9 + + #undef EFI_CONSOLE_RX_BRAIN_PIN + #define EFI_CONSOLE_RX_BRAIN_PIN GPIOA_10 + #undef EFI_CONSOLE_AF #define EFI_CONSOLE_AF 7 #endif diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index 0902dcf416..03795970f0 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -349,18 +349,12 @@ #endif // todo: start using consoleSerialTxPin? Not sure -#ifndef EFI_CONSOLE_TX_PORT -#define EFI_CONSOLE_TX_PORT GPIOC -#endif -#ifndef EFI_CONSOLE_TX_PIN -#define EFI_CONSOLE_TX_PIN 10 +#ifndef EFI_CONSOLE_TX_BRAIN_PIN +#define EFI_CONSOLE_TX_BRAIN_PIN GPIOC_10 #endif // todo: start using consoleSerialRxPin? Not sure -#ifndef EFI_CONSOLE_RX_PORT -#define EFI_CONSOLE_RX_PORT GPIOC -#endif -#ifndef EFI_CONSOLE_RX_PIN -#define EFI_CONSOLE_RX_PIN 11 +#ifndef EFI_CONSOLE_RX_BRAIN_PIN +#define EFI_CONSOLE_RX_BRAIN_PIN GPIOC_11 #endif // todo: this should be detected automatically based on pin selection #define EFI_CONSOLE_AF 7 diff --git a/firmware/config/stm32f7ems/efifeatures.h b/firmware/config/stm32f7ems/efifeatures.h index d80f34fc06..3bfc413a2a 100644 --- a/firmware/config/stm32f7ems/efifeatures.h +++ b/firmware/config/stm32f7ems/efifeatures.h @@ -95,15 +95,12 @@ #endif // todo: start using consoleSerialTxPin? Not sure -#undef EFI_CONSOLE_TX_PORT -#define EFI_CONSOLE_TX_PORT GPIOD -#undef EFI_CONSOLE_TX_PIN -#define EFI_CONSOLE_TX_PIN 8 +#undef EFI_CONSOLE_TX_BRAIN_PIN +#define EFI_CONSOLE_TX_BRAIN_PIN GPIOD_8 + // todo: start using consoleSerialRxPin? Not sure -#undef EFI_CONSOLE_RX_PORT -#define EFI_CONSOLE_RX_PORT GPIOD -#undef EFI_CONSOLE_RX_PIN -#define EFI_CONSOLE_RX_PIN 9 +#undef EFI_CONSOLE_RX_BRAIN_PIN +#define EFI_CONSOLE_RX_BRAIN_PIN GPIOD_9 // todo: temporary ignore errors, this is a test config #define EFI_PRINT_ERRORS_AS_WARNINGS TRUE diff --git a/firmware/console/console_io.cpp b/firmware/console/console_io.cpp index 1d9b232c95..cd1e0d5b1c 100644 --- a/firmware/console/console_io.cpp +++ b/firmware/console/console_io.cpp @@ -269,8 +269,8 @@ void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p) sdStart(EFI_CONSOLE_SERIAL_DEVICE, &serialConfig); // cannot use pin repository here because pin repository prints to console - palSetPadMode(EFI_CONSOLE_RX_PORT, EFI_CONSOLE_RX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); - palSetPadMode(EFI_CONSOLE_TX_PORT, EFI_CONSOLE_TX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); + palSetPadMode(getHwPort("console", EFI_CONSOLE_RX_BRAIN_PIN), getHwPin("console", EFI_CONSOLE_RX_BRAIN_PIN), PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); + palSetPadMode(getHwPort("console", EFI_CONSOLE_TX_BRAIN_PIN), getHwPin("console", EFI_CONSOLE_TX_BRAIN_PIN), PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); isSerialConsoleStarted = true; @@ -280,8 +280,8 @@ void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p) uartStart(EFI_CONSOLE_UART_DEVICE, &uartConfig); // cannot use pin repository here because pin repository prints to console - palSetPadMode(EFI_CONSOLE_RX_PORT, EFI_CONSOLE_RX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); - palSetPadMode(EFI_CONSOLE_TX_PORT, EFI_CONSOLE_TX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); + palSetPadMode(getHwPort("console", EFI_CONSOLE_RX_BRAIN_PIN), getHwPin("console", EFI_CONSOLE_RX_BRAIN_PIN), PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); + palSetPadMode(getHwPort("console", EFI_CONSOLE_TX_BRAIN_PIN), getHwPin("console", EFI_CONSOLE_TX_BRAIN_PIN), PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); isSerialConsoleStarted = true; #endif /* EFI_CONSOLE_SERIAL_DEVICE || EFI_CONSOLE_UART_DEVICE */