]>
cvs.zerfleddert.de Git - rsbs2/blob - bmc/usart.c
8 #define UBRR_VAL ((F_CPU+BAUD*8)/(BAUD*16)-1)
9 #define BAUD_REAL (F_CPU/(16*(UBRR_VAL+1)))
10 #define BAUD_ERROR ((BAUD_REAL*1000)/BAUD)
12 #if ((BAUD_ERROR<990) || (BAUD_ERROR>1010))
13 #error Systematischer Fehler der Baudrate grösser 1% und damit zu hoch!
16 int usart_put(char c
, FILE *stream
)
19 usart_put('\r', stream
);
21 while(!(UCSRA
& (1<<UDRE
))) {}
26 static FILE usart_stdout
= FDEV_SETUP_STREAM(usart_put
, NULL
, _FDEV_SETUP_WRITE
);
33 UCSRC
|= (1<<URSEL
)|(1 << UCSZ1
)|(1 << UCSZ0
);
35 UBRRH
= UBRR_VAL
>> 8;
36 UBRRL
= UBRR_VAL
& 0xFF;
38 stdout
= &usart_stdout
;