SimpleLink API Reference Manual  1.11
 All Data Structures Files Functions Variables Typedefs Macros Groups
hci.h
Go to the documentation of this file.
1 /*****************************************************************************
2 *
3 * hci.h - CC3000 Host Driver Implementation.
4 * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com/
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *****************************************************************************/
35 #ifndef __HCI_H__
36 #define __HCI_H__
37 
38 #include "cc3000_common.h"
39 
40 //*****************************************************************************
41 //
42 // If building with a C++ compiler, make all of the definitions in this header
43 // have a C binding.
44 //
45 //*****************************************************************************
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 
51 #define SPI_HEADER_SIZE (5)
52 #define SIMPLE_LINK_HCI_CMND_HEADER_SIZE (4)
53 #define HEADERS_SIZE_CMD (SPI_HEADER_SIZE + SIMPLE_LINK_HCI_CMND_HEADER_SIZE)
54 #define SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE (5)
55 #define SIMPLE_LINK_HCI_DATA_HEADER_SIZE (5)
56 #define SIMPLE_LINK_HCI_PATCH_HEADER_SIZE (2)
57 
58 
59 //*****************************************************************************
60 //
61 // Values that can be used as HCI Commands and HCI Packet header defines
62 //
63 //*****************************************************************************
64 #define HCI_TYPE_CMND 0x1
65 #define HCI_TYPE_DATA 0x2
66 #define HCI_TYPE_PATCH 0x3
67 #define HCI_TYPE_EVNT 0x4
68 
69 
70 #define HCI_EVENT_PATCHES_DRV_REQ (1)
71 #define HCI_EVENT_PATCHES_FW_REQ (2)
72 #define HCI_EVENT_PATCHES_BOOTLOAD_REQ (3)
73 
74 
75 #define HCI_CMND_WLAN_BASE (0x0000)
76 #define HCI_CMND_WLAN_CONNECT 0x0001
77 #define HCI_CMND_WLAN_DISCONNECT 0x0002
78 #define HCI_CMND_WLAN_IOCTL_SET_SCANPARAM 0x0003
79 #define HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY 0x0004
80 #define HCI_CMND_WLAN_IOCTL_ADD_PROFILE 0x0005
81 #define HCI_CMND_WLAN_IOCTL_DEL_PROFILE 0x0006
82 #define HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS 0x0007
83 #define HCI_CMND_EVENT_MASK 0x0008
84 #define HCI_CMND_WLAN_IOCTL_STATUSGET 0x0009
85 #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START 0x000A
86 #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP 0x000B
87 #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX 0x000C
88 #define HCI_CMND_WLAN_CONFIGURE_PATCH 0x000D
89 
90 
91 #define HCI_CMND_SOCKET_BASE 0x1000
92 #define HCI_CMND_SOCKET 0x1001
93 #define HCI_CMND_BIND 0x1002
94 #define HCI_CMND_RECV 0x1004
95 #define HCI_CMND_ACCEPT 0x1005
96 #define HCI_CMND_LISTEN 0x1006
97 #define HCI_CMND_CONNECT 0x1007
98 #define HCI_CMND_BSD_SELECT 0x1008
99 #define HCI_CMND_SETSOCKOPT 0x1009
100 #define HCI_CMND_GETSOCKOPT 0x100A
101 #define HCI_CMND_CLOSE_SOCKET 0x100B
102 #define HCI_CMND_RECVFROM 0x100D
103 #define HCI_CMND_GETHOSTNAME 0x1010
104 #define HCI_CMND_MDNS_ADVERTISE 0x1011
105 
106 
107 #define HCI_DATA_BASE 0x80
108 
109 #define HCI_CMND_SEND (0x01 + HCI_DATA_BASE)
110 #define HCI_CMND_SENDTO (0x03 + HCI_DATA_BASE)
111 #define HCI_DATA_BSD_RECVFROM (0x04 + HCI_DATA_BASE)
112 #define HCI_DATA_BSD_RECV (0x05 + HCI_DATA_BASE)
113 
114 
115 #define HCI_CMND_NVMEM_CBASE (0x0200)
116 
117 
118 #define HCI_CMND_NVMEM_CREATE_ENTRY (0x0203)
119 #define HCI_CMND_NVMEM_SWAP_ENTRY (0x0205)
120 #define HCI_CMND_NVMEM_READ (0x0201)
121 #define HCI_CMND_NVMEM_WRITE (0x0090)
122 #define HCI_CMND_NVMEM_WRITE_PATCH (0x0204)
123 #define HCI_CMND_READ_SP_VERSION (0x0207)
124 
125 #define HCI_CMND_READ_BUFFER_SIZE 0x400B
126 #define HCI_CMND_SIMPLE_LINK_START 0x4000
127 
128 #define HCI_CMND_NETAPP_BASE 0x2000
129 
130 #define HCI_NETAPP_DHCP (0x0001 + HCI_CMND_NETAPP_BASE)
131 #define HCI_NETAPP_PING_SEND (0x0002 + HCI_CMND_NETAPP_BASE)
132 #define HCI_NETAPP_PING_REPORT (0x0003 + HCI_CMND_NETAPP_BASE)
133 #define HCI_NETAPP_PING_STOP (0x0004 + HCI_CMND_NETAPP_BASE)
134 #define HCI_NETAPP_IPCONFIG (0x0005 + HCI_CMND_NETAPP_BASE)
135 #define HCI_NETAPP_ARP_FLUSH (0x0006 + HCI_CMND_NETAPP_BASE)
136 #define HCI_NETAPP_SET_DEBUG_LEVEL (0x0008 + HCI_CMND_NETAPP_BASE)
137 #define HCI_NETAPP_SET_TIMERS (0x0009 + HCI_CMND_NETAPP_BASE)
138 
139 
140 
141 
142 
143 
144 //*****************************************************************************
145 //
146 // Values that can be used as HCI Events defines
147 //
148 //*****************************************************************************
149 #define HCI_EVNT_WLAN_BASE 0x0000
150 #define HCI_EVNT_WLAN_CONNECT 0x0001
151 #define HCI_EVNT_WLAN_DISCONNECT \
152  0x0002
153 #define HCI_EVNT_WLAN_IOCTL_ADD_PROFILE \
154  0x0005
155 
156 
157 #define HCI_EVNT_SOCKET HCI_CMND_SOCKET
158 #define HCI_EVNT_BIND HCI_CMND_BIND
159 #define HCI_EVNT_RECV HCI_CMND_RECV
160 #define HCI_EVNT_ACCEPT HCI_CMND_ACCEPT
161 #define HCI_EVNT_LISTEN HCI_CMND_LISTEN
162 #define HCI_EVNT_CONNECT HCI_CMND_CONNECT
163 #define HCI_EVNT_SELECT HCI_CMND_BSD_SELECT
164 #define HCI_EVNT_CLOSE_SOCKET HCI_CMND_CLOSE_SOCKET
165 #define HCI_EVNT_RECVFROM HCI_CMND_RECVFROM
166 #define HCI_EVNT_SETSOCKOPT HCI_CMND_SETSOCKOPT
167 #define HCI_EVNT_GETSOCKOPT HCI_CMND_GETSOCKOPT
168 #define HCI_EVNT_BSD_GETHOSTBYNAME HCI_CMND_GETHOSTNAME
169 #define HCI_EVNT_MDNS_ADVERTISE HCI_CMND_MDNS_ADVERTISE
170 
171 #define HCI_EVNT_SEND 0x1003
172 #define HCI_EVNT_WRITE 0x100E
173 #define HCI_EVNT_SENDTO 0x100F
174 
175 #define HCI_EVNT_PATCHES_REQ 0x1000
176 
177 #define HCI_EVNT_UNSOL_BASE 0x4000
178 
179 #define HCI_EVNT_WLAN_UNSOL_BASE (0x8000)
180 
181 #define HCI_EVNT_WLAN_UNSOL_CONNECT (0x0001 + HCI_EVNT_WLAN_UNSOL_BASE)
182 #define HCI_EVNT_WLAN_UNSOL_DISCONNECT (0x0002 + HCI_EVNT_WLAN_UNSOL_BASE)
183 #define HCI_EVNT_WLAN_UNSOL_INIT (0x0004 + HCI_EVNT_WLAN_UNSOL_BASE)
184 #define HCI_EVNT_WLAN_TX_COMPLETE (0x0008 + HCI_EVNT_WLAN_UNSOL_BASE)
185 #define HCI_EVNT_WLAN_UNSOL_DHCP (0x0010 + HCI_EVNT_WLAN_UNSOL_BASE)
186 #define HCI_EVNT_WLAN_ASYNC_PING_REPORT (0x0040 + HCI_EVNT_WLAN_UNSOL_BASE)
187 #define HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE (0x0080 + HCI_EVNT_WLAN_UNSOL_BASE)
188 #define HCI_EVNT_WLAN_KEEPALIVE (0x0200 + HCI_EVNT_WLAN_UNSOL_BASE)
189 #define HCI_EVNT_BSD_TCP_CLOSE_WAIT (0x0800 + HCI_EVNT_WLAN_UNSOL_BASE)
190 
191 #define HCI_EVNT_DATA_UNSOL_FREE_BUFF \
192  0x4100
193 
194 #define HCI_EVNT_NVMEM_CREATE_ENTRY \
195  HCI_CMND_NVMEM_CREATE_ENTRY
196 #define HCI_EVNT_NVMEM_SWAP_ENTRY HCI_CMND_NVMEM_SWAP_ENTRY
197 
198 #define HCI_EVNT_NVMEM_READ HCI_CMND_NVMEM_READ
199 #define HCI_EVNT_NVMEM_WRITE (0x0202)
200 
201 #define HCI_EVNT_READ_SP_VERSION \
202  HCI_CMND_READ_SP_VERSION
203 
204 #define HCI_EVNT_INPROGRESS 0xFFFF
205 
206 
207 #define HCI_DATA_RECVFROM 0x84
208 #define HCI_DATA_RECV 0x85
209 #define HCI_DATA_NVMEM 0x91
210 
211 #define HCI_EVENT_CC3000_CAN_SHUT_DOWN 0x99
212 
213 //*****************************************************************************
214 //
215 // Prototypes for the structures for APIs.
216 //
217 //*****************************************************************************
218 
219 #define HCI_DATA_HEADER_SIZE (5)
220 #define HCI_EVENT_HEADER_SIZE (5)
221 #define HCI_DATA_CMD_HEADER_SIZE (5)
222 #define HCI_PATCH_HEADER_SIZE (6)
223 
224 #define HCI_PACKET_TYPE_OFFSET (0)
225 #define HCI_PACKET_ARGSIZE_OFFSET (2)
226 #define HCI_PACKET_LENGTH_OFFSET (3)
227 
228 
229 #define HCI_EVENT_OPCODE_OFFSET (1)
230 #define HCI_EVENT_LENGTH_OFFSET (3)
231 #define HCI_EVENT_STATUS_OFFSET (4)
232 #define HCI_DATA_LENGTH_OFFSET (3)
233 
234 
235 
236 
237 //*****************************************************************************
238 //
239 // Prototypes for the APIs.
240 //
241 //*****************************************************************************
242 
243 //*****************************************************************************
244 //
254 //
255 //*****************************************************************************
256 extern unsigned short hci_command_send(unsigned short usOpcode,
257  unsigned char *ucArgs,
258  unsigned char ucArgsLength);
259 
260 
261 //*****************************************************************************
262 //
274 //
275 //*****************************************************************************
276 extern long hci_data_send(unsigned char ucOpcode,
277  unsigned char *ucArgs,
278  unsigned short usArgsLength,
279  unsigned short usDataLength,
280  const unsigned char *ucTail,
281  unsigned short usTailLength);
282 
283 
284 //*****************************************************************************
285 //
296 //
297 //*****************************************************************************
298 extern void hci_data_command_send(unsigned short usOpcode, unsigned char *pucBuff,
299  unsigned char ucArgsLength, unsigned short ucDataLength);
300 
301 //*****************************************************************************
302 //
313 //
314 //*****************************************************************************
315 extern void hci_patch_send(unsigned char ucOpcode, unsigned char *pucBuff, char *patch, unsigned short usDataLength);
316 
317 
318 
319 //*****************************************************************************
320 //
321 // Mark the end of the C bindings section for C++ compilers.
322 //
323 //*****************************************************************************
324 #ifdef __cplusplus
325 }
326 #endif // __cplusplus
327 
328 #endif // __HCI_H__