-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (34 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
# Board type (uno, promicro, nano):
BOARD = promicro
# Name of microcontroller (atmega328p, atmega32u4):
MCU = atmega32u4
# Microcontroller clock frequency (Hz).
F_CPU = 16000000
# Name of C compiler:
CC = avr-gcc
# Flags passed to C preprocessor:
CPPFLAGS = -Isrc -DF_CPU=$(F_CPU) -DBOARD_$(BOARD)=1
# Flags passed to C compiler:
CFLAGS = -O3 -Wall -Wno-unused-function -mmcu=$(MCU)
# Name of linker:
LD = avr-gcc
# Flags passed to linker:
LDFLAGS = -mmcu=$(MCU)
# Name of objcopy tool:
OBJCOPY = avr-objcopy
# Name of size tool:
SIZE = avr-size
SOURCES = src/main.c src/clock.c src/comms.c src/data_conversion.c src/debug.c src/rc_receiver.c src/rf_transceiver.c src/includes/receiver.c src/includes/spi.c src/includes/transmitter.c
OBJECTS = $(SOURCES:.c=.o)
all: comms-firmware.hex
comms-firmware.hex: comms-firmware.elf
$(OBJCOPY) -O ihex $< $@
$(SIZE) $@
comms-firmware.elf: $(OBJECTS)
$(LD) $(LDFLAGS) -o $@ $^ -Wl,-u,vfprintf -lprintf_flt
*.o: *.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $<
clean:
rm -f *.hex *.elf src/*.o
flash:
avrdude -p$(MCU) -cc232hm -P/dev/ttyUSB0 -b57600 -U flash:w:comms-firmware.hex:i