mirror of
https://github.com/ptrks/avr-usart-printf.git
synced 2025-07-08 11:21:04 +03:00
Update usart_printf.c
This commit is contained in:
@ -8,11 +8,7 @@
|
|||||||
void usart_initialize(void) {
|
void usart_initialize(void) {
|
||||||
UBRR0H = (BAUD_PRESCALE >> 8);
|
UBRR0H = (BAUD_PRESCALE >> 8);
|
||||||
UBRR0L = BAUD_PRESCALE;
|
UBRR0L = BAUD_PRESCALE;
|
||||||
|
|
||||||
//Enable receive and transmit
|
|
||||||
UCSR0B = (1<<RXEN0) | (1<<TXEN0);
|
UCSR0B = (1<<RXEN0) | (1<<TXEN0);
|
||||||
|
|
||||||
// Set frame to 8 bits
|
|
||||||
UCSR0C = (1<<UCSZ01) | (1<<UCSZ00);
|
UCSR0C = (1<<UCSZ01) | (1<<UCSZ00);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,10 +18,8 @@ void usart_send_byte(char byte, FILE *stream) {
|
|||||||
}
|
}
|
||||||
loop_until_bit_is_set(UCSR0A,UDRE0);
|
loop_until_bit_is_set(UCSR0A,UDRE0);
|
||||||
UDR0 = byte;
|
UDR0 = byte;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char usart_get_byte(FILE *stream) {
|
char usart_get_byte(FILE *stream) {
|
||||||
loop_until_bit_is_set(UCSR0A, RXC0);
|
loop_until_bit_is_set(UCSR0A, RXC0);
|
||||||
return UDR0;
|
return UDR0;
|
||||||
|
Reference in New Issue
Block a user