-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
60 lines (43 loc) · 1.1 KB
/
Makefile
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Global AVR utilities
AVRDUDE=avrdude
OBJCOPY=avr-objcopy
OBJDUMP=avr-objdump
CC=avr-gcc
RM=rm -f
# Microcontroller used
MCU=atmega328p
MCU_AVRDUDE=m328p
F_CPU=16000000UL
SERIALPORT?=/dev/ttyUSB0
BAUD=9600
OPEN_SERIAL=picocom $(SERIALPORT) -b $(BAUD) --imap lfcrlf --parity o --stopbits 2
PROGRAMMER?=usbtiny
BIN_FORMAT=ihex
CFLAGS=-Wall -Wextra -Wno-unused-parameter -g -Os -DF_CPU=$(F_CPU)\
-DBAUD=$(BAUD) -mmcu=$(MCU) -std=c99
TARGET=main
SRC:=$(TARGET).c support/uart.c
OBJ:=$(SRC:.c=.o)
.SUFFIXES: .elf .hex
.SECONDARY: $(OBJS)
all: $(TARGET).hex $(TARGET).elf tags
%.elf: $(OBJ)
$(CC) $(CFLAGS) -o $@ $^
%.hex: %.elf
$(OBJCOPY) -O $(BIN_FORMAT) -R .eeprom $< $@
%.lss: %.elf
$(OBJDUMP) -h -S $< > $@
listing: $(TARGET).lss
upload: $(TARGET).hex
$(AVRDUDE) -v -p $(MCU_AVRDUDE) -c $(PROGRAMMER) -V\
-U flash:w:$(TARGET).hex
serial:
$(OPEN_SERIAL)
setfuses:
$(AVRDUDE) -v -p $(MCU_AVRDUDE) -c $(PROGRAMMER)\
-U lfuse:w:e6:m
tags: $(SOURCES)
@ctags --exclude=.git -R .
clean:
$(RM) $(TARGET).elf $(TARGET).hex $(OBJ) $(TARGET).lss tags
.PHONY: all clean listing serial setfuses upload