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
1 changed files with 4 additions and 4 deletions

View File

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