-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (68 loc) · 2.68 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
MMCU=atmega328p
SMCU=$(MMCU)
F_CPU = 20000000
BAUDRATE?=9600
CC=avr-c++
DEFINE=-DF_CPU=$(F_CPU) -DBAUDRATE=$(BAUDRATE) -DORNITHOPTER
INCLUDE=-I./libraries/Arduino/hardware/arduino/avr/libraries/SPI/src/ -I./libraries/RF24/
CFLAGS=-mmcu=$(MMCU) $(DEFINE) -Wall -O1 -std=c++11 -Wno-write-strings -fdata-sections -ffunction-sections -Wl,-gc-sections -fshort-enums
LFLAGS=
LFUSES=0x5E
RADIO_CE?=PC0
RADIO_CSN?=PC1
ifdef WIRED
DEFINE+=-DWIRED
else
DEFINE+=-UWIRED
endif
ifdef MAX_TIMEOUTS
DEFINE+=-DMAX_TIMEOUTS=$(MAX_TIMEOUTS)
endif
ifdef RADIO_POLLING_PERIOD
DEFINE+=-DRADIO_POLLING_PERIOD=$(RADIO_POLLING_PERIOD)
endif
ifdef RADIO_TIMEOUT
DEFINE+=-DRADIO_TIMEOUT=$(RADIO_TIMEOUT)
endif
SPI_CPP=./libraries/Arduino/hardware/arduino/avr/libraries/SPI/src/SPI.cpp
RF24_CPP=./libraries/RF24/RF24.cpp
build/bird.out: src/bird.cc
$(CC) $(CFLAGS) $(DEFINE) -DRADIO_CE=$(RADIO_CE) -DRADIO_CSN=$(RADIO_CSN) -I./ -I./src/ $(INCLUDE) -o $@ $< $(SPI_CPP) $(RF24_CPP) $(LFLAGS)
build/car.out: src/car.cc
$(CC) $(CFLAGS) $(DEFINE) -DRADIO_CE=$(RADIO_CE) -DRADIO_CSN=$(RADIO_CSN) -I./ -I./src/ $(INCLUDE) -o $@ $< $(SPI_CPP) $(RF24_CPP) $(LFLAGS)
build/serial.out: src/serial.cc
$(CC) $(CFLAGS) $(DEFINE) -DRADIO_CE=$(RADIO_CE) -DRADIO_CSN=$(RADIO_CSN) -I./ -I./src/ $(INCLUDE) -o $@ $< $(SPI_CPP) $(RF24_CPP) $(LFLAGS)
build/radio.out: test/radio.cc
@echo "Using pins RADIO_CE =" $(RADIO_CE) " and RADIO_CSN =" $(RADIO_CSN)
$(CC) $(CFLAGS) $(DEFINE) -DRADIO_CE=$(RADIO_CE) -DRADIO_CSN=$(RADIO_CSN) -I./ $(INCLUDE) -o $@ $< $(SPI_CPP) $(RF24_CPP) $(LFLAGS)
build/%.out: test/%.cc
$(CC) $(CFLAGS) $(DEFINE) -I./ -o $@ $< $(LFLAGS)
build/%.hex: build/%.out
avr-objcopy -O ihex $< $@;\
avr-size --mcu=$(MMCU) --format=avr $<
clean:
rm -rf build/*
fuses:
avrdude -p $(SMCU) -P usb -c usbtiny -U lfuse:w:$(LFUSES):m
led: build/led.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
helloworld: build/helloworld.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
echo: build/echo.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
servo: build/servo.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
servos: build/servos.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
dcmotor: build/dcmotor.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
accelerometer: build/accelerometer.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
radio: build/radio.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
bird: build/bird.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
car: build/car.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<
serial: build/serial.hex fuses
avrdude -p $(SMCU) -P usb -c usbtiny -U flash:w:$<