-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile_AVR
42 lines (29 loc) · 823 Bytes
/
Makefile_AVR
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Makefile for AVR projects
# MCU, F_CPU, and other settings
MCU = atmega2560
F_CPU = 16000000UL
BAUD_RATE = 115200
BAUD_PRESCALE = F_CPU / (16 * BAUD_RATE) - 1
# Source files
SRC = avr.c
# Compiler and linker settings
CC = avr-gcc
OBJCOPY = avr-objcopy
AVRDUDE = avrdude
CFLAGS = -Wall -Os -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DBAUD=$(BAUD_RATE)
# Name for the output files
TARGET = avr
HEX_FILE = $(TARGET).hex
# Port and programmer settings for AVRDUDE
PORT = /dev/ttyACM1
PROGRAMMER = wiring
all: $(HEX_FILE)
$(HEX_FILE): $(TARGET).elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
$(TARGET).elf: $(SRC)
$(CC) -Wno-cpp $(CFLAGS) -o $@ $^
flash: $(HEX_FILE)
$(AVRDUDE) -D -c $(PROGRAMMER) -p $(MCU) -P $(PORT) -b $(BAUD_RATE) -U flash:w:$(HEX_FILE)
clean:
rm -f $(TARGET).elf $(HEX_FILE)
.PHONY: all flash clean