1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 09:45:21 +03:00

Improve BT speed

This commit is contained in:
Bertrand Songis 2019-04-25 09:46:23 +02:00
parent 1fb995b915
commit d73081425f
2 changed files with 10 additions and 2 deletions

View file

@ -40,6 +40,7 @@ enum BluetoothStates {
BLUETOOTH_STATE_CONNECT_SENT, BLUETOOTH_STATE_CONNECT_SENT,
BLUETOOTH_STATE_CONNECTED, BLUETOOTH_STATE_CONNECTED,
BLUETOOTH_STATE_DISCONNECTED, BLUETOOTH_STATE_DISCONNECTED,
BLUETOOTH_STATE_FIRMWARE_UGRADE
}; };
#define LEN_BLUETOOTH_ADDR 16 #define LEN_BLUETOOTH_ADDR 16

View file

@ -30,7 +30,9 @@ volatile uint8_t btChipPresent = 0;
enum BluetoothWriteState enum BluetoothWriteState
{ {
BLUETOOTH_WRITE_IDLE, BLUETOOTH_WRITE_IDLE,
#if defined(BT_BRTS_GPIO_PIN)
BLUETOOTH_WRITE_INIT, BLUETOOTH_WRITE_INIT,
#endif
BLUETOOTH_WRITING, BLUETOOTH_WRITING,
BLUETOOTH_WRITE_DONE BLUETOOTH_WRITE_DONE
}; };
@ -123,20 +125,25 @@ extern "C" void BT_USART_IRQHandler(void)
} }
} }
void bluetoothWriteWakeup(void) void bluetoothWriteWakeup()
{ {
if (bluetoothWriteState == BLUETOOTH_WRITE_IDLE) { if (bluetoothWriteState == BLUETOOTH_WRITE_IDLE) {
if (!btTxFifo.isEmpty()) { if (!btTxFifo.isEmpty()) {
bluetoothWriteState = BLUETOOTH_WRITE_INIT;
#if defined(BT_BRTS_GPIO_PIN) #if defined(BT_BRTS_GPIO_PIN)
bluetoothWriteState = BLUETOOTH_WRITE_INIT;
GPIO_ResetBits(BT_BRTS_GPIO, BT_BRTS_GPIO_PIN); GPIO_ResetBits(BT_BRTS_GPIO, BT_BRTS_GPIO_PIN);
#else
bluetoothWriteState = BLUETOOTH_WRITING;
USART_ITConfig(BT_USART, USART_IT_TXE, ENABLE);
#endif #endif
} }
} }
#if defined(BT_BRTS_GPIO_PIN)
else if (bluetoothWriteState == BLUETOOTH_WRITE_INIT) { else if (bluetoothWriteState == BLUETOOTH_WRITE_INIT) {
bluetoothWriteState = BLUETOOTH_WRITING; bluetoothWriteState = BLUETOOTH_WRITING;
USART_ITConfig(BT_USART, USART_IT_TXE, ENABLE); USART_ITConfig(BT_USART, USART_IT_TXE, ENABLE);
} }
#endif
else if (bluetoothWriteState == BLUETOOTH_WRITE_DONE) { else if (bluetoothWriteState == BLUETOOTH_WRITE_DONE) {
bluetoothWriteState = BLUETOOTH_WRITE_IDLE; bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
#if defined(BT_BRTS_GPIO_PIN) #if defined(BT_BRTS_GPIO_PIN)