2 * fw/uart.h - Functions needed for debugging over uart
4 * Code adapted from http://www.roboternetz.de/wissen/index.php/UART_mit_avr-gcc
5 * and http://www.mikrocontroller.net/articles/AVR-GCC-Tutorial
7 * Published under the Creative Commons Share-Alike licence
8 * https://creativecommons.org/licenses/by-sa/2.0/de/
13 * Josef Filzmaier 2017
19 #define USART_BAUD 38400UL
20 #define F_CPU 8000000UL
22 #define Wait_USART_Ready() while (!(UCSR1A & (1<<UDRE1)))
23 #define UART_UBRR (F_CPU/(16L*USART_BAUD)-1)
25 // initialize USART, 8N1 mode
29 /* TODO: Find a working configuration for uart for the atmega32u2 */
30 #if CHIP == at90usb1287
31 CLKPR = (1 << CLKPCE);
32 CLKPR = 0; // clock prescaler == 0, so we have 16 MHz mpu frequency
34 UCSR1C = (1 << UCSZ10) | (1 << UCSZ11);
35 UCSR1B = (1 << TXEN1);
40 while (UCSR1A & (1 << RXC1));
45 int uart_write_char(char c, FILE* stream)