Well, at least it compiles now!
This commit is contained in:
parent
c89e14d307
commit
f2e913329b
3 changed files with 44 additions and 11 deletions
33
avr/Makefile
Normal file
33
avr/Makefile
Normal file
|
@ -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)
|
20
avr/uart.c
20
avr/uart.c
|
@ -11,27 +11,27 @@
|
||||||
#include <util/setbaud.h>
|
#include <util/setbaud.h>
|
||||||
|
|
||||||
void uart_init() {
|
void uart_init() {
|
||||||
UBRR0H = UBRRH_VALUE;
|
UBRR1H = UBRRH_VALUE;
|
||||||
UBRR0L = UBRRL_VALUE;
|
UBRR1L = UBRRL_VALUE;
|
||||||
|
|
||||||
#if USE_2X
|
#if USE_2X
|
||||||
UCSR0A |= _BV(U2X0);
|
UCSR1A |= _BV(U2X1);
|
||||||
#else
|
#else
|
||||||
UCSR0A &= ~(_BV(U2X0));
|
UCSR1A &= ~(_BV(U2X1));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
|
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
|
||||||
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
|
UCSR1B = _BV(RXEN1) | _BV(TXEN1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uart_putchar(char c, FILE *fh) {
|
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) {
|
char uart_getchar(FILE *fh) {
|
||||||
loop_until_bit_is_set(UCSR0A, RXC0);
|
loop_until_bit_is_set(UCSR1A, RXC1);
|
||||||
|
|
||||||
return UDR0;
|
return UDR1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _TABBY_AVR_UART_H
|
#ifndef _TABBY_AVR_UART_H
|
||||||
#define _TABBY_AVR_UART_H
|
#define _TABBY_AVR_UART_H
|
||||||
|
|
||||||
#define TABBY_AVR_UART_BAUD 115200
|
#define TABBY_AVR_UART_BAUD 57600
|
||||||
|
|
||||||
void uart_init();
|
void uart_init();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue