Just need a bullet-proof solution which would work regardless of class, struct, typedef struct or not defined type (#5395)
This commit is contained in:
parent
c3a87bc4d3
commit
186080c136
|
@ -39,7 +39,7 @@ DDEFS += -DEFI_SENT_SUPPORT=TRUE
|
|||
|
||||
# TS_SECONDARY_UxART_PORT
|
||||
DDEFS += -DSTM32_SERIAL_USE_USART3=TRUE
|
||||
DDEFS += -DTS_SECONDARY_UxART_PORT=SD3
|
||||
DDEFS += -DTS_SECONDARY_UxART_PORT=SD3 -DEFI_TS_SECONDARY_IS_SERIAL=TRUE
|
||||
|
||||
DDEFS += -DSTM32_I2C_USE_I2C3=TRUE
|
||||
|
||||
|
|
|
@ -27,7 +27,8 @@ ifeq ($(PROJECT_CPU),ARCH_STM32F7)
|
|||
#Linker options, flash size
|
||||
USE_OPT += -Wl,--defsym=FLASH_SIZE=768k
|
||||
# TODO do we only support serial on F7 but not UART?
|
||||
DDEFS += -DEFI_CONSOLE_TX_BRAIN_PIN=Gpio::D6 -DEFI_CONSOLE_RX_BRAIN_PIN=Gpio::D5 -DTS_PRIMARY_UxART_PORT=SD2 -DSTM32_SERIAL_USE_USART2=TRUE -DSTM32_UART_USE_USART2=FALSE
|
||||
DDEFS += -DEFI_CONSOLE_TX_BRAIN_PIN=Gpio::D6 -DEFI_CONSOLE_RX_BRAIN_PIN=Gpio::D5
|
||||
DDEFS += -DTS_PRIMARY_UxART_PORT=SD2 -DEFI_TS_PRIMARY_IS_SERIAL=TRUE -DSTM32_SERIAL_USE_USART2=TRUE -DSTM32_UART_USE_USART2=FALSE
|
||||
else ifeq ($(PROJECT_CPU),ARCH_STM32F4)
|
||||
DDEFS += -DSHORT_BOARD_NAME=alphax-4chan
|
||||
DDEFS += $(PRIMARY_COMMUNICATION_PORT_USART2)
|
||||
|
|
|
@ -31,7 +31,7 @@ USE_FATFS = no
|
|||
|
||||
# TS serial
|
||||
DDEFS += -DSTM32_SERIAL_USE_USART1=TRUE
|
||||
DDEFS += -DTS_PRIMARY_UxART_PORT=SD1
|
||||
DDEFS += -DTS_PRIMARY_UxART_PORT=SD1 -DEFI_TS_PRIMARY_IS_SERIAL=TRUE
|
||||
# WARNING: those are USB pins on discovery or rusEFI brain board so make sure to power those NOT via USB
|
||||
DDEFS += -DEFI_CONSOLE_TX_BRAIN_PIN=Gpio::A9 -DEFI_CONSOLE_RX_BRAIN_PIN=Gpio::A10
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
/* debug console */
|
||||
#define TS_PRIMARY_UxART_PORT SD1
|
||||
#define EFI_TS_PRIMARY_IS_SERIAL TRUE
|
||||
|
||||
/* Knock detection */
|
||||
#undef EFI_HIP_9011
|
||||
|
|
|
@ -14,27 +14,16 @@
|
|||
#include "hellen_meta.h"
|
||||
#endif // HW_HELLEN
|
||||
|
||||
// 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;
|
||||
|
||||
#ifdef TS_PRIMARY_UxART_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_UxART_PORT), UARTDriver>,
|
||||
#if EFI_USE_UART_DMA
|
||||
UartDmaTsChannel,
|
||||
#else // EFI_USE_UART_DMA
|
||||
UartTsChannel,
|
||||
#endif // EFI_USE_UART_DMA
|
||||
SerialTsChannel> primaryChannel(TS_PRIMARY_UxART_PORT);
|
||||
#if EFI_TS_PRIMARY_IS_SERIAL
|
||||
SerialTsChannel
|
||||
#elif EFI_USE_UART_DMA
|
||||
UartDmaTsChannel
|
||||
#else
|
||||
UartTsChannel
|
||||
#endif
|
||||
primaryChannel(TS_PRIMARY_UxART_PORT);
|
||||
|
||||
struct PrimaryChannelThread : public TunerstudioThread {
|
||||
PrimaryChannelThread() : TunerstudioThread("Primary TS Channel") { }
|
||||
|
@ -57,14 +46,14 @@ class SerialTsChannel;
|
|||
#endif // defined(TS_PRIMARY_UxART_PORT)
|
||||
|
||||
#ifdef TS_SECONDARY_UxART_PORT
|
||||
std::conditional_t<
|
||||
std::is_same_v<decltype(TS_SECONDARY_UxART_PORT), UARTDriver>,
|
||||
#if EFI_USE_UART_DMA
|
||||
UartDmaTsChannel,
|
||||
#else // EFI_USE_UART_DMA
|
||||
UartTsChannel,
|
||||
#endif // EFI_USE_UART_DMA
|
||||
SerialTsChannel> secondaryChannel(TS_SECONDARY_UxART_PORT);
|
||||
#if EFI_TS_SECONDARY_IS_SERIAL
|
||||
SerialTsChannel
|
||||
#elif EFI_USE_UART_DMA
|
||||
UartDmaTsChannel
|
||||
#else
|
||||
UartTsChannel
|
||||
#endif
|
||||
secondaryChannel(TS_SECONDARY_UxART_PORT);
|
||||
|
||||
struct SecondaryChannelThread : public TunerstudioThread {
|
||||
SecondaryChannelThread() : TunerstudioThread("Secondary TS Channel") { }
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
|
||||
// see SIM_SD1_PORT and SIM_SD2_PORT
|
||||
#define TS_PRIMARY_UxART_PORT SD1
|
||||
#define EFI_TS_PRIMARY_IS_SERIAL TRUE
|
||||
#define TS_SECONDARY_UxART_PORT SD2
|
||||
#define EFI_TS_SECONDARY_IS_SERIAL TRUE
|
||||
|
||||
#define EFI_ENABLE_ASSERTS TRUE
|
||||
#define EFI_LAUNCH_CONTROL TRUE
|
||||
|
|
Loading…
Reference in New Issue