1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

Update serial port irq handlers so they avoid the % operator.

This commit is contained in:
Dominic Clifton 2014-12-12 16:23:44 +00:00
parent d8127f65ad
commit ad9a2d2833
2 changed files with 16 additions and 4 deletions

View file

@ -353,14 +353,20 @@ void usartIrqHandler(uartPort_t *s)
s->port.callback(s->USARTx->RDR);
} else {
s->port.rxBuffer[s->port.rxBufferHead] = s->USARTx->RDR;
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 (!s->txDMAChannel && (ISR & USART_FLAG_TXE)) {
if (s->port.txBufferTail != s->port.txBufferHead) {
USART_SendData(s->USARTx, 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);
}