diff options
| author | Keith Packard <keithp@keithp.com> | 2009-07-18 01:04:17 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2009-07-18 01:04:17 -0700 | 
| commit | d3f76ce58b9c0ed2e5a9fe3bbc7fb9cb38247714 (patch) | |
| tree | d7deebda39bc1ae1940453a2a016451115bf68c2 /src | |
| parent | d7c2d358ed8a1afc9f0ba2bd830b10f6b56dc7b1 (diff) | |
Drain serial port before changing speed
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/ao_serial.c | 10 | 
1 files changed, 10 insertions, 0 deletions
| diff --git a/src/ao_serial.c b/src/ao_serial.c index 7bc11b97..4155e776 100644 --- a/src/ao_serial.c +++ b/src/ao_serial.c @@ -76,6 +76,13 @@ ao_serial_putchar(char c) __critical  }  static void +ao_serial_drain(void) __critical +{ +	while (!ao_fifo_empty(ao_usart1_tx_fifo)) +		ao_sleep(&ao_usart1_tx_fifo); +} + +static void  send_serial(void)  {  	ao_cmd_white(); @@ -115,6 +122,9 @@ static const struct {  void  ao_serial_set_speed(uint8_t speed)  { +	ao_serial_drain(); +	if (speed > AO_SERIAL_SPEED_57600) +		return;  	U1BAUD = ao_serial_speeds[speed].baud;  	U1GCR = ao_serial_speeds[speed].gcr;  } | 
