-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (40 loc) · 1.3 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
# --------------------------------------------------------------
# Wiegand-SPI fimreware for ATTINY25/45/85
#
# (c) 2016 Sam Thompson <[email protected]>
# The MIT License
DEVICE = attiny85
CLOCK = 1000000
PROGRAMMER = -c raspid_v1 -b 250000 -C +avrdude.conf
OBJECTS = main.o
BUILD_DIR = build
# Use this to calcuate fuses: http://www.engbedded.com/fusecalc/
FUSES = -U hfuse:w:0x5F:m -U lfuse:w:0x62:m
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
# symbolic targets:
all: main.hex
.c.o:
$(COMPILE) -c $< -o $(BUILD_DIR)/$@
flash: all
$(AVRDUDE) -U flash:w:$(BUILD_DIR)/main.hex:i
fuse:
$(AVRDUDE) $(FUSES)
# Xcode uses the Makefile targets "", "clean" and "install"
install: flash fuse
# if you use a bootloader, change the command below appropriately:
load: all
bootloadHID $(BUILD_DIR)/main.hex
clean:
rm -f $(BUILD_DIR)/*
main.elf: $(OBJECTS)
$(COMPILE) -o $(BUILD_DIR)/main.elf $(addprefix $(BUILD_DIR)/, $(OBJECTS))
main.hex: main.elf
rm -f $(BUILD_DIR)/main.hex
avr-objcopy -j .text -j .data -O ihex $(BUILD_DIR)/main.elf $(BUILD_DIR)/main.hex
avr-size --format=avr --mcu=$(DEVICE) $(BUILD_DIR)/main.elf
# Targets for code debugging and analysis:
disasm: main.elf
avr-objdump -d $(BUILD_DIR)/main.elf
cpp:
$(COMPILE) -E main.c