UART: fix transmission problem when buffer is full
This commit is contained in:
parent
730885fbdd
commit
3c7466ca0e
|
@ -15,7 +15,7 @@
|
||||||
/** library for UART communication (code)
|
/** library for UART communication (code)
|
||||||
* @file uart.c
|
* @file uart.c
|
||||||
* @author King Kévin <kingkevin@cuvoodoo.info>
|
* @author King Kévin <kingkevin@cuvoodoo.info>
|
||||||
* @date 2016-2017
|
* @date 2016-2018
|
||||||
* @note peripherals used: USART @ref uart
|
* @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
|
while (tx_used>=LENGTH(tx_buffer)) { // idle until buffer has some space
|
||||||
usart_enable_tx_interrupt(USART(UART_ID)); // enable transmit interrupt
|
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
|
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
|
tx_buffer[(tx_i+tx_used)%LENGTH(tx_buffer)] = c; // put character in buffer
|
||||||
|
|
Loading…
Reference in New Issue