/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <avr/io.h>
static int _write(char c, FILE *stream);
-static FILE mystdout = FDEV_SETUP_STREAM(_write,
+static FILE mystdout = FDEV_SETUP_STREAM(_write,
NULL, _FDEV_SETUP_WRITE);
#endif
#if ((BUFFER_SIZE) > 256)
-# error: BUFFER_SIZE
+# error: BUFFER_SIZE
#endif
struct ring rx_ring;
PRR0 &= ~_BV(PRUSART0);
UCSR0B = 0;
+ UCSR0A = 0;
+ UBRR0 = (F_CPU + (baud/2) + 8) / baud / 16 - 1;
+ UCSR0B = _BV(RXCIE0) | _BV(RXEN0) | _BV(TXEN0);
+ UCSR0C = 3 << UCSZ00;
/* Initialize ring buffers. */
ring_init(&rx_ring, rx_ring_buffer, BUFFER_SIZE);
ring_init(&tx_ring, tx_ring_buffer, BUFFER_SIZE);
-
- UCSR0A = 0;
- UBRR0 = F_CPU / baud / 16 - 1;
- UCSR0B = _BV(RXCIE0) | _BV(RXEN0) | _BV(TXEN0);
- UCSR0C = 3 << UCSZ00;
};
}
{
return !ring_is_empty(&rx_ring);
}
-
-