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