]>
git.zerfleddert.de Git - rsbs2/blob - bmc/usart.c
36ba83c6b127339fa9a982a83772fc1892539a38
6 #define UBRR_VAL ((F_CPU+BAUD*8)/(BAUD*16)-1)
7 #define BAUD_REAL (F_CPU/(16*(UBRR_VAL+1)))
8 #define BAUD_ERROR ((BAUD_REAL*1000)/BAUD)
10 #if ((BAUD_ERROR<990) || (BAUD_ERROR>1010))
11 #error Systematischer Fehler der Baudrate grösser 1% und damit zu hoch!
14 int usart_put(char c
, FILE *stream
)
17 usart_put('\r', stream
);
19 while(!(UCSRA
& (1<<UDRE
))) {}
24 static FILE usart_stdout
= FDEV_SETUP_STREAM(usart_put
, NULL
, _FDEV_SETUP_WRITE
);
29 UCSRC
|= (1<<URSEL
)|(1 << UCSZ1
)|(1 << UCSZ0
);
31 UBRRH
= UBRR_VAL
>> 8;
32 UBRRL
= UBRR_VAL
& 0xFF;
34 stdout
= &usart_stdout
;