TI BLE-Stack for Bluetooth 4.2 API Documentation  3.01.00.07
hci_tl.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Group: WCS, BTS
4  $Target Device: DEVICES $
5 
6  ******************************************************************************
7  $License: TISD 2009 $
8  ******************************************************************************
9  $Release Name: PACKAGE NAME $
10  $Release Date: PACKAGE RELEASE DATE $
11  *****************************************************************************/
12 
21 #ifndef HCI_TL_H
22 #define HCI_TL_H
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
29 /*******************************************************************************
30  * INCLUDES
31  */
32 
33 #include "hci.h"
34 #include "osal.h"
35 #include "hci_data.h"
36 #include "hci_event.h"
37 
39 extern uint8 hciTaskID;
40 extern uint8 hciTestTaskID;
41 extern uint8 hciGapTaskID;
42 extern uint8 hciL2capTaskID;
43 extern uint8 hciSmpTaskID;
45 
46 /*******************************************************************************
47  * MACROS
48  */
49 
51 #define HCI_ASSERT(condition) HAL_ASSERT(condition)
52  // end of HCI
54 
55 /*******************************************************************************
56  * CONSTANTS
57  */
58 
64 // OSAL Task Events
65 #define HCI_TX_PROCESS_EVENT 0x0001
66 #define HCI_TEST_UART_SEND_EVENT 0x0002
67 #define HCI_ADV_NOTICE_EVENT 0x0004
68 #define HCI_SCAN_NOTICE_EVENT 0x0008
69 #define HCI_CONN_NOTICE_EVENT 0x0010
70 #define HCI_BDADDR_UPDATED_EVENT 0x4000
71 
72 // OSAL Message Header Events
73 #define HCI_CTRL_TO_HOST_EVENT 0x01
74 #define HCI_HOST_TO_CTRL_CMD_EVENT 0x02
75 #define HCI_HOST_TO_CTRL_DATA_EVENT 0x03
76 
77 #define HCI_BDADDR_LEN 6
78 
79 // Max Allowed HCI Packet
80 #define HCI_MAX_CMD_PKT_SIZE 0xFF
81 #define HCI_MAX_DATA_PKT_SIZE 0xFFFF
82 
83 // Max Data Length in Packet
84 #define HCI_DATA_MAX_DATA_LENGTH 27
85 
86 
92 #define HCI_CMD_MIN_LENGTH 4
93 
100 #define HCI_EVENT_MIN_LENGTH 3
101 
102 
109 #define HCI_DATA_MIN_LENGTH 5
110 
111 #define HCI_MAX_NUM_CONNECTIONS 0x03
112 
113 #define HCI_TX_DATA_ANY_CONNECTION 0xFF
114 
115 // HCI Packet Types
116 #define HCI_CMD_PACKET 0x01
117 #define HCI_ACL_DATA_PACKET 0x02
118 #define HCI_SCO_DATA_PACKET 0x03
119 #define HCI_EVENT_PACKET 0x04
120 
121 
122 // States for Command and Data packet parser
123 #define HCI_PARSER_STATE_PKT_TYPE 0
124 #define HCI_CMD_PARSER_STATE_OPCODE 1
125 #define HCI_CMD_PARSER_STATE_LENGTH 2
126 #define HCI_CMD_PARSER_STATE_DATA 3
127 #define HCI_DATA_PARSER_STATE_HANDLE 4
128 #define HCI_DATA_PARSER_STATE_LENGTH 5
129 #define HCI_DATA_PARSER_STATE_DATA 6
130 
131 // HCI Command Subgroup
132 #define HCI_OPCODE_CSG_LINK_LAYER 0
133 #define HCI_OPCODE_CSG_CSG_L2CAP 1
134 #define HCI_OPCODE_CSG_CSG_ATT 2
135 #define HCI_OPCODE_CSG_CSG_GATT 3
136 #define HCI_OPCODE_CSG_CSG_GAP 4
137 #define HCI_OPCODE_CSG_CSG_SM 5
138 #define HCI_OPCODE_CSG_CSG_Reserved 6
139 #define HCI_OPCODE_CSG_CSG_USER_PROFILE 7
140 
141 // Vendor Specific OGF
142 #define VENDOR_SPECIFIC_OGF 0x3F
143 
144 /*
145 ** HCI Command Opcodes
146 */
147 
148 // Link Control Commands
149 #define HCI_DISCONNECT 0x0406
150 #define HCI_READ_REMOTE_VERSION_INFO 0x041D
151 
152 // Controller and Baseband Commands
153 #define HCI_SET_EVENT_MASK 0x0C01
154 #define HCI_RESET 0x0C03
155 #define HCI_READ_TRANSMIT_POWER 0x0C2D
156 #define HCI_SET_CONTROLLER_TO_HOST_FLOW_CONTROL 0x0C31
158 #define HCI_HOST_BUFFER_SIZE 0x0C33
159 #define HCI_HOST_NUM_COMPLETED_PACKETS 0x0C35
161 #define HCI_SET_EVENT_MASK_PAGE_2 0x0C63
162 #define HCI_READ_AUTH_PAYLOAD_TIMEOUT 0x0C7B
163 #define HCI_WRITE_AUTH_PAYLOAD_TIMEOUT 0x0C7C
164 
165 // Information Parameters
166 #define HCI_READ_LOCAL_VERSION_INFO 0x1001
167 #define HCI_READ_LOCAL_SUPPORTED_COMMANDS 0x1002
168 #define HCI_READ_LOCAL_SUPPORTED_FEATURES 0x1003
169 #define HCI_READ_BDADDR 0x1009
170 
171 // Status Parameters
172 #define HCI_READ_RSSI 0x1405
173 
174 // LE Commands
175 // V4.0
176 #define HCI_LE_SET_EVENT_MASK 0x2001
177 #define HCI_LE_READ_BUFFER_SIZE 0x2002
178 #define HCI_LE_READ_LOCAL_SUPPORTED_FEATURES 0x2003
179 #define HCI_LE_SET_RANDOM_ADDR 0x2005
180 #define HCI_LE_SET_ADV_PARAM 0x2006
181 #define HCI_LE_READ_ADV_CHANNEL_TX_POWER 0x2007
182 #define HCI_LE_SET_ADV_DATA 0x2008
183 #define HCI_LE_SET_SCAN_RSP_DATA 0x2009
184 #define HCI_LE_SET_ADV_ENABLE 0x200A
185 #define HCI_LE_SET_SCAN_PARAM 0x200B
186 #define HCI_LE_SET_SCAN_ENABLE 0x200C
187 #define HCI_LE_CREATE_CONNECTION 0x200D
188 #define HCI_LE_CREATE_CONNECTION_CANCEL 0x200E
189 #define HCI_LE_READ_WHITE_LIST_SIZE 0x200F
190 #define HCI_LE_CLEAR_WHITE_LIST 0x2010
191 #define HCI_LE_ADD_WHITE_LIST 0x2011
192 #define HCI_LE_REMOVE_WHITE_LIST 0x2012
193 #define HCI_LE_CONNECTION_UPDATE 0x2013
194 #define HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION 0x2014
195 #define HCI_LE_READ_CHANNEL_MAP 0x2015
196 #define HCI_LE_READ_REMOTE_USED_FEATURES 0x2016
197 #define HCI_LE_ENCRYPT 0x2017
198 #define HCI_LE_RAND 0x2018
199 #define HCI_LE_START_ENCRYPTION 0x2019
200 #define HCI_LE_LTK_REQ_REPLY 0x201A
201 #define HCI_LE_LTK_REQ_NEG_REPLY 0x201B
202 #define HCI_LE_READ_SUPPORTED_STATES 0x201C
203 #define HCI_LE_RECEIVER_TEST 0x201D
204 #define HCI_LE_TRANSMITTER_TEST 0x201E
205 #define HCI_LE_TEST_END 0x201F
206 // V4.1
207 #define HCI_LE_REMOTE_CONN_PARAM_REQ_REPLY 0x2020
208 #define HCI_LE_REMOTE_CONN_PARAM_REQ_NEG_REPLY 0x2021
209 // V4.2
210 #define HCI_LE_SET_DATA_LENGTH 0x2022
211 #define HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH 0x2023
212 #define HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH 0x2024
213 #define HCI_LE_READ_LOCAL_P256_PUBLIC_KEY 0x2025
214 #define HCI_LE_GENERATE_DHKEY 0x2026
215 #define HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST 0x2027
216 #define HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST 0x2028
217 #define HCI_LE_CLEAR_RESOLVING_LIST 0x2029
218 #define HCI_LE_READ_RESOLVING_LIST_SIZE 0x202A
219 #define HCI_LE_READ_PEER_RESOLVABLE_ADDRESS 0x202B
220 #define HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS 0x202C
221 #define HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE 0x202D
222 #define HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT 0x202E
223 #define HCI_LE_READ_MAX_DATA_LENGTH 0x202F
224 
225 // V5.0
227 #define HCI_LE_READ_PHY 0x2030
228 #define HCI_LE_SET_DEFAULT_PHY 0x2031
229 #define HCI_LE_SET_PHY 0x2032
230 #define HCI_LE_ENHANCED_RECEIVER_TEST 0x2033
231 #define HCI_LE_ENHANCED_TRANSMITTER_TEST 0x2034
232 // LE Vendor Specific LL Extension Commands
234 #define HCI_EXT_SET_RX_GAIN 0xFC00
235 #define HCI_EXT_SET_TX_POWER 0xFC01
236 #define HCI_EXT_ONE_PKT_PER_EVT 0xFC02
237 #define HCI_EXT_CLK_DIVIDE_ON_HALT 0xFC03
239 #define HCI_EXT_DECLARE_NV_USAGE 0xFC04
240 #define HCI_EXT_DECRYPT 0xFC05
242 #define HCI_EXT_SET_LOCAL_SUPPORTED_FEATURES 0xFC06
243 #define HCI_EXT_SET_FAST_TX_RESP_TIME 0xFC07
244 #define HCI_EXT_MODEM_TEST_TX 0xFC08
245 #define HCI_EXT_MODEM_HOP_TEST_TX 0xFC09
246 #define HCI_EXT_MODEM_TEST_RX 0xFC0A
247 #define HCI_EXT_END_MODEM_TEST 0xFC0B
248 #define HCI_EXT_SET_BDADDR 0xFC0C
249 #define HCI_EXT_SET_SCA 0xFC0D
250 #define HCI_EXT_ENABLE_PTM 0xFC0E
251 #define HCI_EXT_SET_FREQ_TUNE 0xFC0F
252 #define HCI_EXT_SAVE_FREQ_TUNE 0xFC10
253 #define HCI_EXT_SET_MAX_DTM_TX_POWER 0xFC11
254 #define HCI_EXT_MAP_PM_IO_PORT 0xFC12
256 #define HCI_EXT_DISCONNECT_IMMED 0xFC13
258 #define HCI_EXT_PER 0xFC14
259 #define HCI_EXT_PER_BY_CHAN 0xFC15
260 #define HCI_EXT_EXTEND_RF_RANGE 0xFC16
262 #define HCI_EXT_ADV_EVENT_NOTICE 0xFC17
264 #define HCI_EXT_CONN_EVENT_NOTICE 0xFC18
265 #define HCI_EXT_HALT_DURING_RF 0xFC19
267 #define HCI_EXT_OVERRIDE_SL 0xFC1A
268 #define HCI_EXT_BUILD_REVISION 0xFC1B
270 #define HCI_EXT_DELAY_SLEEP 0xFC1C
272 #define HCI_EXT_RESET_SYSTEM 0xFC1D
274 #define HCI_EXT_OVERLAPPED_PROCESSING 0xFC1E
276 #define HCI_EXT_NUM_COMPLETED_PKTS_LIMIT 0xFC1F
278 #define HCI_EXT_GET_CONNECTION_INFO 0xFC20
279 #define HCI_EXT_SET_MAX_DATA_LENGTH 0xFC21
280 #define HCI_EXT_SCAN_EVENT_NOTICE 0xFC22
281 #define HCI_EXT_SCAN_REQ_REPORT 0xFC23
282 #define HCI_EXT_GET_ACTIVE_CONNECTION_INFO 0xFC24
283 
284 #define HCI_EXT_LL_TEST_MODE 0xFC70
286 
288 /*
289 ** HCI Event Codes
290 */
291 
292 // BT Events
293 #define HCI_DISCONNECTION_COMPLETE_EVENT_CODE 0x05
294 #define HCI_ENCRYPTION_CHANGE_EVENT_CODE 0x08
295 #define HCI_READ_REMOTE_INFO_COMPLETE_EVENT_CODE 0x0C
296 #define HCI_COMMAND_COMPLETE_EVENT_CODE 0x0E
297 #define HCI_COMMAND_STATUS_EVENT_CODE 0x0F
298 #define HCI_BLE_HARDWARE_ERROR_EVENT_CODE 0x10
299 #define HCI_NUM_OF_COMPLETED_PACKETS_EVENT_CODE 0x13
300 #define HCI_DATA_BUFFER_OVERFLOW_EVENT 0x1A
301 #define HCI_KEY_REFRESH_COMPLETE_EVENT_CODE 0x30
302 #define HCI_APTO_EXPIRED_EVENT_CODE 0x57
303 
304 // LE Event Code (for LE Meta Events)
305 #define HCI_LE_EVENT_CODE 0x3E
306 
307 // LE Meta Event Codes
308 #define HCI_BLE_CONNECTION_COMPLETE_EVENT 0x01
309 #define HCI_BLE_ADV_REPORT_EVENT 0x02
310 #define HCI_BLE_CONN_UPDATE_COMPLETE_EVENT 0x03
311 #define HCI_BLE_READ_REMOTE_FEATURE_COMPLETE_EVENT 0x04
312 #define HCI_BLE_LTK_REQUESTED_EVENT 0x05
313 // V4.1
314 #define HCI_BLE_REMOTE_CONN_PARAM_REQUEST_EVENT 0x06
315 // V4.2
316 #define HCI_BLE_DATA_LENGTH_CHANGE_EVENT 0x07
317 #define HCI_BLE_READ_LOCAL_P256_PUBLIC_KEY_COMPLETE_EVENT 0x08
318 #define HCI_BLE_GENERATE_DHKEY_COMPLETE_EVENT 0x09
319 #define HCI_BLE_ENHANCED_CONNECTION_COMPLETE_EVENT 0x0A
320 #define HCI_BLE_DIRECT_ADVERTISING_REPORT_EVENT 0x0B
321 // V5.0
322 #define HCI_BLE_PHY_UPDATE_COMPLETE_EVENT 0x0C
323 // VS Meta Event Codes - Texas Instruments Inc specific!
324 #define HCI_BLE_SCAN_REQ_REPORT_EVENT 0x80
325 
326 #define HCI_VE_EVENT_CODE 0xFF
327 
328 // LE Vendor Specific LL Extension Events
329 #define HCI_EXT_SET_RX_GAIN_EVENT 0x0400
330 #define HCI_EXT_SET_TX_POWER_EVENT 0x0401
331 #define HCI_EXT_ONE_PKT_PER_EVT_EVENT 0x0402
332 #define HCI_EXT_CLK_DIVIDE_ON_HALT_EVENT 0x0403
334 #define HCI_EXT_DECLARE_NV_USAGE_EVENT 0x0404
335 #define HCI_EXT_DECRYPT_EVENT 0x0405
337 #define HCI_EXT_SET_LOCAL_SUPPORTED_FEATURES_EVENT 0x0406
338 #define HCI_EXT_SET_FAST_TX_RESP_TIME_EVENT 0x0407
339 #define HCI_EXT_MODEM_TEST_TX_EVENT 0x0408
340 #define HCI_EXT_MODEM_HOP_TEST_TX_EVENT 0x0409
341 #define HCI_EXT_MODEM_TEST_RX_EVENT 0x040A
342 #define HCI_EXT_END_MODEM_TEST_EVENT 0x040B
343 #define HCI_EXT_SET_BDADDR_EVENT 0x040C
344 #define HCI_EXT_SET_SCA_EVENT 0x040D
345 #define HCI_EXT_ENABLE_PTM_EVENT 0x040E
346 #define HCI_EXT_SET_FREQ_TUNE_EVENT 0x040F
347 #define HCI_EXT_SAVE_FREQ_TUNE_EVENT 0x0410
348 #define HCI_EXT_SET_MAX_DTM_TX_POWER_EVENT 0x0411
349 #define HCI_EXT_MAP_PM_IO_PORT_EVENT 0x0412
351 #define HCI_EXT_DISCONNECT_IMMED_EVENT 0x0413
353 #define HCI_EXT_PER_EVENT 0x0414
354 #define HCI_EXT_PER_BY_CHAN_EVENT 0x0415
355 #define HCI_EXT_EXTEND_RF_RANGE_EVENT 0x0416
357 #define HCI_EXT_ADV_EVENT_NOTICE_EVENT 0x0417
359 #define HCI_EXT_CONN_EVENT_NOTICE_EVENT 0x0418
360 #define HCI_EXT_HALT_DURING_RF_EVENT 0x0419
362 #define HCI_EXT_OVERRIDE_SL_EVENT 0x041A
363 #define HCI_EXT_BUILD_REVISION_EVENT 0x041B
365 #define HCI_EXT_DELAY_SLEEP_EVENT 0x041C
367 #define HCI_EXT_RESET_SYSTEM_EVENT 0x041D
369 #define HCI_EXT_OVERLAPPED_PROCESSING_EVENT 0x041E
371 #define HCI_EXT_NUM_COMPLETED_PKTS_LIMIT_EVENT 0x041F
373 #define HCI_EXT_GET_CONNECTION_INFO_EVENT 0x0420
374 #define HCI_EXT_SET_MAX_DATA_LENGTH_EVENT 0x0421
375 #define HCI_EXT_SCAN_EVENT_NOTICE_EVENT 0x0422
376 #define HCI_EXT_SCAN_REQ_REPORT_EVENT 0x0423
377 #define HCI_EXT_GET_ACTIVE_CONNECTION_INFO_EVENT 0x0424
378 #define HCI_EXT_LL_TEST_MODE_EVENT 0x0470
380 
382  // end of HCI_Constants
384 
385 /*******************************************************************************
386  * TYPEDEFS
387  */
388 
389 /*******************************************************************************
390  * LOCAL VARIABLES
391  */
392 
393 /*******************************************************************************
394  * GLOBAL VARIABLES
395  */
396 
397 /*
398 ** HCI OSAL API
399 */
400 
402 
410 extern void HCI_Init( uint8 taskID );
411 
412 
421 extern void HCI_TL_getCmdResponderID( uint8 taskID );
422 
423 
434 extern uint16 HCI_ProcessEvent( uint8 task_id,
435  uint16 events );
436 
437 
439 
440 #ifdef __cplusplus
441 }
442 #endif
443 
444 #endif /* HCI_TL_H */
This API allows the software components in the Z-Stack to be written independently of the specifics o...
HCI layer interface.
Copyright 2017, Texas Instruments Incorporated