[Taranis X9E] Bluetooth
- baudrate configured automatically to 115200bauds (factory reset=9600bauds) - device name is now "Taranis" - Telemetry is mirrored
This commit is contained in:
@@ -197,7 +197,7 @@ void perMain()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(REV9E) && !defined(SIMU)
|
#if defined(REV9E) && !defined(SIMU)
|
||||||
bt_wakeup();
|
bluetoothWakeup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
|
|||||||
@@ -12,26 +12,33 @@
|
|||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "../../fifo.h"
|
#include "../../fifo.h"
|
||||||
|
|
||||||
Fifo<200> btTxFifo;
|
Fifo<64> btTxFifo;
|
||||||
Fifo<200> btRxFifo;
|
Fifo<64> btRxFifo;
|
||||||
|
|
||||||
int bt_open()
|
void bluetoothInit(uint32_t baudrate)
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
|
|
||||||
|
USART_DeInit(BT_USART);
|
||||||
|
|
||||||
RCC_AHB1PeriphClockCmd(BT_RCC_AHB1Periph, ENABLE);
|
RCC_AHB1PeriphClockCmd(BT_RCC_AHB1Periph, ENABLE);
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_EN;
|
GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_BRTS;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||||
|
GPIO_Init(BT_GPIO_BRTS, &GPIO_InitStructure);
|
||||||
|
GPIO_SetBits(BT_GPIO_BRTS, BT_GPIO_PIN_BRTS);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_EN;
|
||||||
GPIO_Init(BT_GPIO_EN, &GPIO_InitStructure);
|
GPIO_Init(BT_GPIO_EN, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_BRTS;
|
GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_BCTS;
|
||||||
GPIO_Init(BT_GPIO_BRTS, &GPIO_InitStructure);
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||||
|
GPIO_Init(BT_GPIO_BCTS, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_TX|BT_GPIO_PIN_RX;
|
GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_TX|BT_GPIO_PIN_RX;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||||
@@ -41,7 +48,7 @@ int bt_open()
|
|||||||
GPIO_PinAFConfig(BT_GPIO_TXRX, BT_GPIO_PinSource_TX, BT_GPIO_AF);
|
GPIO_PinAFConfig(BT_GPIO_TXRX, BT_GPIO_PinSource_TX, BT_GPIO_AF);
|
||||||
GPIO_PinAFConfig(BT_GPIO_TXRX, BT_GPIO_PinSource_RX, BT_GPIO_AF);
|
GPIO_PinAFConfig(BT_GPIO_TXRX, BT_GPIO_PinSource_RX, BT_GPIO_AF);
|
||||||
|
|
||||||
USART_InitStructure.USART_BaudRate = 115200;
|
USART_InitStructure.USART_BaudRate = baudrate;
|
||||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
@@ -59,25 +66,36 @@ int bt_open()
|
|||||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
|
|
||||||
GPIO_SetBits(BT_GPIO_BRTS, BT_GPIO_PIN_BRTS);
|
|
||||||
GPIO_ResetBits(BT_GPIO_EN, BT_GPIO_PIN_EN); // open bluetooth
|
GPIO_ResetBits(BT_GPIO_EN, BT_GPIO_PIN_EN); // open bluetooth
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t bt_state = 0;
|
enum BluetoothState
|
||||||
|
{
|
||||||
|
BLUETOOTH_INIT,
|
||||||
|
BLUETOOTH_WAIT_TTM,
|
||||||
|
BLUETOOTH_WAIT_BAUDRATE_CHANGE,
|
||||||
|
BLUETOOTH_OK,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum BluetoothWriteState
|
||||||
|
{
|
||||||
|
BLUETOOTH_WRITE_IDLE,
|
||||||
|
BLUETOOTH_WRITE_INIT,
|
||||||
|
BLUETOOTH_WRITING,
|
||||||
|
BLUETOOTH_WRITE_DONE
|
||||||
|
};
|
||||||
|
|
||||||
|
volatile uint8_t bluetoothState = BLUETOOTH_INIT;
|
||||||
|
volatile uint8_t bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
|
||||||
|
|
||||||
extern "C" void USART6_IRQHandler(void)
|
extern "C" void USART6_IRQHandler(void)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
if (USART_GetITStatus(BT_USART, USART_IT_RXNE) != RESET) {
|
if (USART_GetITStatus(BT_USART, USART_IT_RXNE) != RESET) {
|
||||||
USART_ClearITPendingBit(BT_USART, USART_IT_RXNE);
|
USART_ClearITPendingBit(BT_USART, USART_IT_RXNE);
|
||||||
uint8_t byte = USART_ReceiveData(BT_USART);
|
uint8_t byte = USART_ReceiveData(BT_USART);
|
||||||
btRxFifo.push(byte);
|
btRxFifo.push(byte);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
if (USART_GetITStatus(BT_USART, USART_IT_TXE) != RESET) {
|
if (USART_GetITStatus(BT_USART, USART_IT_TXE) != RESET) {
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
bool result = btTxFifo.pop(byte);
|
bool result = btTxFifo.pop(byte);
|
||||||
@@ -86,52 +104,116 @@ extern "C" void USART6_IRQHandler(void)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
USART_ITConfig(BT_USART, USART_IT_TXE, DISABLE);
|
USART_ITConfig(BT_USART, USART_IT_TXE, DISABLE);
|
||||||
GPIO_SetBits(BT_GPIO_BRTS, BT_GPIO_PIN_BRTS);
|
bluetoothWriteState = BLUETOOTH_WRITE_DONE;
|
||||||
bt_state = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_write(const void *buffer, int len)
|
void bluetoothWrite(const void * buffer, int len)
|
||||||
{
|
{
|
||||||
uint8_t *data = (uint8_t *)buffer;
|
uint8_t * data = (uint8_t *)buffer;
|
||||||
for (int i=0; i<len; ++i) {
|
for (int i=0; i<len; ++i) {
|
||||||
btTxFifo.push(data[i]);
|
btTxFifo.push(data[i]);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_wakeup(void)
|
void bluetoothWriteString(const char * str)
|
||||||
{
|
{
|
||||||
if (bt_state < 2 && !btTxFifo.empty()) {
|
while (*str != 0) {
|
||||||
if (bt_state == 0) {
|
btTxFifo.push(*str++);
|
||||||
GPIO_ResetBits(BT_GPIO_BRTS, BT_GPIO_PIN_BRTS);
|
|
||||||
bt_state = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
USART_ITConfig(BT_USART, USART_IT_TXE, ENABLE);
|
|
||||||
bt_state = 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_read(void *buffer, int len)
|
void bluetoothWriteWakeup(void)
|
||||||
|
{
|
||||||
|
if (bluetoothWriteState == BLUETOOTH_WRITE_IDLE) {
|
||||||
|
if (!btTxFifo.empty()) {
|
||||||
|
bluetoothWriteState = BLUETOOTH_WRITE_INIT;
|
||||||
|
GPIO_ResetBits(BT_GPIO_BRTS, BT_GPIO_PIN_BRTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bluetoothWriteState == BLUETOOTH_WRITE_INIT) {
|
||||||
|
bluetoothWriteState = BLUETOOTH_WRITING;
|
||||||
|
USART_ITConfig(BT_USART, USART_IT_TXE, ENABLE);
|
||||||
|
}
|
||||||
|
else if (bluetoothWriteState == BLUETOOTH_WRITE_DONE) {
|
||||||
|
bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
|
||||||
|
GPIO_SetBits(BT_GPIO_BRTS, BT_GPIO_PIN_BRTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bluetoothWakeup(void)
|
||||||
|
{
|
||||||
|
if (bluetoothState != BLUETOOTH_OK) {
|
||||||
|
static tmr10ms_t waitEnd = 0;
|
||||||
|
|
||||||
|
if (bluetoothState == BLUETOOTH_INIT) {
|
||||||
|
const char btMessage[] = "TTM:REN-Taranis";
|
||||||
|
bluetoothWriteString(btMessage);
|
||||||
|
bluetoothState = BLUETOOTH_WAIT_TTM;
|
||||||
|
waitEnd = get_tmr10ms() + 25/*250*s*/;
|
||||||
|
}
|
||||||
|
else if (bluetoothState == BLUETOOTH_WAIT_TTM) {
|
||||||
|
if (get_tmr10ms() > waitEnd) {
|
||||||
|
char ttm[] = "TTM:REN";
|
||||||
|
int index = 0;
|
||||||
|
uint8_t c;
|
||||||
|
bool found = false;
|
||||||
|
while (btRxFifo.pop(c)) {
|
||||||
|
if (c == ttm[index]) {
|
||||||
|
index++;
|
||||||
|
if (index == sizeof(ttm)-1) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
bluetoothState = BLUETOOTH_OK;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bluetoothInit(9600);
|
||||||
|
const char btMessage[] = "TTM:BPS-115200";
|
||||||
|
bluetoothWriteString(btMessage);
|
||||||
|
bluetoothState = BLUETOOTH_WAIT_BAUDRATE_CHANGE;
|
||||||
|
waitEnd = get_tmr10ms() + 250;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bluetoothState == BLUETOOTH_WAIT_BAUDRATE_CHANGE) {
|
||||||
|
if (get_tmr10ms() > waitEnd) {
|
||||||
|
bluetoothInit(115200);
|
||||||
|
bluetoothState = BLUETOOTH_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bluetoothWriteWakeup();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t bluetoothReady()
|
||||||
|
{
|
||||||
|
return (bluetoothState == BLUETOOTH_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bluetoothRead(void * buffer, int len)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
uint8_t *data = (uint8_t *)buffer;
|
uint8_t * data = (uint8_t *)buffer;
|
||||||
while (1) {
|
while (result < len) {
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
if (!btRxFifo.pop(byte))
|
if (!btRxFifo.pop(byte)) {
|
||||||
return result;
|
break;
|
||||||
|
}
|
||||||
data[result++] = byte;
|
data[result++] = byte;
|
||||||
if (result >= len)
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_close()
|
void bluetoothDone()
|
||||||
{
|
{
|
||||||
GPIO_SetBits(BT_GPIO_EN, BT_GPIO_PIN_EN); // close bluetooth
|
GPIO_SetBits(BT_GPIO_EN, BT_GPIO_PIN_EN); // close bluetooth
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ void boardInit()
|
|||||||
init2MhzTimer();
|
init2MhzTimer();
|
||||||
init5msTimer();
|
init5msTimer();
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
eepromInit();
|
i2cInit();
|
||||||
usbInit();
|
usbInit();
|
||||||
|
|
||||||
#if defined(HAPTIC)
|
#if defined(HAPTIC)
|
||||||
@@ -140,7 +140,7 @@ void boardInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(REV9E)
|
#if defined(REV9E)
|
||||||
bt_open();
|
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
|
|||||||
@@ -288,8 +288,8 @@ void usbStop(void);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// EEPROM driver
|
// I2C driver: EEPROM + Audio Volume
|
||||||
void eepromInit(void);
|
void i2cInit(void);
|
||||||
void eepromReadBlock(uint8_t * buffer, uint16_t address, uint16_t size);
|
void eepromReadBlock(uint8_t * buffer, uint16_t address, uint16_t size);
|
||||||
void eepromWriteBlock(uint8_t * buffer, uint16_t address, uint16_t size);
|
void eepromWriteBlock(uint8_t * buffer, uint16_t address, uint16_t size);
|
||||||
|
|
||||||
@@ -321,7 +321,7 @@ void hapticOff(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SERIAL_USART driver
|
// SERIAL_USART driver
|
||||||
#define DEBUG_BAUDRATE 115200
|
#define DEBUG_BAUDRATE 115200
|
||||||
void uart3Init(unsigned int mode, unsigned int protocol);
|
void uart3Init(unsigned int mode, unsigned int protocol);
|
||||||
void uart3Putc(const char c);
|
void uart3Putc(const char c);
|
||||||
#define telemetrySecondPortInit(protocol) uart3Init(UART_MODE_TELEMETRY, protocol)
|
#define telemetrySecondPortInit(protocol) uart3Init(UART_MODE_TELEMETRY, protocol)
|
||||||
@@ -329,10 +329,13 @@ void uart3SbusInit(void);
|
|||||||
void uart3Stop(void);
|
void uart3Stop(void);
|
||||||
|
|
||||||
// BT driver
|
// BT driver
|
||||||
int bt_open(void);
|
#define BLUETOOTH_DEFAULT_BAUDRATE 115200
|
||||||
int bt_write(const void *buffer, int len);
|
uint8_t bluetoothReady();
|
||||||
int bt_read(void *buffer, int len);
|
void bluetoothInit(uint32_t baudrate);
|
||||||
void bt_wakeup(void);
|
void bluetoothWrite(const void * buffer, int len);
|
||||||
|
void bluetoothWriteString(const char * str);
|
||||||
|
int bluetoothRead(void * buffer, int len);
|
||||||
|
void bluetoothWakeup(void);
|
||||||
|
|
||||||
// Top LCD driver
|
// Top LCD driver
|
||||||
#if defined(REV9E)
|
#if defined(REV9E)
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ TCHAR backupFilename[60];
|
|||||||
|
|
||||||
uint32_t Master_frequency;
|
uint32_t Master_frequency;
|
||||||
volatile uint8_t Tenms;
|
volatile uint8_t Tenms;
|
||||||
uint8_t EE_timer;
|
|
||||||
|
|
||||||
FIL FlashFile;
|
FIL FlashFile;
|
||||||
DIR Dj;
|
DIR Dj;
|
||||||
@@ -423,18 +422,12 @@ int main()
|
|||||||
lcd_putsLeft(0, BOOTLOADER_TITLE);
|
lcd_putsLeft(0, BOOTLOADER_TITLE);
|
||||||
lcd_invert_line(0);
|
lcd_invert_line(0);
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
#if defined(PCBSKY9X)
|
|
||||||
OptrexDisplay = 0;
|
|
||||||
lcdRefresh();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
#if defined(REVPLUS)
|
#if defined(REVPLUS)
|
||||||
turnBacklightOn(0, 0);
|
turnBacklightOn(0, 0);
|
||||||
#endif
|
#endif
|
||||||
keysInit();
|
keysInit();
|
||||||
eepromInit();
|
i2cInit();
|
||||||
#endif
|
|
||||||
|
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
init10msTimer();
|
init10msTimer();
|
||||||
@@ -444,13 +437,6 @@ int main()
|
|||||||
init_spi();
|
init_spi();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
|
||||||
LockBits = readLockBits();
|
|
||||||
if (LockBits) {
|
|
||||||
clearLockBits();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
// SD card detect pin
|
// SD card detect pin
|
||||||
sdInit();
|
sdInit();
|
||||||
@@ -462,15 +448,6 @@ int main()
|
|||||||
wdt_reset();
|
wdt_reset();
|
||||||
|
|
||||||
if (Tenms) {
|
if (Tenms) {
|
||||||
|
|
||||||
if (EE_timer) {
|
|
||||||
if (--EE_timer == 0) {
|
|
||||||
#if defined(PCBSKY9X)
|
|
||||||
writeBlock();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Tenms = 0;
|
Tenms = 0;
|
||||||
|
|
||||||
lcdRefreshWait();
|
lcdRefreshWait();
|
||||||
|
|||||||
@@ -549,8 +549,10 @@
|
|||||||
#define BT_GPIO_PIN_RX GPIO_Pin_9 // PG.09
|
#define BT_GPIO_PIN_RX GPIO_Pin_9 // PG.09
|
||||||
#define BT_GPIO_EN GPIOD
|
#define BT_GPIO_EN GPIOD
|
||||||
#define BT_GPIO_PIN_EN GPIO_Pin_11 // PD.11
|
#define BT_GPIO_PIN_EN GPIO_Pin_11 // PD.11
|
||||||
#define BT_GPIO_BRTS GPIOB
|
#define BT_GPIO_BRTS GPIOE
|
||||||
#define BT_GPIO_PIN_BRTS GPIO_Pin_10
|
#define BT_GPIO_PIN_BRTS GPIO_Pin_12 // PE.12
|
||||||
|
#define BT_GPIO_BCTS GPIOG
|
||||||
|
#define BT_GPIO_PIN_BCTS GPIO_Pin_6 // PG.06
|
||||||
#define BT_GPIO_PinSource_TX GPIO_PinSource14
|
#define BT_GPIO_PinSource_TX GPIO_PinSource14
|
||||||
#define BT_GPIO_PinSource_RX GPIO_PinSource9
|
#define BT_GPIO_PinSource_RX GPIO_PinSource9
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
void eepromPageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite);
|
void eepromPageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite);
|
||||||
void eepromWaitEepromStandbyState(void);
|
void eepromWaitEepromStandbyState(void);
|
||||||
|
|
||||||
void eepromInit(void)
|
void i2cInit()
|
||||||
{
|
{
|
||||||
I2C_DeInit(I2C);
|
I2C_DeInit(I2C);
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ bool I2C_EE_ReadBlock(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRea
|
|||||||
void eepromReadBlock(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead)
|
void eepromReadBlock(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead)
|
||||||
{
|
{
|
||||||
while (!I2C_EE_ReadBlock(pBuffer, ReadAddr, NumByteToRead)) {
|
while (!I2C_EE_ReadBlock(pBuffer, ReadAddr, NumByteToRead)) {
|
||||||
eepromInit();
|
i2cInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ bool I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWri
|
|||||||
void eepromPageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite)
|
void eepromPageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite)
|
||||||
{
|
{
|
||||||
while (!I2C_EE_PageWrite(pBuffer, WriteAddr, NumByteToWrite)) {
|
while (!I2C_EE_PageWrite(pBuffer, WriteAddr, NumByteToWrite)) {
|
||||||
eepromInit();
|
i2cInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ bool I2C_EE_WaitEepromStandbyState(void)
|
|||||||
void eepromWaitEepromStandbyState(void)
|
void eepromWaitEepromStandbyState(void)
|
||||||
{
|
{
|
||||||
while (!I2C_EE_WaitEepromStandbyState()) {
|
while (!I2C_EE_WaitEepromStandbyState()) {
|
||||||
eepromInit();
|
i2cInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,6 +170,19 @@ NOINLINE void processSerialData(uint8_t data)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
#define BLUETOOTH_BUFFER_LENGTH 20
|
||||||
|
static uint8_t bluetoothBuffer[BLUETOOTH_BUFFER_LENGTH];
|
||||||
|
static uint8_t bluetoothIndex = 0;
|
||||||
|
bluetoothBuffer[bluetoothIndex++] = data;
|
||||||
|
if (bluetoothIndex == BLUETOOTH_BUFFER_LENGTH) {
|
||||||
|
if (bluetoothReady()) {
|
||||||
|
bluetoothWrite(bluetoothBuffer, BLUETOOTH_BUFFER_LENGTH);
|
||||||
|
}
|
||||||
|
bluetoothIndex = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (dataState)
|
switch (dataState)
|
||||||
{
|
{
|
||||||
case STATE_DATA_START:
|
case STATE_DATA_START:
|
||||||
|
|||||||
@@ -511,11 +511,11 @@ void sportFirmwareUpdate(ModuleIndex module, const char *filename)
|
|||||||
{
|
{
|
||||||
bool result = sportUpdatePowerOn(module);
|
bool result = sportUpdatePowerOn(module);
|
||||||
if (result)
|
if (result)
|
||||||
result = sportUpdateReqVersion();
|
result = sportUpdateReqVersion();
|
||||||
if (result)
|
if (result)
|
||||||
result = sportUpdateUploadFile(filename);
|
result = sportUpdateUploadFile(filename);
|
||||||
if (result)
|
if (result)
|
||||||
result = sportUpdateEnd();
|
result = sportUpdateEnd();
|
||||||
|
|
||||||
if (result == false) {
|
if (result == false) {
|
||||||
POPUP_WARNING("Firmware Update Error");
|
POPUP_WARNING("Firmware Update Error");
|
||||||
|
|||||||
Reference in New Issue
Block a user