From f2e913329b8e62bf7eae97c8763bcdeb21b48dfc Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Fri, 27 May 2016 15:49:27 -0500 Subject: [PATCH] Well, at least it compiles now! --- avr/Makefile | 33 +++++++++++++++++++++++++++++++++ avr/uart.c | 20 ++++++++++---------- include/tabby/avr/uart.h | 2 +- 3 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 avr/Makefile diff --git a/avr/Makefile b/avr/Makefile new file mode 100644 index 0000000..411c59f --- /dev/null +++ b/avr/Makefile @@ -0,0 +1,33 @@ +include ../mk/build.mk + +INCLUDE_PATH = ../include +HEADER_SUBDIR = tabby + +CROSS = avr- +CC = $(CROSS)gcc +CFLAGS = $(CGFLAGS) -Wall -Os -mmcu=atmega32u4 -I$(INCLUDE_PATH) +LDFLAGS = + +HEADERS_LOCAL = +HEADERS_BUILD = $(HEADERS_LOCAL) \ + $(addprefix $(INCLUDE_PATH)/$(HEADER_SUBDIR)/,$(HEADERS)) + +NAME = tabby + +HEADERS = avr/buffer.h avr/uart.h clock.h command.h link.h +OBJS = main.o uart.o + +IMAGE_ELF = $(NAME).elf + +RM = /bin/rm + +all: $(IMAGE_ELF) + +$(IMAGE_ELF): $(OBJS) + $(CC) $(CFLAGS) $(OBJS) -o $@ + +$(OBJS): %.o: %.c $(HEADERS_BUILD) + $(CC) $(CFLAGS) -c $< + +clean: + $(RM) -f $(IMAGE_ELF) $(OBJS) diff --git a/avr/uart.c b/avr/uart.c index 498baa5..ef0b135 100644 --- a/avr/uart.c +++ b/avr/uart.c @@ -11,27 +11,27 @@ #include void uart_init() { - UBRR0H = UBRRH_VALUE; - UBRR0L = UBRRL_VALUE; + UBRR1H = UBRRH_VALUE; + UBRR1L = UBRRL_VALUE; #if USE_2X - UCSR0A |= _BV(U2X0); + UCSR1A |= _BV(U2X1); #else - UCSR0A &= ~(_BV(U2X0)); + UCSR1A &= ~(_BV(U2X1)); #endif - UCSR0C = _BV(UCSZ01) | _BV(UCSZ00); - UCSR0B = _BV(RXEN0) | _BV(TXEN0); + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); + UCSR1B = _BV(RXEN1) | _BV(TXEN1); } void uart_putchar(char c, FILE *fh) { - loop_until_bit_is_set(UCSR0A, UDRE0); + loop_until_bit_is_set(UCSR1A, UDRE1); - UDR0 = c; + UDR1 = c; } char uart_getchar(FILE *fh) { - loop_until_bit_is_set(UCSR0A, RXC0); + loop_until_bit_is_set(UCSR1A, RXC1); - return UDR0; + return UDR1; } diff --git a/include/tabby/avr/uart.h b/include/tabby/avr/uart.h index 3e47d5f..4bfdcbf 100644 --- a/include/tabby/avr/uart.h +++ b/include/tabby/avr/uart.h @@ -1,7 +1,7 @@ #ifndef _TABBY_AVR_UART_H #define _TABBY_AVR_UART_H -#define TABBY_AVR_UART_BAUD 115200 +#define TABBY_AVR_UART_BAUD 57600 void uart_init();