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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
PROJ_NAME = uwb_simple_example
# Build folder
ODIR      = ./objects
 
# Detect Unix-style shell
ifeq ($(findstring /,$(PWD)),/)
RM        = rm -f
FixPath   = $1
MKDIR     = mkdir -p
MV        = mv -f
$(info Unix-Style)
else
SHELL    := cmd.exe
RM        = del /Q
FixPath   = $(subst /,\,$1)
MKDIR     = mkdir
MV        = copy
$(info Windows)
endif
 
 
# Configure tool names
CC        = arm-none-eabi-gcc
CXX       = arm-none-eabi-g++
AS        = arm-none-eabi-as
OBJCOPY   = arm-none-eabi-objcopy -O binary -S
SIZE      = arm-none-eabi-size
 
 
# Define CPU target
#  - Use Cortex-M1 if tools do not provide named support for Cortex-M0
#  - Compiling for Cortex-M1 will produce code compatible with Cortex-M0
CPUTARGET = -mcpu=Cortex-M0 -mthumb -mthumb-interwork
 
#
# CM0MCU compiler options
#
CCFLAGS   = $(CPUTARGET) -std=c99 -O2 -g -DUWB_EN
CCFLAGS  += -ffunction-sections -fdata-sections
 
LDFLAGS   = $(CPUTARGET) -T ../../../../../devices/MK800X/Source/GCC/gcc_arm.ld 
# Use newlib-nano
LDFLAGS  += --specs=nano.specs
LDFLAGS  += --specs=nosys.specs
# print float
#LDFLAGS  += -u_printf_float
# Link for code size
LDFLAGS  += -Wl,--gc-sections
# Create map file
LDFLAGS  += -Wl,-Map=$(PROJ_NAME).map
 
ASFLAGS   = $(CPUTARGET) --keep
 
 
# Source code
SRC       = ../../../board.c \
            ../pin_config.c \
            ../../../../src/uwb_examples/uwb_simple_example/main.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_ds_twr_init/simple_ds_twr_init.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_ds_twr_init_sts/simple_ds_twr_init_sts.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_ds_twr_resp/simple_ds_twr_resp.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_ds_twr_resp_sts/simple_ds_twr_resp_sts.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_rx/simple_rx.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_tx/simple_tx.c \
            ../../../../../components/algo/src/steering_vector/cmp_svec.c \
            ../../../../../components/crc/crc.c \
            ../../../../../components/libc/libc.c \
            ../../../../../components/wsf/sources/platform/pal_flash.c \
            ../../../../../components/wsf/sources/platform/pal_sys.c \
            ../../../../../components/wsf/sources/platform/pal_uart.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_assert.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_buf.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_bufio.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_heap.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_msg.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_nvm.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_os.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_queue.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_timer.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_trace.c \
            ../../../../../devices/MK800X/Source/startup_MK800X.c \
            ../../../../../devices/MK800X/Source/system_MK800X.c \
            ../../../../../drivers/mk_adc.c \
            ../../../../../drivers/mk_aes.c \
            ../../../../../drivers/mk_calib.c \
            ../../../../../drivers/mk_clock.c \
            ../../../../../drivers/mk_dma.c \
            ../../../../../drivers/mk_dual_timer.c \
            ../../../../../drivers/mk_flash.c \
            ../../../../../drivers/mk_gpio.c \
            ../../../../../drivers/mk_io.c \
            ../../../../../drivers/mk_misc.c \
            ../../../../../drivers/mk_power.c \
            ../../../../../drivers/mk_reset.c \
            ../../../../../drivers/mk_rtc.c \
            ../../../../../drivers/mk_sleep_timer.c \
            ../../../../../drivers/mk_trace.c \
            ../../../../../drivers/mk_uart.c \
            ../../../../../drivers/mk_uwb.c \
            ../../../../../drivers/mk_wdt.c \
 
 
# Include path
INC       = -I../../../../../CMSIS/Include \
            -I../../.. \
            -I.. \
            -I../../../../../components/algo/inc \
            -I../../../../../components/crc \
            -I../../../../../components/libc \
            -I../../../../../components/wsf/include \
            -I../../../../../components/wsf/include/platform \
            -I../../../../../devices/MK800X/Include \
            -I../../../../../drivers \
 
 
# Include library
LIB       = ../../../../../components/algo/lib/lib_aoa.a \
            ../../../../../components/algo/lib/lib_ranging.a \
            ../../../../../drivers/lib/lib_lsp.a \
            ../../../../../drivers/lib/lib_mac_phy.a \
            -lm \
 
ODIR_     = $(call FixPath, $(ODIR))
OBJS      = $(patsubst %.c, $(ODIR)/%.o, $(notdir $(SRC)))
OBJS_     = $(call FixPath, $(OBJS))
 
ifneq ($(ODIR), $(wildcard $(ODIR)))
$(shell $(MKDIR) $(ODIR_))
endif
 
$(info $(ODIR))
$(info $(OBJS))
 
SOURSE_DIR = $(dir $(SRC))
 
vpath %.c $(SOURSE_DIR)
 
.PHONY: all clean
 
################################################################################
#
# Rule deck
#
 
all: $(PROJ_NAME).bin $(PROJ_NAME).elf $(OBJS)
 
$(ODIR)/%.o: %.c
        $(info $< $@)
        $(CC) -c $(CCFLAGS) $(INC) $< -o $@
 
%.elf: $(OBJS)
        $(CC) $(LDFLAGS) $^ -Xlinker "-(" $(LIB) -Xlinker "-)" -o $(PROJ_NAME).elf
        $(SIZE) $@
 
%.bin: %.elf
        $(OBJCOPY) $(PROJ_NAME).elf $(PROJ_NAME).bin
 
 
################################################################################
#
# Clean - remove all .bin, .elf, .map
#
 
clean:
        $(RM) $(OBJS_) *.bin *.elf *.map
 
download:
        -./pyjlink -f $(PROJ_NAME).bin
# EOF