UART: fix transmission problem when buffer is full
This commit is contained in:
parent
772cbe70ea
commit
dc389ceaeb
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue