Browse Source

UART: fix transmission problem when buffer is full

spark_strober
King Kévin 4 years ago
parent
commit
3c7466ca0e
  1. 4
      lib/uart.c

4
lib/uart.c

@ -15,7 +15,7 @@ @@ -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) @@ -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…
Cancel
Save