forked from arturo182/bbq10kbd_i2c_sw
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
152 lines (132 loc) · 3.75 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
CROSS_COMPILE ?= arm-none-eabi-
TARGET ?= lagom
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
OBJCOPY := $(CROSS_COMPILE)objcopy
SIZE := $(CROSS_COMPILE)size
include targets/$(TARGET)/target.mk
SRCS += \
SDK/common/utils/interrupt/interrupt_sam_nvic.c \
SDK/common2/services/delay/sam0/cycle_counter.c \
SDK/sam0/drivers/extint/extint_callback.c \
SDK/sam0/drivers/extint/extint_sam_d_r_h/extint.c \
SDK/sam0/drivers/port/port.c \
SDK/sam0/drivers/sercom/sercom.c \
SDK/sam0/drivers/sercom/sercom_interrupt.c \
SDK/sam0/drivers/sercom/usart/usart.c \
SDK/sam0/drivers/system/clock/clock_samd20/clock.c \
SDK/sam0/drivers/system/clock/clock_samd20/gclk.c \
SDK/sam0/drivers/sercom/i2c/i2c_samd20/i2c_slave.c \
SDK/sam0/drivers/sercom/i2c/i2c_samd20/i2c_slave_interrupt.c \
SDK/sam0/drivers/system/pinmux/pinmux.c \
SDK/sam0/drivers/system/system.c \
SDK/sam0/drivers/tc/tc_sam_d_r_h/tc.c \
SDK/sam0/utils/cmsis/samd20/source/gcc/startup_samd20.c \
SDK/sam0/utils/cmsis/samd20/source/system_samd20.c \
SDK/sam0/utils/syscalls/gcc/syscalls.c \
targets/$(TARGET)/target.c \
app/backlight.c \
app/fifo.c \
app/i2c.c \
app/keyboard.c \
app/main.c \
app/reg.c \
app/time.c \
app/gpio.c \
INCS += \
SDK/common/utils \
SDK/common2/services \
SDK/common2/services/delay \
SDK/sam0/drivers/extint \
SDK/sam0/drivers/gpio \
SDK/sam0/drivers/port \
SDK/sam0/drivers/sercom \
SDK/sam0/drivers/sercom/i2c \
SDK/sam0/drivers/system \
SDK/sam0/drivers/system/clock \
SDK/sam0/drivers/system/clock/clock_samd20 \
SDK/sam0/drivers/sercom \
SDK/sam0/drivers/system/interrupt \
SDK/sam0/drivers/system/interrupt/system_interrupt_samd20 \
SDK/sam0/drivers/system/pinmux \
SDK/sam0/drivers/system/power/power_sam_d_r_h \
SDK/sam0/drivers/system/reset/reset_sam_d_r_h \
SDK/sam0/drivers/tc \
SDK/sam0/utils \
SDK/sam0/utils/cmsis/samd20/include \
SDK/sam0/utils/cmsis/samd20/source \
SDK/sam0/utils/header_files \
SDK/sam0/utils/preprocessor \
SDK/thirdparty/CMSIS/Include \
targets/$(TARGET) \
targets \
app/config \
app
DEFS += \
EXTINT_CALLBACK_MODE=true \
I2C_SLAVE_CALLBACK_MODE=true \
CYCLE_MODE
ifdef DEBUG
DEFS += \
DEBUG=true
endif
LIBS += \
OBJS := $(patsubst %.c,out/$(TARGET)/obj/%.c.o, $(filter %.c, $(SRCS)))
DEPS := $(patsubst %.o,%.d,$(OBJS))
LDSCRIPT := SDK/sam0/utils/linker_scripts/samd20/gcc/$(LD_FILE)
CFLAGS := \
-mcpu=cortex-m0plus -mthumb \
-std=gnu99 -Os -g -Wall -Wextra \
-Wno-missing-field-initializers -Wno-unused-parameter -Wno-expansion-to-defined \
-ffunction-sections -fdata-sections -fomit-frame-pointer \
$(addprefix -D, $(DEFS)) \
$(addprefix -I, $(INCS))
LDFLAGS := \
-mcpu=cortex-m0plus -mthumb \
-Wl,--gc-sections --specs=nano.specs \
-T$(LDSCRIPT) \
$(LIBS)
all: out/$(TARGET)/app.bin
.PHONY: all
out/$(TARGET)/obj/%.c.o: %.c
@echo "CC $<"
@mkdir -p $(dir $@)
@$(CC) -MM -MF $(subst .o,.d,$@) -MP -MT "$@ $(subst .o,.d,$@)" $(CFLAGS) $<
@$(CC) $(CFLAGS) -c -o $@ $<
out/$(TARGET)/app.elf: $(OBJS)
@echo "LD $@"
@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -Xlinker -Map=$@.map
@$(SIZE) $@
%.bin: %.elf
@$(OBJCOPY) -O binary $< $@
clean:
@echo "Removing the out directory"
@rm -rf out/
.PHONY: clean
flash: out/$(TARGET)/app.bin
@echo -e "reset halt\nprogram $< verify\nreset run\nexit\n" | nc localhost 4444
.PHONY: flash
daplink:
@openocd \
-f interface/cmsis-dap.cfg \
-c "transport select swd" \
-f target/at91samdXX.cfg \
-c "init ; reset halt"
.PHONY: daplink
stlink:
@openocd \
-f interface/stlink-v2.cfg \
-f target/at91samdXX.cfg \
-c "init ; reset halt"
.PHONY: stlink
jlink:
@openocd \
-f interface/jlink.cfg \
-c "transport select swd" \
-c "set WORKAREASIZE 0" \
-f target/at91samdXX.cfg \
-c "init ; reset halt"
.PHONY: jlink
ifneq ("$(MAKECMDGOALS)","clean")
-include $(DEPS)
endif