static void uart_check_tx(struct uart_device* uart, uint32_t intr)
{
/* We are currently sending, send next char */
- if (intr & LPC_UART_ST_TX_READY) {
+ if (intr & LPC_UART_ST_TX_IDLE) {
if (uart->sending && (uart->out_length > uart->sending)) {
uart->regs->tx_data = uart->out_buff[uart->sending++];
} else {
uart->sending = 0;
- uart->regs->inten_clear = LPC_UART_ST_TX_READY;
+ uart->regs->inten_clear = LPC_UART_ST_TX_IDLE;
}
}
}
{
uint32_t intr = uart->regs->status;
- uart_check_rx(uart, intr);
- uart_check_tx(uart, intr);
/* Clear all flags */
uart->regs->status = LPC_UART_ST_CLEAR;
+ /* And check what got received / sent */
+ uart_check_rx(uart, intr);
+ uart_check_tx(uart, intr);
}
if (!uart->sending && (uart->out_length != 0)) {
uart->sending++;
uart->regs->tx_data = uart->out_buff[0];
- /* Activate only LPC_UART_ST_TX_READY in order to prevent multiple calls to
+ /* Activate only LPC_UART_ST_TX_IDLE in order to prevent multiple calls to
* the interrupt handler, which will cause data loss */
- uart->regs->inten_set = (LPC_UART_ST_TX_READY);
+ uart->regs->inten_set = (LPC_UART_ST_TX_IDLE);
}
}
/* Active wait for message to be sent. If interrupts are
* disabled, call the UART handler while waiting. */
while (uart->sending) {
- if (get_priority_mask() == 0) {
+ if (get_priority_mask() != 0) {
uart_check_tx(uart, uart->regs->status);
}
}