1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Update UART driver so it reports the amount of bytes waiting.

Previously it reported '1' if there is one or more.
This commit is contained in:
Dominic Clifton 2014-05-21 19:26:39 +01:00
parent bcc9b8ca71
commit 582cf5ad00

View file

@ -160,11 +160,11 @@ void uartStartTxDMA(uartPort_t *s)
uint8_t uartTotalBytesWaiting(serialPort_t *instance) uint8_t uartTotalBytesWaiting(serialPort_t *instance)
{ {
uartPort_t *s = (uartPort_t*)instance; uartPort_t *s = (uartPort_t*)instance;
// FIXME always returns 1 or 0, not the amount of bytes waiting
if (s->rxDMAChannel) if (s->rxDMAChannel)
return s->rxDMAChannel->CNDTR != s->rxDMAPos; return (s->rxDMAChannel->CNDTR - s->rxDMAPos) & (s->port.txBufferSize - 1);
else else {
return s->port.rxBufferTail != s->port.rxBufferHead; return (s->port.rxBufferHead - s->port.rxBufferTail) & (s->port.txBufferSize - 1);
}
} }
// BUGBUG TODO TODO FIXME - What is the bug? // BUGBUG TODO TODO FIXME - What is the bug?