Hardcode for ATmega328p register names in avr/uart.c

This commit is contained in:
XANTRONIX Development 2016-05-28 19:22:31 -05:00
parent 772f2c3d17
commit a8c1fc27ff

View file

@ -11,27 +11,29 @@
#include <util/setbaud.h>
void uart_init() {
UBRR1H = UBRRH_VALUE;
UBRR1L = UBRRL_VALUE;
UBRR0H = UBRRH_VALUE;
UBRR0L = UBRRL_VALUE;
#if USE_2X
UCSR1A |= _BV(U2X1);
UCSR0A |= _BV(U2X0);
#else
UCSR1A &= ~(_BV(U2X1));
UCSR0A &= ~(_BV(U2X0));
#endif
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
UCSR1B = _BV(RXEN1) | _BV(TXEN1);
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
}
void uart_putchar(char c, FILE *fh) {
loop_until_bit_is_set(UCSR1A, UDRE1);
int uart_putchar(char c, FILE *fh) {
loop_until_bit_is_set(UCSR0A, UDRE0);
UDR1 = c;
UDR0 = c;
return 0;
}
char uart_getchar(FILE *fh) {
loop_until_bit_is_set(UCSR1A, RXC1);
int uart_getchar(FILE *fh) {
loop_until_bit_is_set(UCSR0A, RXC0);
return UDR1;
return UDR0;
}