btle.mk 8.72 KB
Newer Older
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
################################################################################
# Copyright (C) 2014 Maxim Integrated Products, Inc., All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
# OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of Maxim Integrated
# Products, Inc. shall not be used except as stated in the Maxim Integrated
# Products, Inc. Branding Policy.
#
# The mere transfer of this software does not imply any licenses
# of trade secrets, proprietary technology, copyrights, patents,
# trademarks, maskwork rights, or any other form of intellectual
# property whatsoever. Maxim Integrated Products, Inc. retains all
# ownership rights.
#
32
# $Id: btle.mk 50302 2019-12-24 15:42:19Z kevin.gillespie $
33
34
35
36
37
38
39
40
41
#
################################################################################

################################################################################
# This file can be included in a project makefile to build the library for the 
# project.
################################################################################

ifeq "$(TARGET)" ""
42
$(error "TARGET must be specified")
43
44
45
46
endif
TARGET_UC:=$(shell echo $(TARGET) | tr a-z A-Z)
TARGET_LC:=$(shell echo $(TARGET) | tr A-Z a-z)

47
48
49
50
51
52
53
54
55
56
57
# Specify the library variant.
ifeq "$(MFLOAT_FLAGS)" "hardfp"
LIBRARY_VARIANT=hardfp
else
ifeq "$(MFLOAT_FLAGS)" "hard"
LIBRARY_VARIANT=hardfp
else
LIBRARY_VARIANT=softfp
endif
endif

58
59
60
PHY_DIR             := ${CORDIO_DIR}/phy
PHY_BUILD_DIR       := ${PHY_DIR}/build
PHY_LIB_DIR         := ${PHY_BUILD_DIR}/${COMPILER}/library
61
ifeq "$(LIBRARY_VARIANT)" ""
62
PHY_LIB             := ${PHY_LIB_DIR}/libphy.a
63
64
65
else
PHY_LIB             := ${PHY_LIB_DIR}/libphy_$(LIBRARY_VARIANT).a
endif
66

67
LINKLAYER_DIR       := ${CORDIO_DIR}/link_layer
68
LINKLAYER_BUILD_DIR := ${LINKLAYER_DIR}/build
69
LINKLAYER_LIB_DIR   := ${LINKLAYER_BUILD_DIR}/${COMPILER}/library
70
ifeq "$(LIBRARY_VARIANT)" ""
71
LINKLAYER_LIB       := ${LINKLAYER_LIB_DIR}/liblinklayer.a
72
73
74
else
LINKLAYER_LIB       := ${LINKLAYER_LIB_DIR}/liblinklayer_$(LIBRARY_VARIANT).a
endif
75

76
STACK_DIR           := ${CORDIO_DIR}/stack
77
STACK_BUILD_DIR     := ${STACK_DIR}/build
78
STACK_LIB_DIR       := ${STACK_BUILD_DIR}/${COMPILER}/library
79
ifeq "$(LIBRARY_VARIANT)" ""
80
STACK_LIB           := ${STACK_LIB_DIR}/libstack.a
81
82
83
else
STACK_LIB           := ${STACK_LIB_DIR}/libstack_$(LIBRARY_VARIANT).a
endif
84

85
WSF_DIR             := ${CORDIO_DIR}/wsf
86
WSF_BUILD_DIR       := ${WSF_DIR}/build
87
WSF_LIB_DIR         := ${WSF_BUILD_DIR}/${COMPILER}/library
88
ifeq "$(LIBRARY_VARIANT)" ""
89
WSF_LIB             := ${WSF_LIB_DIR}/libwsf.a
90
91
92
else
WSF_LIB             := ${WSF_LIB_DIR}/libwsf_$(LIBRARY_VARIANT).a
endif
93
94

# Add to libraries list
95
ifeq ($(BTLE_DEFS_ONLY),)
96
97
98
LIBS += $(LINKLAYER_LIB)
LIBS += $(STACK_LIB)
LIBS += $(WSF_LIB)
99
100
LIBS += $(PHY_LIB)
endif
101

102
103
104
# Add Cordio include path
IPATH += ${CORDIO_DIR}

105
# Add Link Layer include paths
106
107
108
109
110
IPATH += ${LINKLAYER_DIR}/platform/common/include
IPATH += ${LINKLAYER_DIR}/controller/include/ble
IPATH += ${LINKLAYER_DIR}/controller/include/common
IPATH += ${LINKLAYER_DIR}/controller/sources/common/bb
IPATH += ${LINKLAYER_DIR}/controller/sources/ble/include
111
112

# Add Stack include paths
113
IPATH += ${STACK_DIR}/platform/$(TARGET_LC)
114
IPATH += ${STACK_DIR}/platform/include
115
IPATH += ${STACK_DIR}/ble-host/sources/stack/cfg
116
IPATH += ${STACK_DIR}/ble-host/sources/stack/dm
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
IPATH += ${STACK_DIR}/ble-host/include
IPATH += ${STACK_DIR}/ble-host/sources/stack/hci
IPATH += ${STACK_DIR}/ble-host/sources/hci/dual_chip
IPATH += ${STACK_DIR}/ble-profiles/include/app
IPATH += ${STACK_DIR}/ble-profiles/sources/apps
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/app
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/cycling
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/datc
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/dats
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/fit
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/gluc
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/hidapp
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/medc
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/meds
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/sensor
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/tag
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/uribeacon
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/watch
IPATH += ${STACK_DIR}/ble-profiles/sources/apps/wdxs
IPATH += ${STACK_DIR}/ble-profiles/sources/services
IPATH += ${STACK_DIR}/ble-profiles/sources/profiles
IPATH += ${STACK_DIR}/ble-profiles/sources/profiles/include
139
140

# Add WSF include paths
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
IPATH += ${WSF_DIR}/include
IPATH += ${WSF_DIR}/include/util

# Add phy include paths.
IPATH += $(PHY_DIR)/dbb/control/pan
IPATH += $(PHY_DIR)/dbb/prot/ble
IPATH += $(PHY_DIR)/dbb/prot/ble/pan2g5
IPATH += $(PHY_DIR)/dbb/prot/ble/pan2g5/afe
IPATH += $(PHY_DIR)/dbb/prot/ble/pan2g5/afe/max32665
IPATH += $(PHY_DIR)/dbb/prot/ble/pan2g5/afe/max32665/include
IPATH += $(PHY_DIR)/dbb/prot/ble/pan2g5/include
IPATH += $(PHY_DIR)/dbb/prot/shared
IPATH += $(PHY_DIR)/debug
IPATH += $(PHY_DIR)/include
IPATH += $(PHY_DIR)/llc/ble
IPATH += $(PHY_DIR)/llc/shared
157

158
# Add sources
159
BTLE_SRCS := $(notdir $(foreach dir, $(CORDIO_DIR), $(wildcard $(dir)/*.c)))
160

161
162
163
164
165
166
167
168
169
170
171
# Add configurable sources
BTLE_SRCS += hci_drv_sdma.c
BTLE_SRCS += hci_drv.c
BTLE_SRCS += hci_vs.c
BTLE_SRCS += hci_tr.c
BTLE_SRCS += lctr_main_tester.c
BTLE_SRCS += init_ctr.c
BTLE_SRCS += init_ctr_ext.c
BTLE_SRCS += init_ext.c
BTLE_SRCS += init.c

172
173
174
175
# Add btle source paths.
VPATH     += ${STACK_DIR}/platform/${TARGET_LC}
VPATH     += ${LINKLAYER_DIR}/controller/sources/ble/lctr
VPATH     += ${LINKLAYER_DIR}/controller/sources/ble/init
176
177

# Filter sources based on configuration
178
179
180
181
182
183
184
185
186
187
188
189
FILTERED_SRCS :=
ifeq ($(ENABLE_LL_TESTER),)
FILTERED_SRCS+=lctr_main_tester.c
else
PROJ_CFLAGS+=-DLL_ENABLE_TESTER=TRUE
endif

ifeq ($(ENABLE_SDMA),)
FILTERED_SRCS+=hci_drv_sdma.c
else
PROJ_CFLAGS+=-DENABLE_SDMA=TRUE
FILTERED_SRCS+=hci_drv.c
190

191
192
193
# Fixed data memory size for all of the images
PROJ_AFLAGS +=-D__SDMA_DATA_SIZE=0x7BC0

194
195
ifeq ($(SDMA_ADV),)
ifeq ($(SDMA_SCN),)
196
SDMA_CODE_NAME=${STACK_DIR}/platform/$(TARGET_LC)/sdma_code.inc
197
endif
198
199
endif

200
ifneq ($(SDMA_ADV),)
201
# Adv/Slave only
202
PROJ_CFLAGS+=-DSDMA_ADV=TRUE
203
SDMA_CODE_NAME=${STACK_DIR}/platform/$(TARGET_LC)/sdma_adv_code.inc
204
endif
205

206
ifneq ($(SDMA_SCN),)
207
# Scan/Master only
208
PROJ_CFLAGS+=-DSDMA_SCN=TRUE
209
210
SDMA_CODE_NAME=${STACK_DIR}/platform/$(TARGET_LC)/sdma_scn_code.inc

211
endif
212
213
214
215
216
217
218

FILESIZE=$(shell ls -la $(SDMA_CODE_NAME) | tr -s " " | cut -d " " -f5)

# 81 characters per line, 16 bytes per line, round to the upper 16 byte boundary
CODESIZE=$$(( ($(FILESIZE) / 81 + 1 ) * 16 ))
PROJ_AFLAGS +=-D__SDMA_CODE_SIZE=$(CODESIZE)

219
220
endif

221
ifeq ($(BTLE_DEFS_ONLY),)
222
SRCS+=$(filter-out $(FILTERED_SRCS),$(BTLE_SRCS))
223
endif
224
225
226
227
228
229
230
231

# Add definitions
PROJ_CFLAGS+=-DLHCI_ENABLE_VS=TRUE
PROJ_CFLAGS+=-DBB_CLK_RATE_HZ=1600000
PROJ_CFLAGS+=-DLCTR_CONN_NO_TIFS_REASSEMBLY=1
PROJ_CFLAGS+=-DBB_ENABLE_INLINE_ENC_TX=1
PROJ_CFLAGS+=-DBB_ENABLE_INLINE_DEC_RX=1
PROJ_CFLAGS+=-DFORCE_PMU_WAKEUP=1
232
PROJ_CFLAGS+=-DWDX_FTD_ATT_DEFAULT_PAYLOAD_LEN=256
233
234

# Build libraries
235
236
237
export TARGET
export COMPILER
export CMSIS_ROOT
238
239
240
export PROJ_CFLAGS
export IPATH

241
ifeq ($(BTLE_DEFS_ONLY),)
242
243
include ${LINKLAYER_BUILD_DIR}/sources_ll.mk
${LINKLAYER_LIB}: ${LINKLAYER_C_FILES} ${LINKLAYER_H_FILES}
244
	$(MAKE) -C ${LINKLAYER_BUILD_DIR}/${COMPILER} lib
245
246
247

include ${STACK_BUILD_DIR}/sources_stack.mk
${STACK_LIB}: ${STACK_C_FILES} ${STACK_H_FILES}
248
	$(MAKE) -C ${STACK_BUILD_DIR}/${COMPILER} lib
249
250
251

include ${WSF_BUILD_DIR}/sources_wsf.mk
${WSF_LIB}: ${WSF_C_FILES} ${WSF_H_FILES}
252
	$(MAKE) -C ${WSF_BUILD_DIR}/${COMPILER} lib
253

254
255
256
257
include ${PHY_BUILD_DIR}/sources_phy.mk
${PHY_LIB}: ${PHY_C_FILES} ${PHY_H_FILES}
	$(MAKE) -C ${PHY_BUILD_DIR}/${COMPILER} lib
	
258
259
260
261
262
263
264
265
266
clean.stack:
	@rm -rf $(STACK_LIB_DIR)/*

clean.linklayer:
	@rm -rf $(LINKLAYER_LIB_DIR)/*

clean.wsf:
	@rm -rf $(WSF_LIB_DIR)/*

267
268
269
270
271
272
clean.phy:
	@rm -rf $(PHY_LIB_DIR)/*

clean.ble: clean.stack clean.linklayer clean.wsf clean.phy

endif