From cda16639cbf19d6eb5c11f05f1045e54b3fdaba9 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 30 Oct 2018 12:07:58 +0100 Subject: [avr] Add test program for IO and basic usart --- sw-avr/rom-loader/makefile | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'sw-avr/rom-loader/makefile') diff --git a/sw-avr/rom-loader/makefile b/sw-avr/rom-loader/makefile index e68174f..85222c8 100644 --- a/sw-avr/rom-loader/makefile +++ b/sw-avr/rom-loader/makefile @@ -1,17 +1,24 @@ -CC=avr-gcc -CARGS=-Wall -mmcu=atmega328p -D__AVR_ATmega328p__ -Os -I. +SOURCES := main.c usart.c +OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) -SOURCES=main.c +CFLAGS := -Wall -mmcu=atmega328p -Os -I. \ + -D__AVR_ATmega328p__ -DF_CPU=1000000UL -DBAUD=9600 +LDFLAGS := .PHONY: all flash clean -all: rom-loader.bin +all: rom-loader.hex -flash: rom-loader.bin - avrdude -c usbasp -p atmega328p +flash: rom-loader.hex + avrdude -c usbasp -p atmega328p -U flash:w:$< clean: - rm rom-loader.bin + rm -f *.bin *.hex *.o -rom-loader.bin: $(SOURCES) - $(CC) $(CARGS) $< -o $@ +rom-loader.hex: rom-loader.bin + avr-objcopy -R .eeprom -O ihex $< $@ +rom-loader.bin: $(OBJECTS) + avr-gcc $(CFLAGS) $(OBJECTS) -o $@ $(LDFLAGS) + +%.o: %.c + avr-gcc $(CFLAGS) $< -c -o $@ $(LDFLAGS) -- cgit v1.2.1