diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2014-04-08 11:28:54 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2014-04-22 16:51:13 +0200 |
commit | 68c180f2aba4471483e1786556c2bc2a94a7d2a7 (patch) | |
tree | 13fd0790193e9e9fe8a745b58cfe34bc108b9b22 /uart.c | |
parent | e3897565c342bee4765f921240b7ca91cd9b23f1 (diff) | |
download | hourglass-68c180f2aba4471483e1786556c2bc2a94a7d2a7.tar.gz hourglass-68c180f2aba4471483e1786556c2bc2a94a7d2a7.tar.bz2 hourglass-68c180f2aba4471483e1786556c2bc2a94a7d2a7.zip |
Increase CPU and UART speed
Re-enable interrupt based accel.
Diffstat (limited to 'uart.c')
-rw-r--r-- | uart.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -2,6 +2,7 @@ #include <avr/io.h> #include "uart.h" +#include "common.h" /* blocking uart send */ @@ -23,13 +24,23 @@ static int uartPutc (char c, FILE *stream) { static FILE mystdout = FDEV_SETUP_STREAM (uartPutc, NULL, _FDEV_SETUP_WRITE); void uartInit () { - /* Set baud rate (9600, double speed, at 1mhz) */ UBRR0H = 0; +#if F_CPU == 1000000 + /* Set baud rate (9600, double speed) */ UBRR0L = 12; +#elif F_CPU == 4000000 + /* Set baud rate (9600, double speed) */ + UBRR0L = 51; +#elif F_CPU == 8000000 + /* baudrate 38.4k */ + UBRR0L = 25; +#else +#error "cpu speed not supported" +#endif /* enable double speed mode */ UCSR0A = (1 << U2X0); /* Enable receiver and transmitter */ - UCSR0B = (1<<RXEN0)|(1<<TXEN0); + UCSR0B = (1 << RXEN0) | (1 << TXEN0); /* Set frame format: 8 data, 1 stop bit, even parity */ UCSR0C = (1<<UPM01) | (0 << UPM00) | (0<<USBS0)|(3<<UCSZ00); |