|
@@ -1,8 +1,10 @@
|
1
|
1
|
MCU = attiny85
|
2
|
2
|
F_CPU = 16000000
|
3
|
3
|
RM = rm -rf
|
|
4
|
+MKDIR = mkdir -p
|
4
|
5
|
EXTRAINCDIR = include
|
5
|
6
|
CSTANDARD = gnu99
|
|
7
|
+BUILDDIR = build
|
6
|
8
|
|
7
|
9
|
GCC = avr-gcc
|
8
|
10
|
SIZE = avr-size
|
|
@@ -10,11 +12,13 @@ OBJCOPY = avr-objcopy
|
10
|
12
|
OBJDUMP = avr-objdump
|
11
|
13
|
AVRDUDE = avrdude
|
12
|
14
|
|
13
|
|
-SRC = src/spi.c
|
|
15
|
+SRC = src/main.c
|
|
16
|
+SRC += src/timer.c
|
|
17
|
+SRC += src/spi.c
|
14
|
18
|
SRC += src/cc2500.c
|
15
|
|
-SRC += src/frsky_arduino_rx_complete.c
|
|
19
|
+SRC += src/rx.c
|
16
|
20
|
|
17
|
|
-OBJ = $(SRC:.c=.o)
|
|
21
|
+OBJ = $(addprefix $(BUILDDIR)/, $(SRC:.c=.o))
|
18
|
22
|
|
19
|
23
|
CARGS = -mmcu=$(MCU)
|
20
|
24
|
CARGS += -I$(EXTRAINCDIR)
|
|
@@ -25,42 +29,35 @@ CARGS += -fpack-struct
|
25
|
29
|
CARGS += -fshort-enums
|
26
|
30
|
CARGS += -Wall -pedantic -Wstrict-prototypes -Wshadow
|
27
|
31
|
CARGS += -Wpointer-arith -Wcast-qual -Wextra
|
28
|
|
-CARGS += -Wno-write-strings -Wno-unused-parameter
|
|
32
|
+CARGS += -Wno-main -Wno-write-strings -Wno-unused-parameter
|
29
|
33
|
CARGS += -std=$(CSTANDARD)
|
30
|
34
|
CARGS += -DF_CPU=$(F_CPU)
|
31
|
|
-#CARGS += -lm -lprintf_flt
|
32
|
35
|
CARGS += -ffunction-sections
|
33
|
36
|
|
34
|
37
|
LINKER = -Wl,--relax
|
35
|
|
-#LINKER = -Wl,--relax,-u,vfprintf,-lm,-lprintf_flt,-u,vfscanf,-lscanf_flt
|
36
|
|
-#LINKER += -Wl,--defsym=__heap_start=0x802200,--defsym=__heap_end=0x80ffff
|
37
|
|
-#LINKER += -Wl,-gc-sections
|
38
|
38
|
|
39
|
39
|
PROGRAMMER = avrisp2
|
40
|
40
|
ISPPORT = usb
|
41
|
41
|
|
42
|
42
|
TARGET = rx
|
43
|
43
|
|
44
|
|
-all: $(TARGET).hex
|
|
44
|
+all: $(BUILDDIR)/$(TARGET).hex
|
45
|
45
|
|
46
|
|
-%.o: %.c
|
|
46
|
+$(BUILDDIR)/%.o: %.c
|
|
47
|
+ @$(MKDIR) $(BUILDDIR)/$(dir $<)
|
47
|
48
|
$(GCC) -c $< -o $@ $(CARGS)
|
48
|
49
|
|
49
|
|
-$(TARGET).elf: $(OBJ)
|
|
50
|
+$(BUILDDIR)/$(TARGET).elf: $(OBJ)
|
50
|
51
|
$(GCC) $(CARGS) $(OBJ) --output $@ $(LINKER) -Wl,-Map -Wl,$(@:.elf=.map)
|
51
|
|
- $(SIZE) --mcu=$(MCU) -C $@
|
|
52
|
+ $(SIZE) $@
|
52
|
53
|
|
53
|
|
-$(TARGET).hex: $(TARGET).elf
|
|
54
|
+$(BUILDDIR)/$(TARGET).hex: $(BUILDDIR)/$(TARGET).elf
|
54
|
55
|
$(OBJCOPY) -O ihex $< $@
|
55
|
56
|
$(OBJDUMP) -h -S $< > $(@:.hex=.lss)
|
56
|
57
|
|
57
|
|
-program: $(TARGET).hex
|
|
58
|
+program: $(BUILDDIR)/$(TARGET).hex
|
58
|
59
|
$(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -P $(ISPPORT) -e -U $(TARGET).hex
|
59
|
60
|
|
60
|
61
|
clean:
|
61
|
|
- $(RM) $(OBJ)
|
62
|
|
- $(RM) *.o
|
63
|
|
- $(RM) *.elf
|
64
|
|
- $(RM) *.hex
|
65
|
|
- $(RM) *.lss
|
66
|
|
- $(RM) *.map
|
|
62
|
+ $(RM) $(BUILDDIR)
|
|
63
|
+
|