#include #include #include #include #define F_CPU 16000000UL #define BAUD TABBY_AVR_UART_BAUD #include void uart_init() { UBRR1H = UBRRH_VALUE; UBRR1L = UBRRL_VALUE; #if USE_2X UCSR1A |= _BV(U2X1); #else UCSR1A &= ~(_BV(U2X1)); #endif UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); UCSR1B = _BV(RXEN1) | _BV(TXEN1); } void uart_putchar(char c, FILE *fh) { loop_until_bit_is_set(UCSR1A, UDRE1); UDR1 = c; } char uart_getchar(FILE *fh) { loop_until_bit_is_set(UCSR1A, RXC1); return UDR1; }