1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-15 12:25:12 +03:00

Bluetooth detection issue on QX7 (some samples, after bootloader)

This commit is contained in:
Bertrand Songis 2019-09-24 10:23:10 +02:00
parent 77f23765ae
commit c0c3680fe6
No known key found for this signature in database
GPG key ID: F189F79290FEC50F
3 changed files with 22 additions and 7 deletions

View file

@ -20,6 +20,7 @@
#include "opentx.h"
#if !defined(BOOT)
Fifo<uint8_t, BT_TX_FIFO_SIZE> btTxFifo;
Fifo<uint8_t, BT_RX_FIFO_SIZE> btRxFifo;
@ -42,6 +43,7 @@ enum BluetoothWriteState
};
volatile uint8_t bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
#endif
void bluetoothInit(uint32_t baudrate, bool enable)
{
@ -65,6 +67,7 @@ void bluetoothInit(uint32_t baudrate, bool enable)
GPIO_Init(BT_BCTS_GPIO, &GPIO_InitStructure);
#endif
#if !defined(BOOT)
GPIO_PinAFConfig(BT_USART_GPIO, BT_TX_GPIO_PinSource, BT_GPIO_AF);
GPIO_PinAFConfig(BT_USART_GPIO, BT_RX_GPIO_PinSource, BT_GPIO_AF);
@ -90,17 +93,17 @@ void bluetoothInit(uint32_t baudrate, bool enable)
bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
if (enable) {
btRxFifo.clear();
btTxFifo.clear();
#endif
if (enable)
GPIO_ResetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
}
else {
else
GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
}
btRxFifo.clear();
btTxFifo.clear();
}
#if !defined(BOOT)
void bluetoothDisable()
{
GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN); // close bluetooth (recent modules will go to bootloader mode)
@ -165,3 +168,4 @@ uint8_t bluetoothIsWriting(void)
{
return bluetoothWriteState != BLUETOOTH_WRITE_IDLE;
}
#endif // !BOOT

View file

@ -92,6 +92,13 @@ if(PCB STREQUAL X12S OR PCB STREQUAL X10 OR PCB STREQUAL X9E OR (PCB STREQUAL X9
)
endif()
if(PCB STREQUAL X7 OR PCB STREQUAL XLITE)
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}
../../../../../targets/common/arm/stm32/bluetooth_driver.cpp
)
endif()
if(NOT (PCB STREQUAL X10 OR PCB STREQUAL X12S))
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}

View file

@ -245,6 +245,10 @@ int main()
backlightInit();
backlightEnable();
#if defined(PCBX7) || defined(PCBXLITE)
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, false);
#endif
#if defined(PCBTARANIS)
i2cInit();
#endif