mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 17:55:19 +03:00
parent
94ba22a74d
commit
0eb203e827
9 changed files with 96 additions and 19 deletions
|
@ -372,7 +372,7 @@ bool menuRadioHardware(event_t event)
|
||||||
#if defined(RADIO_TX16S)
|
#if defined(RADIO_TX16S)
|
||||||
lcdDrawText(lcdNextPos, y, " (TTL)");
|
lcdDrawText(lcdNextPos, y, " (TTL)");
|
||||||
#endif
|
#endif
|
||||||
g_eeGeneral.auxSerialMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_AUX_SERIAL_MODES, g_eeGeneral.auxSerialMode, 0, UART_MODE_MAX, attr, event);
|
g_eeGeneral.auxSerialMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_AUX_SERIAL_MODES, g_eeGeneral.auxSerialMode, 0, UART_MODE_MAX, attr, event, isAux1ModeAvailable);
|
||||||
if (attr && checkIncDec_Ret) {
|
if (attr && checkIncDec_Ret) {
|
||||||
auxSerialInit(g_eeGeneral.auxSerialMode, modelTelemetryProtocol());
|
auxSerialInit(g_eeGeneral.auxSerialMode, modelTelemetryProtocol());
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ bool menuRadioHardware(event_t event)
|
||||||
#if defined(RADIO_TX16S)
|
#if defined(RADIO_TX16S)
|
||||||
lcdDrawText(lcdNextPos, y, " (TTL)");
|
lcdDrawText(lcdNextPos, y, " (TTL)");
|
||||||
#endif
|
#endif
|
||||||
g_eeGeneral.aux2SerialMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_AUX_SERIAL_MODES, g_eeGeneral.aux2SerialMode, 0, UART_MODE_MAX, attr, event);
|
g_eeGeneral.aux2SerialMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_AUX_SERIAL_MODES, g_eeGeneral.aux2SerialMode, 0, UART_MODE_MAX, attr, event, isAux2ModeAvailable);
|
||||||
if (attr && checkIncDec_Ret) {
|
if (attr && checkIncDec_Ret) {
|
||||||
aux2SerialInit(g_eeGeneral.aux2SerialMode, modelTelemetryProtocol());
|
aux2SerialInit(g_eeGeneral.aux2SerialMode, modelTelemetryProtocol());
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,6 +385,24 @@ bool isSwitchAvailable(int swtch, SwitchContext context)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isAux1ModeAvailable(int mode)
|
||||||
|
{
|
||||||
|
#if defined(AUX2_SERIAL)
|
||||||
|
if (mode == UART_MODE_SBUS_TRAINER)
|
||||||
|
return g_eeGeneral.aux2SerialMode != UART_MODE_SBUS_TRAINER;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAux2ModeAvailable(int mode)
|
||||||
|
{
|
||||||
|
#if defined(AUX_SERIAL)
|
||||||
|
if (mode == UART_MODE_SBUS_TRAINER)
|
||||||
|
return g_eeGeneral.auxSerialMode != UART_MODE_SBUS_TRAINER;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool isSwitchAvailableInLogicalSwitches(int swtch)
|
bool isSwitchAvailableInLogicalSwitches(int swtch)
|
||||||
{
|
{
|
||||||
return isSwitchAvailable(swtch, LogicalSwitchesContext);
|
return isSwitchAvailable(swtch, LogicalSwitchesContext);
|
||||||
|
|
|
@ -70,6 +70,8 @@ bool isSourceAvailableInGlobalFunctions(int source);
|
||||||
bool isSourceAvailableInCustomSwitches(int source);
|
bool isSourceAvailableInCustomSwitches(int source);
|
||||||
bool isSourceAvailableInResetSpecialFunction(int index);
|
bool isSourceAvailableInResetSpecialFunction(int index);
|
||||||
bool isSourceAvailableInGlobalResetSpecialFunction(int index);
|
bool isSourceAvailableInGlobalResetSpecialFunction(int index);
|
||||||
|
bool isAux1ModeAvailable(int mode);
|
||||||
|
bool isAux2ModeAvailable(int mode);
|
||||||
bool isSwitchAvailableInLogicalSwitches(int swtch);
|
bool isSwitchAvailableInLogicalSwitches(int swtch);
|
||||||
bool isSwitchAvailableInCustomFunctions(int swtch);
|
bool isSwitchAvailableInCustomFunctions(int swtch);
|
||||||
bool isSwitchAvailableInMixes(int swtch);
|
bool isSwitchAvailableInMixes(int swtch);
|
||||||
|
|
|
@ -21,12 +21,16 @@
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "targets/horus/board.h"
|
#include "targets/horus/board.h"
|
||||||
|
|
||||||
|
#if defined(SBUS)
|
||||||
|
extern Fifo<uint8_t, 32> trainerSbusFifo;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(AUX_SERIAL)
|
#if defined(AUX_SERIAL)
|
||||||
uint8_t auxSerialMode = 0;
|
uint8_t auxSerialMode = 0;
|
||||||
Fifo<uint8_t, 512> auxSerialTxFifo;
|
Fifo<uint8_t, 512> auxSerialTxFifo;
|
||||||
AuxSerialRxFifo auxSerialRxFifo __DMA (AUX_SERIAL_DMA_Stream_RX);
|
AuxSerialRxFifo auxSerialRxFifo __DMA (AUX_SERIAL_DMA_Stream_RX);
|
||||||
|
|
||||||
void auxSerialSetup(unsigned int baudrate, bool dma)
|
void auxSerialSetup(unsigned int baudrate, bool dma, uint16_t lenght = USART_WordLength_8b, uint16_t parity = USART_Parity_No, uint16_t stop = USART_StopBits_1)
|
||||||
{
|
{
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
@ -49,9 +53,9 @@ void auxSerialSetup(unsigned int baudrate, bool dma)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USART_InitStructure.USART_BaudRate = baudrate;
|
USART_InitStructure.USART_BaudRate = baudrate;
|
||||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
USART_InitStructure.USART_WordLength = lenght;
|
||||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
USART_InitStructure.USART_StopBits = stop;
|
||||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
USART_InitStructure.USART_Parity = parity;
|
||||||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
USART_Init(AUX_SERIAL_USART, &USART_InitStructure);
|
USART_Init(AUX_SERIAL_USART, &USART_InitStructure);
|
||||||
|
@ -123,6 +127,11 @@ void auxSerialInit(unsigned int mode, unsigned int protocol)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case UART_MODE_SBUS_TRAINER:
|
||||||
|
auxSerialSetup(SBUS_BAUDRATE, false, USART_WordLength_9b, USART_Parity_Even, USART_StopBits_2); // 2 stop bits requires USART_WordLength_9b
|
||||||
|
AUX_SERIAL_POWER_ON();
|
||||||
|
break;
|
||||||
|
|
||||||
case UART_MODE_LUA:
|
case UART_MODE_LUA:
|
||||||
auxSerialSetup(DEBUG_BAUDRATE, false);
|
auxSerialSetup(DEBUG_BAUDRATE, false);
|
||||||
AUX_SERIAL_POWER_ON();
|
AUX_SERIAL_POWER_ON();
|
||||||
|
@ -144,9 +153,7 @@ void auxSerialPutc(char c)
|
||||||
|
|
||||||
void auxSerialSbusInit()
|
void auxSerialSbusInit()
|
||||||
{
|
{
|
||||||
auxSerialSetup(SBUS_BAUDRATE, true);
|
auxSerialInit(UART_MODE_SBUS_TRAINER, 0);
|
||||||
AUX_SERIAL_USART->CR1 |= USART_CR1_M | USART_CR1_PCE ;
|
|
||||||
AUX_SERIAL_POWER_ON();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void auxSerialStop()
|
void auxSerialStop()
|
||||||
|
@ -201,10 +208,15 @@ extern "C" void AUX_SERIAL_USART_IRQHandler(void)
|
||||||
uint32_t status = AUX_SERIAL_USART->SR;
|
uint32_t status = AUX_SERIAL_USART->SR;
|
||||||
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
|
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
|
||||||
uint8_t data = AUX_SERIAL_USART->DR;
|
uint8_t data = AUX_SERIAL_USART->DR;
|
||||||
|
UNUSED(data);
|
||||||
if (!(status & USART_FLAG_ERRORS)) {
|
if (!(status & USART_FLAG_ERRORS)) {
|
||||||
#if defined(LUA) & !defined(CLI)
|
#if defined(LUA) & !defined(CLI)
|
||||||
if (luaRxFifo && auxSerialMode == UART_MODE_LUA)
|
if (luaRxFifo && auxSerialMode == UART_MODE_LUA)
|
||||||
luaRxFifo->push(data);
|
luaRxFifo->push(data);
|
||||||
|
#endif
|
||||||
|
#if !defined(BOOT)
|
||||||
|
if (auxSerialMode == UART_MODE_SBUS_TRAINER)
|
||||||
|
trainerSbusFifo.push(data);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
status = AUX_SERIAL_USART->SR;
|
status = AUX_SERIAL_USART->SR;
|
||||||
|
@ -218,7 +230,7 @@ uint8_t aux2SerialMode = 0;
|
||||||
Fifo<uint8_t, 512> aux2SerialTxFifo;
|
Fifo<uint8_t, 512> aux2SerialTxFifo;
|
||||||
AuxSerialRxFifo aux2SerialRxFifo __DMA (AUX2_SERIAL_DMA_Stream_RX);
|
AuxSerialRxFifo aux2SerialRxFifo __DMA (AUX2_SERIAL_DMA_Stream_RX);
|
||||||
|
|
||||||
void aux2SerialSetup(unsigned int baudrate, bool dma)
|
void aux2SerialSetup(unsigned int baudrate, bool dma, uint16_t lenght = USART_WordLength_8b, uint16_t parity = USART_Parity_No, uint16_t stop = USART_StopBits_1)
|
||||||
{
|
{
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
@ -241,9 +253,9 @@ void aux2SerialSetup(unsigned int baudrate, bool dma)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USART_InitStructure.USART_BaudRate = baudrate;
|
USART_InitStructure.USART_BaudRate = baudrate;
|
||||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
USART_InitStructure.USART_WordLength = lenght;
|
||||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
USART_InitStructure.USART_StopBits = stop;
|
||||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
USART_InitStructure.USART_Parity = parity;
|
||||||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
USART_Init(AUX2_SERIAL_USART, &USART_InitStructure);
|
USART_Init(AUX2_SERIAL_USART, &USART_InitStructure);
|
||||||
|
@ -315,6 +327,11 @@ void aux2SerialInit(unsigned int mode, unsigned int protocol)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case UART_MODE_SBUS_TRAINER:
|
||||||
|
aux2SerialSetup(SBUS_BAUDRATE, false, USART_WordLength_9b, USART_Parity_Even, USART_StopBits_2); // 2 stop bits requires USART_WordLength_9b
|
||||||
|
AUX2_SERIAL_POWER_ON();
|
||||||
|
break;
|
||||||
|
|
||||||
case UART_MODE_LUA:
|
case UART_MODE_LUA:
|
||||||
aux2SerialSetup(DEBUG_BAUDRATE, false);
|
aux2SerialSetup(DEBUG_BAUDRATE, false);
|
||||||
AUX2_SERIAL_POWER_ON();
|
AUX2_SERIAL_POWER_ON();
|
||||||
|
@ -336,9 +353,7 @@ void aux2SerialPutc(char c)
|
||||||
|
|
||||||
void aux2SerialSbusInit()
|
void aux2SerialSbusInit()
|
||||||
{
|
{
|
||||||
aux2SerialSetup(SBUS_BAUDRATE, true);
|
aux2SerialInit(UART_MODE_SBUS_TRAINER, 0);
|
||||||
AUX2_SERIAL_USART->CR1 |= USART_CR1_M | USART_CR1_PCE ;
|
|
||||||
AUX2_SERIAL_POWER_ON();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void aux2SerialStop()
|
void aux2SerialStop()
|
||||||
|
@ -394,10 +409,17 @@ extern "C" void AUX2_SERIAL_USART_IRQHandler(void)
|
||||||
uint32_t status = AUX2_SERIAL_USART->SR;
|
uint32_t status = AUX2_SERIAL_USART->SR;
|
||||||
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
|
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
|
||||||
uint8_t data = AUX2_SERIAL_USART->DR;
|
uint8_t data = AUX2_SERIAL_USART->DR;
|
||||||
|
UNUSED(data);
|
||||||
if (!(status & USART_FLAG_ERRORS)) {
|
if (!(status & USART_FLAG_ERRORS)) {
|
||||||
#if defined(LUA)
|
#if defined(LUA) & !defined(CLI)
|
||||||
if (luaRxFifo && aux2SerialMode == UART_MODE_LUA)
|
if (luaRxFifo && aux2SerialMode == UART_MODE_LUA) {
|
||||||
luaRxFifo->push(data);
|
luaRxFifo->push(data);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if !defined(BOOT)
|
||||||
|
if (aux2SerialMode == UART_MODE_SBUS_TRAINER) {
|
||||||
|
trainerSbusFifo.push(data);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
status = AUX2_SERIAL_USART->SR;
|
status = AUX2_SERIAL_USART->SR;
|
||||||
|
|
|
@ -66,6 +66,7 @@ if (PCB STREQUAL X10)
|
||||||
set(HARDWARE_TOUCH YES)
|
set(HARDWARE_TOUCH YES)
|
||||||
set(USB_CHARGER YES)
|
set(USB_CHARGER YES)
|
||||||
set(DEFAULT_THEME "DARKBLUE")
|
set(DEFAULT_THEME "DARKBLUE")
|
||||||
|
set(SBUS ON)
|
||||||
set(AUX_SERIAL ON)
|
set(AUX_SERIAL ON)
|
||||||
if (NOT BLUETOOTH AND NOT INTERNAL_GPS)
|
if (NOT BLUETOOTH AND NOT INTERNAL_GPS)
|
||||||
set(AUX2_SERIAL ON)
|
set(AUX2_SERIAL ON)
|
||||||
|
@ -254,6 +255,14 @@ if (AUX2_SERIAL)
|
||||||
set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp)
|
set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (SBUS)
|
||||||
|
add_definitions(-DSBUS)
|
||||||
|
set(SRC
|
||||||
|
${SRC}
|
||||||
|
sbus.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(FIRMWARE_TARGET_SRC
|
set(FIRMWARE_TARGET_SRC
|
||||||
${FIRMWARE_TARGET_SRC}
|
${FIRMWARE_TARGET_SRC}
|
||||||
${LCD_DRIVER}
|
${LCD_DRIVER}
|
||||||
|
|
|
@ -197,6 +197,9 @@ void stop_trainer_ppm();
|
||||||
void init_trainer_capture();
|
void init_trainer_capture();
|
||||||
void stop_trainer_capture();
|
void stop_trainer_capture();
|
||||||
|
|
||||||
|
// SBUS
|
||||||
|
int sbusGetByte(uint8_t * byte);
|
||||||
|
|
||||||
// Keys driver
|
// Keys driver
|
||||||
enum EnumKeys
|
enum EnumKeys
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
|
#if defined(SBUS)
|
||||||
|
Fifo<uint8_t, 32> trainerSbusFifo;
|
||||||
|
#endif
|
||||||
|
|
||||||
void trainerSendNextFrame();
|
void trainerSendNextFrame();
|
||||||
|
|
||||||
void init_trainer_ppm()
|
void init_trainer_ppm()
|
||||||
|
@ -152,3 +156,15 @@ extern "C" void TRAINER_TIMER_IRQHandler()
|
||||||
trainerSendNextFrame();
|
trainerSendNextFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sbusGetByte(uint8_t * byte)
|
||||||
|
{
|
||||||
|
switch (currentTrainerMode) {
|
||||||
|
#if defined(AUX_SERIAL)
|
||||||
|
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
||||||
|
return trainerSbusFifo.pop(*byte);
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -107,7 +107,7 @@ TASK_FUNCTION(mixerTask)
|
||||||
s_pulses_paused = true;
|
s_pulses_paused = true;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
#if defined(PCBTARANIS) && defined(SBUS)
|
#if defined(SBUS) && !defined(PCBSKY9X)
|
||||||
// SBUS trainer
|
// SBUS trainer
|
||||||
processSbusInput();
|
processSbusInput();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -115,9 +115,16 @@ void checkTrainerSettings()
|
||||||
|
|
||||||
#if defined(TRAINER_BATTERY_COMPARTMENT)
|
#if defined(TRAINER_BATTERY_COMPARTMENT)
|
||||||
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
||||||
|
#if defined(AUX_SERIAL)
|
||||||
if (g_eeGeneral.auxSerialMode == UART_MODE_SBUS_TRAINER)
|
if (g_eeGeneral.auxSerialMode == UART_MODE_SBUS_TRAINER)
|
||||||
auxSerialSbusInit();
|
auxSerialSbusInit();
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
|
#if defined(AUX2_SERIAL)
|
||||||
|
if (g_eeGeneral.aux2SerialMode == UART_MODE_SBUS_TRAINER)
|
||||||
|
aux2SerialSbusInit();
|
||||||
|
else
|
||||||
|
#endif
|
||||||
init_trainer_capture();
|
init_trainer_capture();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue