fix: check both SBUS trainer ports (#5149)

.. regardless of TRAINER_MODULE_SBUS_USART define
This commit is contained in:
Raphael Coeffic
2024-06-11 09:51:22 +10:00
committed by GitHub
parent 65a0f0d9e7
commit 61a52b8c38
2 changed files with 13 additions and 16 deletions
+7 -8
View File
@@ -1058,17 +1058,16 @@ bool isTrainerModeAvailable(int mode)
if (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE) { if (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE) {
const etx_module_port_t *port = nullptr; const etx_module_port_t *port = nullptr;
#if defined(TRAINER_MODULE_SBUS_USART) // check if UART with inverter on heartbeat pin is available
// check if UART with inverter on heartbeat pin is required and available for SBUS (some Taranis radios)
port = modulePortFind(EXTERNAL_MODULE, ETX_MOD_TYPE_SERIAL, port = modulePortFind(EXTERNAL_MODULE, ETX_MOD_TYPE_SERIAL,
ETX_MOD_PORT_UART, ETX_Pol_Normal, ETX_MOD_PORT_UART, ETX_Pol_Normal,
ETX_MOD_DIR_RX); ETX_MOD_DIR_RX);
#else if (!port) {
//check if UART with inverter on S.Port pin is available for SBUS (e.g. TX16s, NV14) // otherwise fall back to S.Port pin
port = modulePortFind(EXTERNAL_MODULE, ETX_MOD_TYPE_SERIAL, port =
ETX_MOD_PORT_SPORT, ETX_Pol_Normal, modulePortFind(EXTERNAL_MODULE, ETX_MOD_TYPE_SERIAL,
ETX_MOD_DIR_RX); ETX_MOD_PORT_SPORT, ETX_Pol_Normal, ETX_MOD_DIR_RX);
#endif }
return port != nullptr; return port != nullptr;
} }
+6 -8
View File
@@ -180,16 +180,14 @@ static void trainer_init_module_sbus()
{ {
if (sbus_trainer_mod_st) return; if (sbus_trainer_mod_st) return;
#if defined(TRAINER_MODULE_SBUS_USART) // check if UART with inverter on heartbeat pin is available
// check if UART with inverter on heartbeat pin is required and available for SBUS (some Taranis radios)
sbus_trainer_mod_st = modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_UART, sbus_trainer_mod_st = modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_UART,
&sbusTrainerParams, false); &sbusTrainerParams, false);
#else if(sbus_trainer_mod_st == nullptr) {
// check if UART with inverter on S.Port pin is available for SBUS (e.g. TX16s, NV14) // otherwise fall back to S.Port pin
if(sbus_trainer_mod_st == nullptr) sbus_trainer_mod_st = modulePortInitSerial(
sbus_trainer_mod_st = modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_SPORT, EXTERNAL_MODULE, ETX_MOD_PORT_SPORT, &sbusTrainerParams, false);
&sbusTrainerParams, false); }
#endif
if (sbus_trainer_mod_st) { if (sbus_trainer_mod_st) {
modulePortSetPower(EXTERNAL_MODULE,true); modulePortSetPower(EXTERNAL_MODULE,true);