WiP
This commit is contained in:
@@ -31,7 +31,7 @@ if(PCB STREQUAL X9E)
|
||||
top_lcd_driver.cpp
|
||||
startup_stm32f40_41xxx.s
|
||||
)
|
||||
set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp)
|
||||
set(AUX_SERIAL ON)
|
||||
if(STICKS STREQUAL HORUS)
|
||||
add_definitions(-DHORUS_STICKS)
|
||||
endif()
|
||||
@@ -90,7 +90,7 @@ elseif(PCB STREQUAL X9D+)
|
||||
set(CPU_TYPE_FULL STM32F205xE) # for size report
|
||||
add_definitions(-DSTM32F205xx)
|
||||
set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld)
|
||||
set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp)
|
||||
set(AUX_SERIAL ON)
|
||||
set(STATUS_LEDS NO)
|
||||
endif()
|
||||
elseif(PCB STREQUAL X9D)
|
||||
@@ -110,7 +110,7 @@ elseif(PCB STREQUAL X9D)
|
||||
set(BITMAPS_TARGET taranis_bitmaps)
|
||||
set(FONTS_TARGET taranis_fonts)
|
||||
set(LCD_DRIVER lcd_driver_aspi.cpp)
|
||||
set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp)
|
||||
set(AUX_SERIAL ON)
|
||||
set(GVAR_SCREEN model_gvars.cpp)
|
||||
set(STATUS_LEDS NO)
|
||||
add_definitions(-DMANUFACTURER_FRSKY)
|
||||
@@ -207,7 +207,7 @@ elseif(PCB STREQUAL X7)
|
||||
set(LUA_EXPORT lua_export_zorro)
|
||||
set(BLUETOOTH NO)
|
||||
set(USB_CHARGER YES)
|
||||
set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp)
|
||||
set(AUX_SERIAL ON)
|
||||
add_definitions(-DRADIO_ZORRO)
|
||||
add_definitions(-DEEPROM_VARIANT=0x4006)
|
||||
add_definitions(-DMANUFACTURER_RADIOMASTER)
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
|
||||
#include "../common/arm/stm32/timers_driver.h"
|
||||
|
||||
#if defined(AUX_SERIAL)
|
||||
#include "aux_serial_driver.h"
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -223,10 +227,7 @@ void boardInit()
|
||||
i2cInit();
|
||||
usbInit();
|
||||
|
||||
#if defined(DEBUG) && defined(AUX_SERIAL_GPIO)
|
||||
auxSerialInit(0, 0); // default serial mode (None if DEBUG not defined)
|
||||
TRACE("\nTaranis board started :)");
|
||||
#endif
|
||||
initSerialPorts();
|
||||
|
||||
#if defined(HAPTIC)
|
||||
hapticInit();
|
||||
@@ -415,3 +416,26 @@ void initJackDetect(void)
|
||||
GPIO_Init(JACK_DETECT_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUX_SERIAL)
|
||||
const etx_serial_port_t auxSerialPort = {
|
||||
&AuxSerialDriver,
|
||||
nullptr
|
||||
};
|
||||
#define AUX_SERIAL_PORT &auxSerialPort
|
||||
#else
|
||||
#define AUX_SERIAL_PORT nullptr
|
||||
#endif
|
||||
|
||||
#define AUX2_SERIAL_PORT nullptr
|
||||
|
||||
static const etx_serial_port_t* serialPorts[MAX_AUX_SERIAL] = {
|
||||
AUX_SERIAL_PORT,
|
||||
AUX2_SERIAL_PORT,
|
||||
};
|
||||
|
||||
const etx_serial_port_t* auxSerialGetPort(int port_nr)
|
||||
{
|
||||
if (port_nr >= MAX_AUX_SERIAL) return nullptr;
|
||||
return serialPorts[port_nr];
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "opentx_constants.h"
|
||||
#include "board_common.h"
|
||||
#include "hal.h"
|
||||
#include "hal/serial_port.h"
|
||||
|
||||
#include "watchdog_driver.h"
|
||||
|
||||
@@ -164,26 +165,20 @@ uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
#define init_trainer_capture()
|
||||
#define stop_trainer_capture()
|
||||
#endif
|
||||
|
||||
#if defined(TRAINER_MODULE_CPPM)
|
||||
void init_trainer_module_cppm();
|
||||
void stop_trainer_module_cppm();
|
||||
#else
|
||||
#define init_trainer_module_cppm()
|
||||
#define stop_trainer_module_cppm()
|
||||
#endif
|
||||
|
||||
#if defined(TRAINER_MODULE_SBUS)
|
||||
void init_trainer_module_sbus();
|
||||
void stop_trainer_module_sbus();
|
||||
#else
|
||||
#define init_trainer_module_sbus()
|
||||
#define stop_trainer_module_sbus()
|
||||
int trainerModuleSbusGetByte(uint8_t* byte);
|
||||
#endif
|
||||
|
||||
void check_telemetry_exti();
|
||||
|
||||
// SBUS
|
||||
int sbusGetByte(uint8_t * byte);
|
||||
|
||||
// Keys driver
|
||||
enum EnumKeys
|
||||
{
|
||||
@@ -775,7 +770,7 @@ void sportSendByte(uint8_t byte);
|
||||
void sportSendByteLoop(uint8_t byte);
|
||||
void sportStopSendByteLoop();
|
||||
void sportSendBuffer(const uint8_t * buffer, uint32_t count);
|
||||
bool telemetryGetByte(uint8_t * byte);
|
||||
bool sportGetByte(uint8_t * byte);
|
||||
void telemetryClearFifo();
|
||||
extern uint32_t telemetryErrors;
|
||||
|
||||
@@ -860,15 +855,10 @@ void hapticOff();
|
||||
void hapticOn();
|
||||
#endif
|
||||
|
||||
// Aux serial port driver
|
||||
#if defined(AUX_SERIAL_GPIO)
|
||||
#define DEBUG_BAUDRATE 115200
|
||||
#define LUA_DEFAULT_BAUDRATE 115200
|
||||
#define AUX_SERIAL
|
||||
#define auxSerialTelemetryInit(protocol) auxSerialInit(UART_MODE_TELEMETRY, protocol)
|
||||
#define AUX_SERIAL_POWER_ON()
|
||||
#define AUX_SERIAL_POWER_OFF()
|
||||
#endif
|
||||
|
||||
const etx_serial_port_t* auxSerialGetPort(int port_nr);
|
||||
|
||||
// BT driver
|
||||
#define BLUETOOTH_BOOTLOADER_BAUDRATE 230400
|
||||
|
||||
@@ -1929,14 +1929,14 @@
|
||||
#define TRAINER_MODULE_CPPM_TIMER_IRQn TRAINER_TIMER_IRQn
|
||||
#define TRAINER_MODULE_CPPM_GPIO_AF GPIO_AF_TIM3
|
||||
// Trainer SBUS input on heartbeat pin
|
||||
#define TRAINER_MODULE_SBUS
|
||||
#define TRAINER_MODULE_SBUS_GPIO_AF GPIO_AF_USART6
|
||||
#define TRAINER_MODULE_SBUS_USART USART6
|
||||
#define TRAINER_MODULE_SBUS_GPIO INTMODULE_HEARTBEAT_GPIO
|
||||
#define TRAINER_MODULE_SBUS_GPIO_PIN INTMODULE_HEARTBEAT_GPIO_PIN
|
||||
#define TRAINER_MODULE_SBUS_GPIO_PinSource INTMODULE_HEARTBEAT_EXTI_PinSource
|
||||
#define TRAINER_MODULE_SBUS_DMA_STREAM DMA2_Stream1
|
||||
#define TRAINER_MODULE_SBUS_DMA_CHANNEL DMA_Channel_5
|
||||
// #define TRAINER_MODULE_SBUS
|
||||
// #define TRAINER_MODULE_SBUS_GPIO_AF GPIO_AF_USART6
|
||||
// #define TRAINER_MODULE_SBUS_USART USART6
|
||||
// #define TRAINER_MODULE_SBUS_GPIO INTMODULE_HEARTBEAT_GPIO
|
||||
// #define TRAINER_MODULE_SBUS_GPIO_PIN INTMODULE_HEARTBEAT_GPIO_PIN
|
||||
// #define TRAINER_MODULE_SBUS_GPIO_PinSource INTMODULE_HEARTBEAT_EXTI_PinSource
|
||||
// #define TRAINER_MODULE_SBUS_DMA_STREAM DMA2_Stream1
|
||||
// #define TRAINER_MODULE_SBUS_DMA_CHANNEL DMA_Channel_5
|
||||
#else
|
||||
// TODO: replace SBUS trainer with S.PORT pin
|
||||
#define TRAINER_MODULE_RCC_AHB1Periph 0
|
||||
|
||||
@@ -393,22 +393,12 @@ extern "C" void TELEMETRY_TIMER_IRQHandler()
|
||||
telemetryPortInvertedRxBit();
|
||||
}
|
||||
|
||||
// TODO we should have telemetry in an higher layer, functions above should move to a sport_driver.cpp
|
||||
bool telemetryGetByte(uint8_t * byte)
|
||||
// TODO: we should have telemetry in an higher layer,
|
||||
// functions above should move to a sport_driver.cpp
|
||||
//
|
||||
bool sportGetByte(uint8_t * byte)
|
||||
{
|
||||
#if defined(AUX_SERIAL)
|
||||
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_D_SECONDARY) {
|
||||
if (auxSerialMode == UART_MODE_TELEMETRY)
|
||||
return auxSerialRxFifo.pop(*byte);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return telemetryFifo.pop(*byte);
|
||||
}
|
||||
#else
|
||||
return telemetryFifo.pop(*byte);
|
||||
#endif
|
||||
}
|
||||
|
||||
void telemetryClearFifo()
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
#if defined(TRAINER_MODULE_SBUS_USART)
|
||||
DMAFifo<32> trainerSbusFifo __DMA (TRAINER_MODULE_SBUS_DMA_STREAM);
|
||||
#endif
|
||||
|
||||
void trainerSendNextFrame();
|
||||
|
||||
#if defined(TRAINER_GPIO)
|
||||
@@ -267,7 +263,11 @@ void stop_trainer_module_cppm()
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: use external module serial driver
|
||||
#if defined(TRAINER_MODULE_SBUS)
|
||||
|
||||
static DMAFifo<32> trainerSbusFifo __DMA (TRAINER_MODULE_SBUS_DMA_STREAM);
|
||||
|
||||
void init_trainer_module_sbus()
|
||||
{
|
||||
EXTERNAL_MODULE_ON();
|
||||
@@ -328,22 +328,9 @@ void stop_trainer_module_sbus()
|
||||
EXTERNAL_MODULE_OFF();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SBUS_TRAINER)
|
||||
int sbusGetByte(uint8_t * byte)
|
||||
int trainerModuleSbusGetByte(uint8_t* byte)
|
||||
{
|
||||
switch (currentTrainerMode) {
|
||||
#if defined(TRAINER_MODULE_SBUS_USART)
|
||||
case TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE:
|
||||
return trainerSbusFifo.pop(*byte);
|
||||
#endif
|
||||
#if defined(AUX_SERIAL_USART)
|
||||
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
||||
return auxSerialRxFifo.pop(*byte);
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return trainerSbusFifo.pop(*byte);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user