Bluetooth flash firmware continued

This commit is contained in:
Bertrand Songis
2019-04-25 15:08:38 +02:00
parent 798ee0ffee
commit 3323b0a82f
18 changed files with 112 additions and 45 deletions
@@ -39,7 +39,7 @@ enum BluetoothWriteState
volatile uint8_t bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
void bluetoothInit(uint32_t baudrate)
void bluetoothInit(uint32_t baudrate, bool enable)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = BT_EN_GPIO_PIN;
@@ -88,10 +88,12 @@ void bluetoothInit(uint32_t baudrate)
btTxFifo.clear();
bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
GPIO_ResetBits(BT_EN_GPIO, BT_EN_GPIO_PIN); // open bluetooth
if (enable) {
GPIO_ResetBits(BT_EN_GPIO, BT_EN_GPIO_PIN); // open bluetooth
}
}
void bluetoothDone()
void bluetoothDisable()
{
GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN); // close bluetooth (recent modules will go to bootloader mode)
}
@@ -107,7 +109,7 @@ extern "C" void BT_USART_IRQHandler(void)
if (!btChipPresent) {
// This is to differentiate X7 and X7S and X-Lite with/without BT
btChipPresent = 1;
bluetoothDone();
bluetoothDisable();
}
#endif
}
+3 -2
View File
@@ -609,12 +609,13 @@ void serial2Stop(void);
#define USART_FLAG_ERRORS (USART_FLAG_ORE | USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE)
// BT driver
#define BLUETOOTH_BOOTLOADER_BAUDRATE 230400
#define BLUETOOTH_FACTORY_BAUDRATE 57600
#define BLUETOOTH_DEFAULT_BAUDRATE 115200
void bluetoothInit(uint32_t baudrate);
void bluetoothInit(uint32_t baudrate, bool enable = true);
void bluetoothWriteWakeup(void);
uint8_t bluetoothIsWriting(void);
void bluetoothDone(void);
void bluetoothDisable(void);
extern uint8_t currentTrainerMode;
void checkTrainerSettings(void);
+4 -3
View File
@@ -719,16 +719,17 @@ void serial2Stop(void);
#endif
// BT driver
#define BLUETOOTH_BOOTLOADER_BAUDRATE 230400
#define BLUETOOTH_DEFAULT_BAUDRATE 115200
#if defined(PCBX9E) && !defined(USEHORUSBT)
#define BLUETOOTH_FACTORY_BAUDRATE 9600
#define BLUETOOTH_FACTORY_BAUDRATE 9600
#else
#define BLUETOOTH_FACTORY_BAUDRATE 57600
#endif
void bluetoothInit(uint32_t baudrate);
void bluetoothInit(uint32_t baudrate, bool enable = true);
void bluetoothWriteWakeup(void);
uint8_t bluetoothIsWriting(void);
void bluetoothDone(void);
void bluetoothDisable(void);
#if defined(PCBX3)
#define IS_BLUETOOTH_CHIP_PRESENT() (false)
#elif (defined(PCBX7) || defined(PCBXLITE)) && !defined(SIMU)