Avoid Bluetooth fifo full (and 1ms wait in the mixer task...) (#7652)

Avoid Bluetooth fifo full (and 1ms wait in the mixer task...)
This commit is contained in:
Bertrand Songis
2020-05-31 16:45:48 +02:00
committed by GitHub
parent b6dfa477ef
commit c3f0e2ea88
3 changed files with 15 additions and 13 deletions
+10 -9
View File
@@ -48,17 +48,18 @@ Bluetooth bluetooth;
void Bluetooth::write(const uint8_t * data, uint8_t length) void Bluetooth::write(const uint8_t * data, uint8_t length)
{ {
BLUETOOTH_TRACE("BT>"); if (btTxFifo.hasSpace(length)) {
for (int i=0; i<length; i++) { BLUETOOTH_TRACE("BT>");
BLUETOOTH_TRACE(" %02X", data[i]); for (int i = 0; i < length; i++) {
while (btTxFifo.isFull()) { BLUETOOTH_TRACE(" %02X", data[i]);
if (!bluetoothIsWriting()) btTxFifo.push(data[i]);
bluetoothWriteWakeup();
RTOS_WAIT_MS(1);
} }
btTxFifo.push(data[i]); BLUETOOTH_TRACE(CRLF);
} }
BLUETOOTH_TRACE(CRLF); else {
BLUETOOTH_TRACE("[BT] TX fifo full!" CRLF);
}
bluetoothWriteWakeup(); bluetoothWriteWakeup();
} }
+3 -3
View File
@@ -71,7 +71,7 @@ class Fifo
return (ridx == widx); return (ridx == widx);
} }
bool isFull() bool isFull() const
{ {
uint32_t next = nextIndex(widx); uint32_t next = nextIndex(widx);
return (next == ridx); return (next == ridx);
@@ -82,7 +82,7 @@ class Fifo
return (N + widx - ridx) & (N - 1); return (N + widx - ridx) & (N - 1);
} }
uint32_t hasSpace(uint32_t n) const bool hasSpace(uint32_t n) const
{ {
return (N > (size() + n)); return (N > (size() + n));
} }
@@ -103,7 +103,7 @@ class Fifo
volatile uint32_t widx; volatile uint32_t widx;
volatile uint32_t ridx; volatile uint32_t ridx;
inline uint32_t nextIndex(uint32_t idx) static inline uint32_t nextIndex(uint32_t idx)
{ {
return (idx + 1) & (N - 1); return (idx + 1) & (N - 1);
} }
+2 -1
View File
@@ -69,7 +69,7 @@ const CrossfireSensor & getCrossfireSensor(uint8_t id, uint8_t subId)
void processCrossfireTelemetryValue(uint8_t index, int32_t value) void processCrossfireTelemetryValue(uint8_t index, int32_t value)
{ {
if(!TELEMETRY_STREAMING()) if (!TELEMETRY_STREAMING())
return; return;
const CrossfireSensor & sensor = crossfireSensors[index]; const CrossfireSensor & sensor = crossfireSensors[index];
@@ -201,6 +201,7 @@ void processCrossfireTelemetryData(uint8_t data)
auxSerialPutc(data); auxSerialPutc(data);
} }
#endif #endif
#if defined(AUX2_SERIAL) #if defined(AUX2_SERIAL)
if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) { if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) {
aux2SerialPutc(data); aux2SerialPutc(data);