diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index 7a7121e775..b3459dece4 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -292,6 +292,9 @@ #define GPS_SERIAL_DEVICE &SD1 #define GPS_SERIAL_SPEED 38400 +#define CONSOLE_MODE_SWITCH_PORT GPIOB +#define CONSOLE_MODE_SWITCH_PIN 1 + #define CONFIG_RESET_SWITCH_PORT GPIOD #define CONFIG_RESET_SWITCH_PIN 6 diff --git a/firmware/console/console_io.cpp b/firmware/console/console_io.cpp index 281f21d3c6..7aca4d41b2 100644 --- a/firmware/console/console_io.cpp +++ b/firmware/console/console_io.cpp @@ -131,8 +131,10 @@ static bool getConsoleLine(BaseSequentialStream *chp, char *line, unsigned size) CommandHandler console_line_callback; +static bool is_serial_over_uart; + bool isSerialOverUart(void) { - return false; + return is_serial_over_uart; } #if (defined(EFI_CONSOLE_UART_DEVICE) && ! EFI_SIMULATOR ) || defined(__DOXYGEN__) @@ -246,6 +248,10 @@ void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p) #if (defined(EFI_CONSOLE_UART_DEVICE) && ! EFI_SIMULATOR) || defined(__DOXYGEN__) + palSetPadMode(CONSOLE_MODE_SWITCH_PORT, CONSOLE_MODE_SWITCH_PIN, PAL_MODE_INPUT_PULLUP); + + is_serial_over_uart = GET_CONSOLE_MODE_VALUE() == EFI_USE_UART_FOR_CONSOLE; + if (isSerialOverUart()) { /* * Activates the serial using the driver default configuration (that's 38400) diff --git a/firmware/console/console_io.h b/firmware/console/console_io.h index 4c42c15869..07817a5599 100644 --- a/firmware/console/console_io.h +++ b/firmware/console/console_io.h @@ -17,6 +17,7 @@ typedef void (*CommandHandler)(char *); #include "datalogging.h" // todo: make this pin configurable +#define GET_CONSOLE_MODE_VALUE() palReadPad(CONSOLE_MODE_SWITCH_PORT, CONSOLE_MODE_SWITCH_PIN) #define SHOULD_INGORE_FLASH() (palReadPad(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN) == 0) SerialDriver * getConsoleChannel(void);