Expose console over serial port for H7 proc (#3578)
This way you can use the console/TunerStudio with the ST-Link In the process, combine TS_PRIMARY_UART and TS_PRIMARY_SERIAL into TS_PRIMARY_PORT, to make UART vs SERIAL selection more robus. Ditto for TS_SECONDARY_*. Also change use of TS_NO_PRIMARY to be #if not #ifdef, so that it can be properly set as a compile flag and not be overwritten by various header files.
This commit is contained in:
parent
03b13af2db
commit
8406fafa9e
|
@ -7,7 +7,7 @@
|
|||
#include "dfu.h"
|
||||
|
||||
// Communication vars
|
||||
static UartTsChannel blTsChannel(TS_PRIMARY_UART);
|
||||
static UartTsChannel blTsChannel(TS_PRIMARY_PORT);
|
||||
static uint8_t buffer[DFU_BUFFER_SIZE];
|
||||
// Use short timeout for the first data packet, and normal timeout for the rest
|
||||
static int sr5Timeout = DFU_SR5_TIMEOUT_FIRST;
|
||||
|
|
|
@ -11,7 +11,7 @@ DDEFS += -DFIRMWARE_ID=\"atlas\" -DDEFAULT_ENGINE_TYPE=MINIMAL_PINS
|
|||
# DEFS += -DEFI_SOFTWARE_KNOCK=TRUE
|
||||
|
||||
# disable hardware serial ports on H7
|
||||
# DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
|
||||
# DDEFS += -DTS_NO_PRIMARY=1 -DTS_NO_SECONDARY=1
|
||||
|
||||
# We are running on Atlas hardware!
|
||||
DDEFS += -DHW_ATLAS=1
|
||||
|
|
|
@ -31,7 +31,7 @@ DDEFS += -DEFI_ICU_INPUTS=FALSE -DHAL_TRIGGER_USE_PAL=TRUE
|
|||
DDEFS += -DEFI_LOGIC_ANALYZER=FALSE
|
||||
|
||||
# Enable serial pins on expansion header
|
||||
DDEFS += -DEFI_CONSOLE_TX_BRAIN_PIN=GPIOD_6 -DEFI_CONSOLE_RX_BRAIN_PIN=GPIOD_5 -DTS_PRIMARY_UART=UARTD2 -DSTM32_UART_USE_USART2=1
|
||||
DDEFS += -DEFI_CONSOLE_TX_BRAIN_PIN=GPIOD_6 -DEFI_CONSOLE_RX_BRAIN_PIN=GPIOD_5 -DTS_PRIMARY_PORT=UARTD2 -DSTM32_UART_USE_USART2=1
|
||||
|
||||
# We are running on Hellen-One hardware!
|
||||
DDEFS += -DHW_HELLEN=1
|
||||
|
|
|
@ -22,7 +22,7 @@ DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
|||
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
||||
|
||||
# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card
|
||||
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
|
||||
DDEFS += -DTS_NO_PRIMARY=1 -DTS_NO_SECONDARY=1
|
||||
|
||||
# Add them all together
|
||||
DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"hellen121nissan\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(LED_COMMUNICATION_BRAIN_PIN)
|
||||
|
|
|
@ -22,7 +22,7 @@ DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
|||
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
||||
|
||||
# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card
|
||||
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
|
||||
DDEFS += -DTS_NO_PRIMARY=1 -DTS_NO_SECONDARY=1
|
||||
|
||||
# Add them all together
|
||||
DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"hellen121vag\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(LED_COMMUNICATION_BRAIN_PIN)
|
||||
|
|
|
@ -22,7 +22,7 @@ DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
|||
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
||||
|
||||
# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card
|
||||
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
|
||||
DDEFS += -DTS_NO_PRIMARY=1 -DTS_NO_SECONDARY=1
|
||||
|
||||
# Add them all together
|
||||
DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"hellen128\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(LED_COMMUNICATION_BRAIN_PIN)
|
||||
|
|
|
@ -22,7 +22,7 @@ DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
|||
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
||||
|
||||
# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card
|
||||
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
|
||||
DDEFS += -DTS_NO_PRIMARY=1 -DTS_NO_SECONDARY=1
|
||||
|
||||
# Add them all together
|
||||
DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"hellen154hyundai\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(LED_COMMUNICATION_BRAIN_PIN)
|
||||
|
|
|
@ -22,7 +22,7 @@ DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
|||
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
||||
|
||||
# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card
|
||||
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
|
||||
DDEFS += -DTS_NO_PRIMARY=1 -DTS_NO_SECONDARY=1
|
||||
|
||||
# Add them all together
|
||||
DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"hellenNA6\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(LED_COMMUNICATION_BRAIN_PIN)
|
||||
|
|
|
@ -22,7 +22,7 @@ DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
|||
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
||||
|
||||
# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card
|
||||
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
|
||||
DDEFS += -DTS_NO_PRIMARY=1 -DTS_NO_SECONDARY=1
|
||||
|
||||
# Add them all together
|
||||
DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"hellen72\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(LED_COMMUNICATION_BRAIN_PIN)
|
||||
|
|
|
@ -25,7 +25,7 @@ DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
|||
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
||||
|
||||
# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card
|
||||
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
|
||||
DDEFS += -DTS_NO_PRIMARY=1 -DTS_NO_SECONDARY=1
|
||||
|
||||
# Add them all together
|
||||
DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"hellen81\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(LED_COMMUNICATION_BRAIN_PIN)
|
||||
|
|
|
@ -22,7 +22,7 @@ DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
|||
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
||||
|
||||
# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card
|
||||
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
|
||||
DDEFS += -DTS_NO_PRIMARY=1 -DTS_NO_SECONDARY=1
|
||||
|
||||
# Add them all together
|
||||
DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"hellen88bmw\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(LED_COMMUNICATION_BRAIN_PIN)
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# List of all the board related files.
|
||||
|
||||
DDEFS = -DTS_NO_PRIMARY=0 \
|
||||
-DTS_PRIMARY_PORT=SD3 \
|
||||
-DEFI_CONSOLE_TX_BRAIN_PIN=GPIOD_8 \
|
||||
-DEFI_CONSOLE_RX_BRAIN_PIN=GPIOD_9 \
|
||||
|
||||
|
||||
# Shared variables
|
||||
ALLCPPSRC += $(PROJECT_DIR)/config/boards/nucleo_h743/board_configuration.cpp
|
||||
|
||||
|
|
|
@ -34,15 +34,13 @@
|
|||
|
||||
#define ADC_CHANNEL_VREF ADC_CHANNEL_IN14
|
||||
|
||||
#undef TS_PRIMARY_SERIAL
|
||||
#undef TS_PRIMARY_UART
|
||||
#define TS_PRIMARY_UART UARTD4
|
||||
#undef TS_PRIMARY_PORT
|
||||
#define TS_PRIMARY_PORT UARTD4
|
||||
|
||||
#undef EFI_UART_GPS
|
||||
#define EFI_UART_GPS FALSE
|
||||
|
||||
#undef TS_SECONDARY_UART
|
||||
#undef TS_SECONDARY_SERIAL
|
||||
#undef TS_SECONDARY_PORT
|
||||
|
||||
#undef EFI_BLUETOOTH_SETUP
|
||||
#define EFI_BLUETOOTH_SETUP TRUE
|
||||
|
|
|
@ -32,7 +32,7 @@ endif
|
|||
ifeq ($(PROJECT_CPU),ARCH_STM32F4)
|
||||
# Hardware serial port on UART 2 -> PD5/PD6
|
||||
DDEFS += -DSTM32_UART_USE_USART2=TRUE
|
||||
DDEFS += -DTS_PRIMARY_UART=UARTD2
|
||||
DDEFS += -DTS_PRIMARY_PORT=UARTD2
|
||||
DDEFS += -DEFI_CONSOLE_TX_BRAIN_PIN=GPIOD_5 -DEFI_CONSOLE_RX_BRAIN_PIN=GPIOD_6
|
||||
endif
|
||||
|
||||
|
|
|
@ -21,13 +21,11 @@
|
|||
#define LED_RUNING_BRAIN_PIN_MODE INVERTED_OUTPUT
|
||||
|
||||
/* debug console */
|
||||
#undef TS_PRIMARY_SERIAL
|
||||
#undef TS_PRIMARY_UART
|
||||
#define TS_PRIMARY_SERIAL SD1
|
||||
#undef TS_PRIMARY_PORT
|
||||
#define TS_PRIMARY_PORT SD1
|
||||
|
||||
// no secondary channel
|
||||
#undef TS_SECONDARY_UART
|
||||
#undef TS_SECONDARY_SERIAL
|
||||
#undef TS_SECONDARY_PORT
|
||||
|
||||
/* Knock detection */
|
||||
#undef EFI_HIP_9011
|
||||
|
@ -94,7 +92,7 @@
|
|||
#undef SERIAL_SPEED
|
||||
#define SERIAL_SPEED 115200
|
||||
|
||||
#ifdef TS_PRIMARY_SERIAL
|
||||
#ifdef TS_PRIMARY_PORT
|
||||
#undef EFI_CONSOLE_TX_PORT
|
||||
#define EFI_CONSOLE_TX_PORT GPIOA
|
||||
#undef EFI_CONSOLE_TX_PIN
|
||||
|
|
|
@ -360,11 +360,11 @@
|
|||
#define EFI_USE_UART_DMA TRUE
|
||||
#endif
|
||||
|
||||
#ifndef TS_PRIMARY_UART
|
||||
#define TS_PRIMARY_UART UARTD3
|
||||
#ifndef TS_PRIMARY_PORT
|
||||
#define TS_PRIMARY_PORT UARTD3
|
||||
#endif
|
||||
|
||||
#undef TS_SECONDARY_UART
|
||||
#undef TS_SECONDARY_PORT
|
||||
|
||||
#define AUX_SERIAL_DEVICE (&SD6)
|
||||
|
||||
|
|
|
@ -37,8 +37,10 @@
|
|||
#define EFI_USE_UART_DMA FALSE
|
||||
|
||||
// UART driver not implemented on F7
|
||||
#define TS_NO_PRIMARY
|
||||
#define TS_NO_SECONDARY
|
||||
#ifndef TS_NO_PRIMARY
|
||||
#define TS_NO_PRIMARY 1
|
||||
#endif
|
||||
#define TS_NO_SECONDARY 1
|
||||
|
||||
#define AUX_SERIAL_DEVICE (&SD6)
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
#pragma once
|
||||
#include "global.h"
|
||||
|
||||
#if (!defined(TS_NO_PRIMARY) && (defined(TS_PRIMARY_UART) || defined(TS_PRIMARY_SERIAL)))
|
||||
#if (!TS_NO_PRIMARY && defined(TS_PRIMARY_PORT))
|
||||
#define HAS_PRIMARY true
|
||||
#else
|
||||
#define HAS_PRIMARY false
|
||||
#endif
|
||||
|
||||
#if (!defined(TS_NO_SECONDARY) && (defined(TS_SECONDARY_UART) || defined(TS_SECONDARY_SERIAL)))
|
||||
#if (!TS_NO_SECONDARY && defined(TS_SECONDARY_PORT))
|
||||
#define HAS_SECONDARY true
|
||||
#else
|
||||
#define HAS_SECONDARY false
|
||||
|
|
|
@ -11,16 +11,29 @@
|
|||
#include "tunerstudio_io.h"
|
||||
#include "connector_uart_dma.h"
|
||||
|
||||
// These may not be defined due to the HAL, but they're necessary for the compiler to do it's magic
|
||||
class UARTDriver;
|
||||
class UartDmaTsChannel;
|
||||
class UartTsChannel;
|
||||
class SerialTsChannel;
|
||||
|
||||
#if HAS_PRIMARY
|
||||
#ifdef TS_PRIMARY_UART
|
||||
#if EFI_USE_UART_DMA
|
||||
UartDmaTsChannel primaryChannel(TS_PRIMARY_UART);
|
||||
#else
|
||||
UartTsChannel primaryChannel(TS_PRIMARY_UART);
|
||||
#endif
|
||||
#elif defined(TS_PRIMARY_SERIAL)
|
||||
SerialTsChannel primaryChannel(TS_PRIMARY_SERIAL);
|
||||
#endif
|
||||
#ifdef TS_PRIMARY_PORT
|
||||
|
||||
// We want to instantiate the correct channel type depending on what type of serial port we're
|
||||
// using. ChibiOS supports two - UART and Serial. We compare the type of the port we're given
|
||||
// against UartDriver and decide whether to instantiate a UART TS Channel or a Serial version. The
|
||||
// UART is further subdivided into two depending whether we support DMA or not. We use the right
|
||||
// combination of std::conditional, std::is_same, and #if to get what we want.
|
||||
std::conditional_t<
|
||||
std::is_same_v<decltype(TS_PRIMARY_PORT), UARTDriver>,
|
||||
#if EFI_USE_UART_DMA
|
||||
UartDmaTsChannel,
|
||||
#else // EFI_USE_UART_DMA
|
||||
UartTsChannel,
|
||||
#endif // EFI_USE_UART_DMA
|
||||
SerialTsChannel> primaryChannel(TS_PRIMARY_PORT);
|
||||
#endif // TS_PRIMARY_PORT
|
||||
|
||||
struct PrimaryChannelThread : public TunerstudioThread {
|
||||
PrimaryChannelThread() : TunerstudioThread("Primary TS Channel") { }
|
||||
|
@ -41,15 +54,17 @@
|
|||
#endif // HAS_PRIMARY
|
||||
|
||||
#if HAS_SECONDARY
|
||||
#ifdef TS_SECONDARY_UART
|
||||
#if EFI_USE_UART_DMA
|
||||
UartDmaTsChannel secondaryChannel(TS_SECONDARY_UART);
|
||||
#else
|
||||
UartTsChannel secondaryChannel(TS_SECONDARY_UART);
|
||||
#endif
|
||||
#elif defined(TS_SECONDARY_SERIAL)
|
||||
SerialTsChannel secondaryChannel(TS_SECONDARY_SERIAL);
|
||||
#endif
|
||||
#ifdef TS_SECONDARY_PORT
|
||||
std::conditional_t<
|
||||
std::is_same_v<decltype(TS_SECONDARY_PORT), UARTDriver>,
|
||||
#if EFI_USE_UART_DMA
|
||||
UartDmaTsChannel,
|
||||
#else // EFI_USE_UART_DMA
|
||||
UartTsChannel,
|
||||
#endif // EFI_USE_UART_DMA
|
||||
SerialTsChannel> secondaryChannel(TS_SECONDARY_PORT);
|
||||
#endif // TS_SECONDARY_PORT
|
||||
|
||||
|
||||
struct SecondaryChannelThread : public TunerstudioThread {
|
||||
SecondaryChannelThread() : TunerstudioThread("Secondary TS Channel") { }
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
*/
|
||||
#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
|
||||
/* Configured in efifeatures.h */
|
||||
#if defined(TS_PRIMARY_UART) || defined(TS_PRIMARY_SERIAL)
|
||||
#if defined(TS_PRIMARY_PORT)
|
||||
#define HAL_USE_UART TRUE
|
||||
#else
|
||||
#define HAL_USE_UART FALSE
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
*/
|
||||
#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
|
||||
/* Configured in efifeatures.h */
|
||||
#if defined(TS_PRIMARY_UART) || defined(TS_PRIMARY_SERIAL)
|
||||
#if defined(TS_PRIMARY_PORT)
|
||||
#define HAL_USE_UART TRUE
|
||||
#else
|
||||
#define HAL_USE_UART FALSE
|
||||
|
@ -200,7 +200,7 @@
|
|||
*/
|
||||
#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
|
||||
/* Configured in efifeatures.h */
|
||||
#if defined(TS_PRIMARY_UART) || defined(TS_PRIMARY_SERIAL)
|
||||
#if defined(TS_PRIMARY_PORT)
|
||||
#define UART_USE_WAIT TRUE
|
||||
#else
|
||||
#define UART_USE_WAIT FALSE
|
||||
|
|
|
@ -385,7 +385,7 @@
|
|||
*/
|
||||
#define STM32_SERIAL_USE_USART1 TRUE
|
||||
#define STM32_SERIAL_USE_USART2 TRUE
|
||||
#define STM32_SERIAL_USE_USART3 FALSE
|
||||
#define STM32_SERIAL_USE_USART3 TRUE
|
||||
#define STM32_SERIAL_USE_UART4 FALSE
|
||||
#define STM32_SERIAL_USE_UART5 FALSE
|
||||
#define STM32_SERIAL_USE_USART6 TRUE
|
||||
|
|
Loading…
Reference in New Issue