mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Update serial port irq handlers so they avoid the % operator.
This commit is contained in:
parent
d8127f65ad
commit
ad9a2d2833
2 changed files with 16 additions and 4 deletions
|
@ -59,13 +59,19 @@ void usartIrqCallback(uartPort_t *s)
|
|||
s->port.callback(s->USARTx->DR);
|
||||
} else {
|
||||
s->port.rxBuffer[s->port.rxBufferHead] = s->USARTx->DR;
|
||||
s->port.rxBufferHead = (s->port.rxBufferHead + 1) % s->port.rxBufferSize;
|
||||
s->port.rxBufferHead++;
|
||||
if (s->port.rxBufferHead >= s->port.rxBufferSize) {
|
||||
s->port.rxBufferHead = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
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->port.txBufferTail + 1) % s->port.txBufferSize;
|
||||
s->port.txBufferTail++;
|
||||
if (s->port.txBufferTail >= s->port.txBufferSize) {
|
||||
s->port.txBufferTail = 0;
|
||||
}
|
||||
} else {
|
||||
USART_ITConfig(s->USARTx, USART_IT_TXE, DISABLE);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue