From a09ebf4a690b86b7cc629d3c1a9e18c4ab4fc097 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 17 May 2012 02:30:01 +0200 Subject: uart: volatile/uart_wait() --- uart.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/uart.c b/uart.c index fcc5783..feb9619 100644 --- a/uart.c +++ b/uart.c @@ -1,6 +1,6 @@ #define TXBSIZE 128 -static char txbuf[TXBSIZE]; -static uint8_t txput = 0, txsend = 0; +static volatile char txbuf[TXBSIZE]; +static volatile uint8_t txput = 0, txsend = 0; ISR(USART_RX_vect) { @@ -19,6 +19,12 @@ ISR(USART_UDRE_vect) } } +static void uart_wait(void) +{ + while (txsend != txput) + asm volatile ("" : : : "memory"); +} + static void _uart_putch(const char ch) { txbuf[txput] = ch; -- cgit v1.2.1