fix: FrSky BT support on B&W RM radios with BLE port (#3607)
* FrSky BT support on RM radio with BLE port * Remove hardcoded 'no bt' * Compilation fix
This commit is contained in:
@@ -25,6 +25,11 @@
|
||||
#include "opentx.h"
|
||||
#include "diskio.h"
|
||||
#include "timers_driver.h"
|
||||
|
||||
#if defined(BLUETOOTH)
|
||||
#include "bluetooth_driver.h"
|
||||
#endif
|
||||
|
||||
#include "hal/module_port.h"
|
||||
|
||||
#include "tasks.h"
|
||||
|
||||
@@ -57,6 +57,7 @@ void* _bt_usart_ctx = nullptr;
|
||||
|
||||
void bluetoothInit(uint32_t baudrate, bool enable)
|
||||
{
|
||||
#if defined(BT_EN_GPIO_PIN)
|
||||
LL_GPIO_InitTypeDef pinInit;
|
||||
LL_GPIO_StructInit(&pinInit);
|
||||
|
||||
@@ -66,6 +67,7 @@ void bluetoothInit(uint32_t baudrate, bool enable)
|
||||
pinInit.Pull = LL_GPIO_PULL_NO;
|
||||
|
||||
LL_GPIO_Init(BT_EN_GPIO, &pinInit);
|
||||
#endif
|
||||
|
||||
#if !defined(BOOT)
|
||||
etx_serial_init cfg = {
|
||||
@@ -83,18 +85,22 @@ void bluetoothInit(uint32_t baudrate, bool enable)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BT_EN_GPIO_PIN)
|
||||
if (enable) {
|
||||
LL_GPIO_ResetOutputPin(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
||||
} else {
|
||||
LL_GPIO_SetOutputPin(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(BOOT)
|
||||
void bluetoothDisable()
|
||||
{
|
||||
#if defined(BT_EN_GPIO_PIN)
|
||||
// close bluetooth (recent modules will go to bootloader mode)
|
||||
LL_GPIO_SetOutputPin(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
||||
#endif
|
||||
if (_bt_usart_ctx) {
|
||||
STM32SerialDriver.deinit(_bt_usart_ctx);
|
||||
_bt_usart_ctx = nullptr;
|
||||
|
||||
@@ -7,6 +7,7 @@ option(GHOST "Ghost TX Module" ON)
|
||||
option(INTERNAL_MODULE_PPM "Support for PPM internal module" OFF)
|
||||
option(AUTOUPDATE "Auto update internal chips from SD" OFF)
|
||||
option(BIND_KEY "Enable bind button" OFF)
|
||||
option(BLUETOOTH "FrSky BT module support" NO)
|
||||
|
||||
set(USE_RTC_CLOCK YES)
|
||||
set(HARDWARE_EXTERNAL_MODULE YES)
|
||||
@@ -230,9 +231,10 @@ elseif(PCB STREQUAL X7)
|
||||
add_definitions(-DSTM32F40_41xxx -DSTM32F407xx)
|
||||
set(ROTARY_ENCODER YES)
|
||||
set(LUA_EXPORT lua_export_tx12mk2)
|
||||
set(BLUETOOTH NO)
|
||||
set(USB_CHARGER YES)
|
||||
set(AUX_SERIAL ON)
|
||||
if (NOT BLUETOOTH)
|
||||
set(AUX_SERIAL ON)
|
||||
endif()
|
||||
add_definitions(-DRADIO_TX12MK2)
|
||||
add_definitions(-DEEPROM_VARIANT=0x4008)
|
||||
add_definitions(-DMANUFACTURER_RADIOMASTER)
|
||||
@@ -251,15 +253,16 @@ elseif(PCB STREQUAL X7)
|
||||
add_definitions(-DSTM32F40_41xxx -DSTM32F407xx)
|
||||
set(ROTARY_ENCODER YES)
|
||||
set(LUA_EXPORT lua_export_boxer)
|
||||
set(BLUETOOTH NO)
|
||||
set(USB_CHARGER YES)
|
||||
set(AUX_SERIAL ON)
|
||||
add_definitions(-DRADIO_BOXER)
|
||||
add_definitions(-DMANUFACTURER_RADIOMASTER)
|
||||
set(PXX2 ON)
|
||||
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
|
||||
set(CLI ON CACHE BOOL "Enable CLI")
|
||||
set(FLYSKY_GIMBAL ON)
|
||||
if (NOT BLUETOOTH)
|
||||
set(AUX_SERIAL ON)
|
||||
endif()
|
||||
elseif(PCBREV STREQUAL ZORRO)
|
||||
set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module")
|
||||
set(INTERNAL_MODULE_SERIAL YES)
|
||||
@@ -310,7 +313,7 @@ elseif(PCB STREQUAL X7)
|
||||
set(CPU_TYPE_FULL STM32F407xE) # for size report
|
||||
add_definitions(-DSTM32F407xx)
|
||||
set(LINKER_SCRIPT targets/taranis/stm32f4_flash.ld)
|
||||
add_definitions(-DSTM32F407xx -DSTM32F40_41xxx)
|
||||
add_definitions(-DSTM32F407xx -DSTM32F40_41xxx)
|
||||
set(ROTARY_ENCODER NO)
|
||||
set(LUA_EXPORT lua_export_commando8)
|
||||
set(BLUETOOTH NO)
|
||||
|
||||
@@ -2565,7 +2565,7 @@
|
||||
#define BT_TX_GPIO_PinSource GPIO_PinSource14
|
||||
#define BT_RX_GPIO_PinSource GPIO_PinSource9
|
||||
#define BT_USART_IRQHandler USART6_IRQHandler
|
||||
#elif defined(RADIO_X7) || defined(RADIO_X7ACCESS) || defined(PCBXLITE) || defined(PCBX9LITES) || defined(RADIO_X9DP2019)
|
||||
#elif defined(BLUETOOTH)
|
||||
#define STORAGE_BLUETOOTH
|
||||
#define BT_RCC_APB1Periph RCC_APB1Periph_USART3
|
||||
#define BT_RCC_APB2Periph 0
|
||||
@@ -2581,6 +2581,9 @@
|
||||
#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOD) // RCC_AHB1Periph_DMA1
|
||||
#define BT_EN_GPIO GPIOD
|
||||
#define BT_EN_GPIO_PIN LL_GPIO_PIN_14 // PD.14
|
||||
#elif defined(MANUFACTURER_RADIOMASTER)
|
||||
// No enable port on RM BLE port
|
||||
#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB)
|
||||
#else
|
||||
#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOE) // RCC_AHB1Periph_DMA1
|
||||
#define BT_EN_GPIO GPIOE
|
||||
@@ -2589,20 +2592,17 @@
|
||||
#define BT_USART_GPIO GPIOB
|
||||
#define BT_TX_GPIO_PIN LL_GPIO_PIN_10 // PB.10
|
||||
#define BT_RX_GPIO_PIN LL_GPIO_PIN_11 // PB.11
|
||||
#define BT_TX_GPIO_PinSource GPIO_PinSource10
|
||||
#define BT_RX_GPIO_PinSource GPIO_PinSource11
|
||||
#define BT_GPIO_AF LL_GPIO_AF_7
|
||||
#define BT_USART USART3
|
||||
#define BT_USART_IRQHandler USART3_IRQHandler
|
||||
#define BT_USART_IRQn USART3_IRQn
|
||||
// #define BT_DMA_Stream_RX DMA1_Stream1
|
||||
// #define BT_DMA_Channel_RX DMA_Channel_4
|
||||
#elif defined(PCBX9D) || defined(PCBX9DP) || defined(RADIO_FAMILY_JUMPER_T12) || defined(RADIO_TX12) || defined(RADIO_TX12MK2)|| defined(RADIO_BOXER) || defined(RADIO_T8) || defined(RADIO_COMMANDO8) || defined(RADIO_ZORRO)
|
||||
#define STORAGE_BLUETOOTH
|
||||
#define BT_RCC_AHB1Periph 0
|
||||
#define BT_RCC_APB1Periph 0
|
||||
#define BT_RCC_APB2Periph 0
|
||||
#else
|
||||
#if defined(PCBX9D) || defined(PCBX9DP) || defined(RADIO_FAMILY_JUMPER_T12) || defined(RADIO_TX12) || defined(RADIO_TX12MK2)|| defined(RADIO_BOXER) || defined(RADIO_T8) || defined(RADIO_COMMANDO8) || defined(RADIO_ZORRO)
|
||||
// To avoid change in modelsize, todo: remove me
|
||||
#define STORAGE_BLUETOOTH
|
||||
#endif
|
||||
#define BT_RCC_AHB1Periph 0
|
||||
#define BT_RCC_APB1Periph 0
|
||||
#define BT_RCC_APB2Periph 0
|
||||
|
||||
Reference in New Issue
Block a user