-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·59 lines (43 loc) · 1.2 KB
/
Makefile
File metadata and controls
executable file
·59 lines (43 loc) · 1.2 KB
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
# Name: Makefile
# Author: Forrest Koran
# License: -TBD-
all:
hugs: TARGET = -DTARGET_HUGS
hugs: DEVICE = atmega8
hugs: PROGRAMMER = -c usbtiny -p m8
hugs: FUSES = -U hfuse:w:0xCA:m -U lfuse:w:0x3F:m
hugs: CLOCK = 16000000
hugs: clean hugs.hex
arduino: TARGET = -DTARGET_ARDUINO
arduino: DEVICE = atmega168
arduino: PROGRAMMER = -c usbtiny -p m168
arduino: FUSES = -U hfuse:w:0xCA:m -U lfuse:w:0x3F:m
arduino: CLOCK = 16000000
arduino: clean arduino.hex
OBJECTS = bldc.o lut.o lut_data.o hal.o
FIXED_REGS = -ffixed-4 -ffixed-5 -ffixed-6 -ffixed-7 -ffixed-8 -ffixed-9 -ffixed-10
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -std=gnu11 -Wall -O3 $(FIXED_REGS) $(TARGET) -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g
.c.o:
$(COMPILE) -c $< -o $@
.S.o:
$(COMPILE) -c $< -o $@
%.lst: %.elf
avr-objdump -h -S $< > $@
avr-objdump -d $<
.c.s:
$(COMPILE) -S $< -o $@
%.hex: %.elf
rm -f $@.hex
avr-objcopy -j .text -j .data -O ihex $< $@
avr-size --format=avr --mcu=$(DEVICE) $<
hugs.elf: $(OBJECTS)
$(COMPILE) -o $@ $(OBJECTS)
arduino.elf: $(OBJECTS)
$(COMPILE) -o $@ $(OBJECTS)
lut_data.c:
python gen_lut.py 96
clean:
rm -f *.hex *.elf *.lst lut_data.c lut*.png $(OBJECTS)
cpp:
$(COMPILE) -E bldc.c