mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Optimize uart buffer counter incrementing.
This commit is contained in:
parent
39f9b799d3
commit
6610a91ce0
2 changed files with 4 additions and 8 deletions
|
@ -58,8 +58,7 @@ void usartIrqCallback(uartPort_t *s)
|
|||
if (s->port.callback) {
|
||||
s->port.callback(s->USARTx->DR);
|
||||
} else {
|
||||
s->port.rxBuffer[s->port.rxBufferHead] = s->USARTx->DR;
|
||||
s->port.rxBufferHead++;
|
||||
s->port.rxBuffer[s->port.rxBufferHead++] = s->USARTx->DR;
|
||||
if (s->port.rxBufferHead >= s->port.rxBufferSize) {
|
||||
s->port.rxBufferHead = 0;
|
||||
}
|
||||
|
@ -67,8 +66,7 @@ void usartIrqCallback(uartPort_t *s)
|
|||
}
|
||||
if (SR & USART_FLAG_TXE) {
|
||||
if (s->port.txBufferTail != s->port.txBufferHead) {
|
||||
s->USARTx->DR = s->port.txBuffer[s->port.txBufferTail];
|
||||
s->port.txBufferTail++;
|
||||
s->USARTx->DR = s->port.txBuffer[s->port.txBufferTail++];
|
||||
if (s->port.txBufferTail >= s->port.txBufferSize) {
|
||||
s->port.txBufferTail = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue