From 741e52a6b9b63535507afa219c9d9b0a7c742c7b Mon Sep 17 00:00:00 2001 From: imp Date: Sun, 26 Jan 2014 04:57:58 +0000 Subject: [PATCH] Before resetting the USART, delay a bit to allow the transmitter to finish the current character to drain to avoid glitching. Also, simplify the code a smidge. --- sys/arm/at91/uart_dev_at91usart.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/arm/at91/uart_dev_at91usart.c b/sys/arm/at91/uart_dev_at91usart.c index 1e673edf335..69e3fb9e429 100644 --- a/sys/arm/at91/uart_dev_at91usart.c +++ b/sys/arm/at91/uart_dev_at91usart.c @@ -421,7 +421,6 @@ at91_usart_bus_attach(struct uart_softc *sc) { int err; int i; - uint32_t cr; struct at91_usart_softc *atsc; atsc = (struct at91_usart_softc *)sc; @@ -490,8 +489,8 @@ at91_usart_bus_attach(struct uart_softc *sc) } /* Turn on rx and tx */ - cr = USART_CR_RSTSTA | USART_CR_RSTRX | USART_CR_RSTTX; - WR4(&sc->sc_bas, USART_CR, cr); + DELAY(1000); /* Give pending character a chance to drain. */ + WR4(&sc->sc_bas, USART_CR, USART_CR_RSTSTA | USART_CR_RSTRX | USART_CR_RSTTX); WR4(&sc->sc_bas, USART_CR, USART_CR_RXEN | USART_CR_TXEN); /* -- 2.45.0