UART: fix transmission problem when buffer is full

This commit is contained in:
King Kévin 2018-06-14 13:18:51 +02:00
parent 730885fbdd
commit 3c7466ca0e
1 changed files with 2 additions and 2 deletions

View File

@ -15,7 +15,7 @@
/** library for UART communication (code)
* @file uart.c
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2016-2017
* @date 2016-2018
* @note peripherals used: USART @ref uart
*/
@ -92,7 +92,7 @@ void uart_putchar_nonblocking(char c)
{
while (tx_used>=LENGTH(tx_buffer)) { // idle until buffer has some space
usart_enable_tx_interrupt(USART(UART_ID)); // enable transmit interrupt
__WFI(); // sleep until something happened
// don't go to sleep since this might prevent an interrupt
}
usart_disable_tx_interrupt(USART(UART_ID)); // disable transmit interrupt to prevent index corruption
tx_buffer[(tx_i+tx_used)%LENGTH(tx_buffer)] = c; // put character in buffer