SimpleLink Host Driver  0.0.5.1
 All Data Structures Functions Variables Groups
device.h
1 /*
2  * device.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
5  *
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution.
18  *
19  * Neither the name of Texas Instruments Incorporated nor the names of
20  * its contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35 */
36 
37 #ifndef __DEVICE_H__
38 #define __DEVICE_H__
39 
40 #include "simplelink.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 typedef void (*P_INIT_CALLBACK)(unsigned long Status);
47 
48 
49 /*****************************************************************************
50 
51  API Prototypes
52 
53  *****************************************************************************/
54 
55 
63 #define SL_DEVICE_GENERAL_CONFIGURATION (1)
64 #define SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME (11)
65 #define SL_DEVICE_GENERAL_VERSION (12)
66 #define SL_DEVICE_STATUS (2)
67 
68 
69 
70 
101 #if _SL_INCLUDE_FUNC(sl_DevSet)
102 long sl_DevSet(unsigned char DeviceSetId ,unsigned char Option,unsigned char ConfigLen, unsigned char *pValues);
103 #endif
104 
105 
106 
107 
174 #if _SL_INCLUDE_FUNC(sl_DevGet)
175 long sl_DevGet(unsigned char DeviceGetId, unsigned char *pOption,unsigned char *pConfigLen, unsigned char *pValues);
176 #endif
177 
178 
179 
180 
181 
182 /*
183  Declare the different event group classifications
184  The SimpleLink device send asynchronous events. Each event has a group
185  classification according to its nature.
186 */
187 #define SL_EVENT_CLASS_GLOBAL (0)
188 #define SL_EVENT_CLASS_DEVICE (1)
189 #define SL_EVENT_CLASS_WLAN (2)
190 #define SL_EVENT_CLASS_BSD (3)
191 #define SL_EVENT_CLASS_NETAPP (4)
192 #define SL_EVENT_CLASS_NETCFG (5)
193 #define SL_EVENT_CLASS_NVMEM (6)
194 
195 
196 
197 /* SL_EVENT_CLASS_WLAN user events */
198 #define SL_WLAN_CONNECT_EVENT (1)
199 #define SL_WLAN_DISCONNECT_EVENT (2)
200 /* Smart Config events */
201 #define SL_WLAN_SMART_CONFIG_START_EVENT (3)
202 #define SL_WLAN_SMART_CONFIG_STOP_EVENT (4)
203 
204 #define SL_WLAN_STA_CONNECTED_EVENT (5)
205 #define SL_WLAN_STA_DISCONNECTED_EVENT (6)
206 
207 #define SL_WLAN_P2P_DEV_FOUND_EVENT (7)
208 #define SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT (8)
209 #define SL_WLAN_CONNECTION_FAILED_EVENT (9)
210 
211 /* SL_EVENT_CLASS_DEVICE user events */
212 #define SL_DEVICE_FATAL_ERROR_EVENT (1)
213 /* SL_EVENT_CLASS_BSD user events */
214 #define SL_SOCKET_TX_FAILED_EVENT (1)
215 #define SL_SOCKET_SSL_ACCEPT_EVENT (2)
216 /* SL_EVENT_CLASS_NETAPP user events */
217 #define SL_NETAPP_IPACQUIRED_EVENT (1)
218 #define SL_NETAPP_IPACQUIRED_V6_EVENT (2)
219 
220 /* Receive this error in case there are no resources to issue the command
221  If possible, increase the number of MAX_CUNCURENT_ACTIONS (result in memory increase)
222  If not, try again later */
223 #define SL_POOL_IS_EMPTY -2000
224 
225 /* Receive this error in case a given length for RX buffer was too small.
226  Receive payload was bigger than the given buffer size. therefore payload is cut according to receive size
227  Recommend to increase buffer size */
228 #define SL_ESMALLBUF -2001
229 
230 /* Receive this error in case zero length is supplied to a get API
231  Recommend to supply length according to requested information (view options defines for help) */
232 #define SL_EZEROLEN -2002
233 
234 /* User supplied invalid parameter */
235 #define SL_INVALPARAM -2003
236 
240 /****************** DEVICE CLASS ****************/
241 #define EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR 0x00000001L
242 #define STATUS_DEVICE_SMART_CONFIG_ACTIVE 0x80000000L
243 
244 /****************** WLAN CLASS ****************/
245 #define EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE 0x00000001L
246 #define EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE 0x00000002L
247 #define EVENT_DROPPED_WLAN_STA_CONNECTED 0x00000004L
248 #define EVENT_DROPPED_WLAN_STA_DISCONNECTED 0x00000008L
249 
250 #define STATUS_WLAN_STA_CONNECTED 0x80000000L
251 
252 /****************** NETAPP CLASS ****************/
253 #define EVENT_DROPPED_NETAPP_IPACQUIRED 0x00000001L
254 #define EVENT_DROPPED_NETAPP_IPACQUIRED_V6 0x00000002L
255 #define EVENT_DROPPED_NETAPP_IP_LEASED 0x00000004L
256 #define EVENT_DROPPED_NETAPP_IP_RELEASED 0x00000008L
257 
258 /****************** BSD CLASS ****************/
259 #define EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE 0x00000001L
260 
261 /****************** FS CLASS ****************/
262 
263 
264 #ifdef SL_IF_TYPE_UART
265 typedef struct
266 {
267  unsigned long BaudRate;
268  unsigned char FlowControlEnable;
269  unsigned char CommPort;
270 } SlUartIfParams_t;
271 #endif
272 
273 typedef struct
274 {
275  unsigned long ChipId;
276  unsigned long FwVersion[4];
277  unsigned char PhyVersion[4];
279 
280 typedef struct
281 {
282  _SlPartialVersion ChipFwAndPhyVersion;
283  unsigned long NwpVersion[4];
284  unsigned short RomVersion;
285  unsigned short Padding;
287 
288 typedef enum
289 {
290  SL_ERR_SENDER_HEALTH_MON,
291  SL_ERR_SENDER_CLI_UART,
292  SL_ERR_SENDER_SUPPLICANT,
293  SL_ERR_SENDER_NETWORK_STACK,
294 
295  SL_ERR_NUM_SENDER_LAST=0xFF
296 }SlErrorSender_e;
297 
298 
299 typedef struct
300 {
301  signed char status;
302  SlErrorSender_e sender;
304 
305 typedef union
306 {
307  sl_DeviceReport deviceEvent;
309 
310 
311 typedef struct
312 {
313  unsigned long Event;
314  SlDeviceEventData_u EventData;
316 
317 
318 typedef struct
319 {
320  /* time */
321  unsigned long sl_tm_sec;
322  unsigned long sl_tm_min;
323  unsigned long sl_tm_hour;
324  /* date */
325  unsigned long sl_tm_day; /* 1-31 */
326  unsigned long sl_tm_mon; /* 1-12 */
327  unsigned long sl_tm_year; /* YYYY 4 digits */
328  unsigned long sl_tm_week_day; /* not required */
329  unsigned long sl_tm_year_day; /* not required */
330  unsigned long reserved[3];
331 }SlDateTime_t;
332 
333 
334 
335 
383 #if _SL_INCLUDE_FUNC(sl_Start)
384 int sl_Start(const void* pIfHdl, char* pDevName, const P_INIT_CALLBACK pInitCallBack);
385 #endif
386 
415 #if _SL_INCLUDE_FUNC(sl_Stop)
416 int sl_Stop(unsigned short timeout);
417 #endif
418 
471 #if _SL_INCLUDE_FUNC(sl_EventMaskSet)
472 int sl_EventMaskSet(unsigned char EventClass , unsigned long Mask);
473 #endif
474 
510 #if _SL_INCLUDE_FUNC(sl_EventMaskGet)
511 int sl_EventMaskGet(unsigned char EventClass, unsigned long *pMask);
512 #endif
513 
514 
535 #if _SL_INCLUDE_FUNC(sl_Task)
536 void sl_Task();
537 #endif
538 
539 
556 #ifdef SL_IF_TYPE_UART
557 #if _SL_INCLUDE_FUNC(sl_UartSetMode)
558 int sl_UartSetMode(const SlUartIfParams_t* pUartParams);
559 #endif
560 #endif
561 
570 #ifdef __cplusplus
571 }
572 #endif /* __cplusplus */
573 
574 
575 #endif /* __DEVICE_H__ */
576 
int sl_Stop(unsigned short timeout)
Stop the SimpleLink device.
long sl_DevGet(unsigned char DeviceGetId, unsigned char *pOption, unsigned char *pConfigLen, unsigned char *pValues)
Internal function for getting device configurations.
long sl_DevSet(unsigned char DeviceSetId, unsigned char Option, unsigned char ConfigLen, unsigned char *pValues)
Internal function for setting device configurations.
Definition: device.h:311
int sl_EventMaskSet(unsigned char EventClass, unsigned long Mask)
Set asynchronous event mask.
Definition: device.h:273
int sl_Start(const void *pIfHdl, char *pDevName, const P_INIT_CALLBACK pInitCallBack)
Start the SimpleLink device.
int sl_EventMaskGet(unsigned char EventClass, unsigned long *pMask)
Get current event mask of the device.
Definition: device.h:318
Definition: device.h:305
Definition: device.h:280
Definition: device.h:299