3 This file is part of the MSP Märklin suite
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
11 #define BIT(n) (1<<(n))
13 void serial_init(uint16_t baud)
15 DDRD = (DDRD&~0x03) | 0x02;
18 baud = (F_CPU/16+baud/2)/baud-1;
21 UCSR0C = BIT(UCSZ00) | BIT(UCSZ01); // 8N1
22 UCSR0B = BIT(RXEN0) | BIT(TXEN0) | BIT(RXCIE0);
25 void serial_write(uint8_t c)
27 while(!(UCSR0A&(1<<UDRE0))) ;