Skip to content

Commit d158adc

Browse files
committed
XMCLib: drivers: Prevent UART overruns
This patch is probably equivalent to disable the FIFO, but as it was, silent overruns were happening. Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
1 parent ceb0746 commit d158adc

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

XMCLib/drivers/src/xmc_uart.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,19 @@ void XMC_UART_CH_Transmit(XMC_USIC_CH_t *const channel, const uint16_t data)
205205
/*Transmit data */
206206
channel->TBUF[0U] = data;
207207
} else {
208+
/* That is probably equivalent to disable the FIFO, but as it
209+
* was before, the code was causing silent overruns to happen. */
210+
211+
/* Wait till the Transmit Buffer is free for transmission */
212+
while (XMC_USIC_CH_GetTransmitBufferStatus(channel) ==
213+
XMC_USIC_CH_TBUF_STATUS_BUSY) {
214+
}
215+
216+
/* Clear the Transmit Buffer indication flag */
217+
XMC_UART_CH_ClearStatusFlag(
218+
channel, (uint32_t)XMC_UART_CH_STATUS_FLAG_TRANSMIT_BUFFER_INDICATION);
219+
220+
/*Transmit data */
208221
channel->IN[0U] = data;
209222
}
210223
}

0 commit comments

Comments
 (0)