Files
2023-03-13 09:01:12 +00:00

29 lines
542 B
Makefile

avrType=atmega328p
avrFreq=16000000 # 16 Mhz
programmerDev=/dev/ttyUSB0
programmerType=arduino
cflags=-DF_CPU=$(avrFreq) -mmcu=$(avrType) -Wall -Werror -Wextra -Os
objects=$(patsubst %.c,%.o,$(wildcard *.c))
.PHONY: clean flash
all: main.hex
%.o: %.c
avr-gcc $(cflags) -c $< -o $@
main.elf: $(objects)
avr-gcc $(cflags) -o $@ $^
main.hex: main.elf
avr-objcopy -j .text -j .data -O ihex $^ $@
flash: main.hex
avrdude -p$(avrType) -c$(programmerType) -P$(programmerDev) -v -U flash:w:$<
clean:
rm -f main.hex main.elf $(objects)