mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +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) {
|
if (s->port.callback) {
|
||||||
s->port.callback(s->USARTx->DR);
|
s->port.callback(s->USARTx->DR);
|
||||||
} else {
|
} else {
|
||||||
s->port.rxBuffer[s->port.rxBufferHead] = s->USARTx->DR;
|
s->port.rxBuffer[s->port.rxBufferHead++] = s->USARTx->DR;
|
||||||
s->port.rxBufferHead++;
|
|
||||||
if (s->port.rxBufferHead >= s->port.rxBufferSize) {
|
if (s->port.rxBufferHead >= s->port.rxBufferSize) {
|
||||||
s->port.rxBufferHead = 0;
|
s->port.rxBufferHead = 0;
|
||||||
}
|
}
|
||||||
|
@ -67,8 +66,7 @@ void usartIrqCallback(uartPort_t *s)
|
||||||
}
|
}
|
||||||
if (SR & USART_FLAG_TXE) {
|
if (SR & USART_FLAG_TXE) {
|
||||||
if (s->port.txBufferTail != s->port.txBufferHead) {
|
if (s->port.txBufferTail != s->port.txBufferHead) {
|
||||||
s->USARTx->DR = s->port.txBuffer[s->port.txBufferTail];
|
s->USARTx->DR = s->port.txBuffer[s->port.txBufferTail++];
|
||||||
s->port.txBufferTail++;
|
|
||||||
if (s->port.txBufferTail >= s->port.txBufferSize) {
|
if (s->port.txBufferTail >= s->port.txBufferSize) {
|
||||||
s->port.txBufferTail = 0;
|
s->port.txBufferTail = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,8 +352,7 @@ void usartIrqHandler(uartPort_t *s)
|
||||||
if (s->port.callback) {
|
if (s->port.callback) {
|
||||||
s->port.callback(s->USARTx->RDR);
|
s->port.callback(s->USARTx->RDR);
|
||||||
} else {
|
} else {
|
||||||
s->port.rxBuffer[s->port.rxBufferHead] = s->USARTx->RDR;
|
s->port.rxBuffer[s->port.rxBufferHead++] = s->USARTx->RDR;
|
||||||
s->port.rxBufferHead++;
|
|
||||||
if (s->port.rxBufferHead >= s->port.rxBufferSize) {
|
if (s->port.rxBufferHead >= s->port.rxBufferSize) {
|
||||||
s->port.rxBufferHead = 0;
|
s->port.rxBufferHead = 0;
|
||||||
}
|
}
|
||||||
|
@ -362,8 +361,7 @@ void usartIrqHandler(uartPort_t *s)
|
||||||
|
|
||||||
if (!s->txDMAChannel && (ISR & USART_FLAG_TXE)) {
|
if (!s->txDMAChannel && (ISR & USART_FLAG_TXE)) {
|
||||||
if (s->port.txBufferTail != s->port.txBufferHead) {
|
if (s->port.txBufferTail != s->port.txBufferHead) {
|
||||||
USART_SendData(s->USARTx, s->port.txBuffer[s->port.txBufferTail]);
|
USART_SendData(s->USARTx, s->port.txBuffer[s->port.txBufferTail++]);
|
||||||
s->port.txBufferTail++;
|
|
||||||
if (s->port.txBufferTail >= s->port.txBufferSize) {
|
if (s->port.txBufferTail >= s->port.txBufferSize) {
|
||||||
s->port.txBufferTail = 0;
|
s->port.txBufferTail = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue