From 46eec45f1b308b2d519147487246bdd23763227a Mon Sep 17 00:00:00 2001 From: Erick Ahmed Date: Thu, 25 Dec 2025 22:42:24 +0100 Subject: [PATCH] Update Makefile --- src/Makefile | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Makefile b/src/Makefile index 2d553b4..8f1d328 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,21 +1,28 @@ -MCU = attiny85 -# TODO: change frequency after moving to external oscillator -F_CPU = 1000000UL -TARGET = main - -CC = avr-gcc -OBJCOPY = avr-objcopy - -# check if this is legit with assembly code only -CFLAGS = -mmcu=$(MCU) -Wall -Os -DF_CPU=$(F_CPU) +MCU = attiny85 +F_CPU = 1000000UL +TARGET = main +SRCS = main.S +CC = avr-gcc +OBJCOPY = avr-objcopy +PORT = /dev/tty.usbmodem101 +BAUD = 19200 +PROGRAMMER = usbasp +AVRDUDE = avrdude -P $(PORT) -b $(BAUD) +CFLAGS = -mmcu=$(MCU) -Wall -Os -DF_CPU=$(F_CPU) all: $(TARGET).hex -$(TARGET).elf: $(TARGET).S +$(TARGET).elf: $(SRCS) $(CC) $(CFLAGS) -o $@ $< $(TARGET).hex: $(TARGET).elf $(OBJCOPY) -j .text -j .data -O ihex $< $@ +# Flash to MCU +install: $(TARGET).hex + $(AVRDUDE) -c $(PROGRAMMER) -p $(MCU) -U flash:w:$(TARGET).hex:i -v + clean: rm -f *.elf *.hex + +.PHONY: all install clean