mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 04:15:26 +03:00
Bluetooth detection issue on QX7 (some samples, after bootloader)
This commit is contained in:
parent
77f23765ae
commit
c0c3680fe6
3 changed files with 22 additions and 7 deletions
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
Fifo<uint8_t, BT_TX_FIFO_SIZE> btTxFifo;
|
Fifo<uint8_t, BT_TX_FIFO_SIZE> btTxFifo;
|
||||||
Fifo<uint8_t, BT_RX_FIFO_SIZE> btRxFifo;
|
Fifo<uint8_t, BT_RX_FIFO_SIZE> btRxFifo;
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ enum BluetoothWriteState
|
||||||
};
|
};
|
||||||
|
|
||||||
volatile uint8_t bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
|
volatile uint8_t bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
|
||||||
|
#endif
|
||||||
|
|
||||||
void bluetoothInit(uint32_t baudrate, bool enable)
|
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);
|
GPIO_Init(BT_BCTS_GPIO, &GPIO_InitStructure);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
GPIO_PinAFConfig(BT_USART_GPIO, BT_TX_GPIO_PinSource, BT_GPIO_AF);
|
GPIO_PinAFConfig(BT_USART_GPIO, BT_TX_GPIO_PinSource, BT_GPIO_AF);
|
||||||
GPIO_PinAFConfig(BT_USART_GPIO, BT_RX_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;
|
bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
|
||||||
|
|
||||||
if (enable) {
|
|
||||||
GPIO_ResetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
btRxFifo.clear();
|
btRxFifo.clear();
|
||||||
btTxFifo.clear();
|
btTxFifo.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
GPIO_ResetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
||||||
|
else
|
||||||
|
GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
void bluetoothDisable()
|
void bluetoothDisable()
|
||||||
{
|
{
|
||||||
GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN); // close bluetooth (recent modules will go to bootloader mode)
|
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;
|
return bluetoothWriteState != BLUETOOTH_WRITE_IDLE;
|
||||||
}
|
}
|
||||||
|
#endif // !BOOT
|
||||||
|
|
|
@ -92,6 +92,13 @@ if(PCB STREQUAL X12S OR PCB STREQUAL X10 OR PCB STREQUAL X9E OR (PCB STREQUAL X9
|
||||||
)
|
)
|
||||||
endif()
|
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))
|
if(NOT (PCB STREQUAL X10 OR PCB STREQUAL X12S))
|
||||||
set(BOOTLOADER_SRC
|
set(BOOTLOADER_SRC
|
||||||
${BOOTLOADER_SRC}
|
${BOOTLOADER_SRC}
|
||||||
|
|
|
@ -245,6 +245,10 @@ int main()
|
||||||
backlightInit();
|
backlightInit();
|
||||||
backlightEnable();
|
backlightEnable();
|
||||||
|
|
||||||
|
#if defined(PCBX7) || defined(PCBXLITE)
|
||||||
|
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
i2cInit();
|
i2cInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue