diff --git a/radio/src/gui/gui_common.cpp b/radio/src/gui/gui_common.cpp index 5f784b6a488..9b99465cbc0 100644 --- a/radio/src/gui/gui_common.cpp +++ b/radio/src/gui/gui_common.cpp @@ -1068,26 +1068,41 @@ bool isTrainerModeAvailable(int mode) return false; #endif + if (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || + mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE) { + #if !defined(TRAINER_MODULE_CPPM) - if (mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE) - return false; + if (mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE) + return false; #endif #if !defined(TRAINER_MODULE_SBUS) - if (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE) - return false; + if (mode == mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE) + return false; #endif -#if defined(TRAINER_MODULE_CPPM) || defined(TRAINER_MODULE_SBUS) - if (IS_EXTERNAL_MODULE_ENABLED() && - (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || - mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE)) - return false; + // no external module or is enabled + if (!modulePortGetModuleDescription(EXTERNAL_MODULE) || + IS_EXTERNAL_MODULE_ENABLED()) { + return false; + } + + if (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE) { +#if defined(EXTMODULE_USART) || defined(CONFIGURABLE_MODULE_PORT) + auto port = modulePortFind(EXTERNAL_MODULE, ETX_MOD_TYPE_SERIAL, + ETX_MOD_PORT_UART, ETX_Pol_Normal); + return port != nullptr; +#elif defined(TRAINER_MODULE_SBUS_USART) + return true; +#else + return false; #endif + } + } -#if !defined(MULTIMODULE) || !defined(HARDWARE_INTERNAL_MODULE) || !defined(HARDWARE_EXTERNAL_MODULE) - if (mode == TRAINER_MODE_MULTI) - return false; +#if !defined(MULTIMODULE) || !defined(HARDWARE_INTERNAL_MODULE) || \ + !defined(HARDWARE_EXTERNAL_MODULE) + if (mode == TRAINER_MODE_MULTI) return false; #else if (mode == TRAINER_MODE_MULTI && ((!IS_INTERNAL_MODULE_ENABLED() && !IS_EXTERNAL_MODULE_ENABLED()) || diff --git a/radio/src/targets/horus/hal.h b/radio/src/targets/horus/hal.h index 232a19c125f..a382c6b1444 100644 --- a/radio/src/targets/horus/hal.h +++ b/radio/src/targets/horus/hal.h @@ -1007,6 +1007,10 @@ #define TRAINER_MODULE_CPPM_TIMER_IRQHandler TIM4_IRQHandler #define TRAINER_MODULE_CPPM_GPIO_AF LL_GPIO_AF_2 +#if defined(EXTMODULE_USART) || defined(CONFIGURABLE_MODULE_PORT) + #define TRAINER_MODULE_SBUS +#endif + // Millisecond timer #define MS_TIMER TIM14 #define MS_TIMER_IRQn TIM8_TRG_COM_TIM14_IRQn diff --git a/radio/src/targets/nv14/hal.h b/radio/src/targets/nv14/hal.h index 7d93d7dda3f..227a31bba80 100644 --- a/radio/src/targets/nv14/hal.h +++ b/radio/src/targets/nv14/hal.h @@ -531,6 +531,7 @@ #define TRAINER_GPIO_AF LL_GPIO_AF_2 #define TRAINER_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1) +#define TRAINER_MODULE_SBUS //BLUETOOTH #define BLUETOOTH_ON_RCC_AHB1Periph RCC_AHB1Periph_GPIOI