SimpleLink CC3120/CC3220 Host Driver  Version 2.0.1.15
Simplifies the implementation of Internet connectivity
device.h
1 /*
2  * Copyright (C) 2016 Texas Instruments Incorporated
3  *
4  * All rights reserved. Property of Texas Instruments Incorporated.
5  * Restricted rights to use, duplicate or disclose this code are
6  * granted through contract.
7  *
8  * The program may not be used without the written permission of
9  * Texas Instruments Incorporated or against the terms and conditions
10  * stipulated in the agreement under which this program has been supplied,
11  * and under no circumstances can it be used with non-TI connectivity device.
12  *
13  */
14 
15 /*****************************************************************************/
16 /* Include files */
17 /*****************************************************************************/
18 #include <ti/drivers/net/wifi/simplelink.h>
19 
20 #ifndef __DEVICE_H__
21 #define __DEVICE_H__
22 
23 
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
42 /*****************************************************************************/
43 /* Macro declarations */
44 /*****************************************************************************/
45 /* Convert event id to event mask to be used in sl_DeviceEventMaskSet and sl_DeviceEventMaskGet */
46 #define SL_DEVICE_EVENT_BIT(EventId) (SL_WLAN_VAL_2_MASK(EventId,1) )
47 
48 
49 
50 typedef enum
51 {
52  SL_DEVICE_EVENT_FATAL_DEVICE_ABORT = 1,
53  SL_DEVICE_EVENT_FATAL_DRIVER_ABORT,
54  SL_DEVICE_EVENT_FATAL_SYNC_LOSS,
55  SL_DEVICE_EVENT_FATAL_NO_CMD_ACK,
56  SL_DEVICE_EVENT_FATAL_CMD_TIMEOUT,
57  SL_DEVICE_EVENT_RESET_REQUEST,
58  SL_DEVICE_EVENT_ERROR,
59  SL_DEVICE_EVENT_MAX
60 
61 } SlDeviceEventId_e;
62 
63 typedef struct
64 {
65  _i16 Status;
66  _u16 Caller;
68 
69 typedef enum
70 {
71  SL_DEVICE_SOURCE_OTHER,
72  SL_DEVICE_SOURCE_WLAN,
73  SL_DEVICE_SOURCE_NETCFG,
74  SL_DEVICE_SOURCE_NETAPP,
75  SL_DEVICE_SOURCE_SECURITY,
76 
77  SL_DEVICE_SOURCE_LAST = 0xFF /* last one */
78 }SlDeviceSource_e;
79 
80 typedef struct
81 {
82  SlDeviceSource_e Source;
83  _i16 Code;
85 
86 typedef union
87 {
88  SlDeviceEventResetRequest_t ResetRequest;
91 
92 
93 
94 typedef enum
95 {
96  SL_DEVICE_RESET_REQUEST_CALLER_PROVISIONING,
97  SL_DEVICE_RESET_REQUEST_CALLER_PROVISIONING_EXTERNAL_CONFIGURATION,
98  SL_DEVICE_RESET_REQUEST_NUM_OF_CALLERS
99 }SlDeviceResetRequestCaller_e;
100 
101 typedef struct
102 {
103  _u32 Id;
104  SlDeviceEventData_u Data;
106 
110 void slcb_DeviceEvtHdlr(SlDeviceEvent_t* pEvent);
115 typedef struct
116 {
117  _u32 Code;
118  _u32 Value;
120 
121 
122 typedef struct
123 {
124  _u32 Code;
126 
127 
128 typedef union
129 {
130  SlDeviceFatalDeviceAssert_t DeviceAssert;
131  SlDeviceFatalNoCmdAck_t NoCmdAck;
132  SlDeviceFatalCmdTimeout_t CmdTimeout;
134 
135 
136 typedef struct
137 {
138  _u32 Id;
139  SlDeviceFatalData_u Data;
141 
142 
143 
144 /*
145  Declare the different IDs for sl_DeviceGet and sl_DeviceSet
146  */
147 #define SL_DEVICE_GENERAL (1)
148 #define SL_DEVICE_IOT (4)
149 #define SL_DEVICE_STATUS (2)
150 
151 /*
152  Declare the different Options for SL_DEVICE_GENERAL in sl_DeviceGet and sl_DeviceSet
153  */
154 #define SL_DEVICE_GENERAL_DATE_TIME (11)
155 #define SL_DEVICE_GENERAL_PERSISTENT (5)
156 #define SL_DEVICE_GENERAL_VERSION (12)
157 
158 /*
159  Declare the different Options for SL_DEVICE_IOT in sl_DeviceGet and sl_DeviceSet
160 */
161 #define SL_DEVICE_IOT_UDID (41)
162 
163 
164 
165 
166 
167 
168 /* Events list to mask/unmask*/
169 #define SL_DEVICE_EVENT_CLASS_DEVICE (1)
170 #define SL_DEVICE_EVENT_CLASS_WLAN (2)
171 #define SL_DEVICE_EVENT_CLASS_BSD (3)
172 #define SL_DEVICE_EVENT_CLASS_NETAPP (4)
173 #define SL_DEVICE_EVENT_CLASS_NETCFG (5)
174 #define SL_DEVICE_EVENT_CLASS_FS (6)
175 #define SL_DEVICE_EVENT_CLASS_NETUTIL (7)
176 
177 
178 /****************** DEVICE CLASS status ****************/
179 #define SL_DEVICE_EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR (0x00000001L)
180 #define SL_DEVICE_STATUS_DEVICE_SMART_CONFIG_ACTIVE (0x80000000L)
181 
182 /****************** WLAN CLASS status ****************/
183 #define SL_DEVICE_EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE (0x00000001L)
184 #define SL_DEVICE_EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE (0x00000002L)
185 #define SL_DEVICE_EVENT_DROPPED_WLAN_STA_CONNECTED (0x00000004L)
186 #define SL_DEVICE_EVENT_DROPPED_WLAN_STA_DISCONNECTED (0x00000008L)
187 #define SL_DEVICE_EVENT_DROPPED_WLAN_P2P_DEV_FOUND (0x00000010L)
188 #define SL_DEVICE_EVENT_DROPPED_WLAN_CONNECTION_FAILED (0x00000020L)
189 #define SL_DEVICE_EVENT_DROPPED_WLAN_P2P_NEG_REQ_RECEIVED (0x00000040L)
190 #define SL_DEVICE_EVENT_DROPPED_WLAN_RX_FILTERS (0x00000080L)
191 #define SL_DEVICE_STATUS_WLAN_STA_CONNECTED (0x80000000L)
192 
193 /****************** NETAPP CLASS status ****************/
194 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED (0x00000001L)
195 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED_V6 (0x00000002L)
196 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_LEASED (0x00000004L)
197 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_RELEASED (0x00000008L)
198 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPV4_LOST (0x00000010L)
199 #define SL_DEVICE_EVENT_DROPPED_NETAPP_DHCP_ACQUIRE_TIMEOUT (0x00000020L)
200 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_COLLISION (0x00000040L)
201 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPV6_LOST (0x00000080L)
202 
203 /****************** BSD CLASS status ****************/
204 #define SL_DEVICE_EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE (0x00000001L)
205 
206 /****************** FS CLASS ****************/
207 
208 
209 
210 /*****************************************************************************/
211 /* Structure/Enum declarations */
212 /*****************************************************************************/
213 
214 #ifdef SL_IF_TYPE_UART
215 typedef struct
216 {
217  _u32 BaudRate;
218  _u8 FlowControlEnable;
219  _u8 CommPort;
221 #endif
222 
223 #ifdef SL_IF_TYPE_UART
224 
225 #define SL_DEVICE_BAUD_9600 (9600L)
226 #define SL_DEVICE_BAUD_14400 (14400L)
227 #define SL_DEVICE_BAUD_19200 (19200L)
228 #define SL_DEVICE_BAUD_38400 (38400L)
229 #define SL_DEVICE_BAUD_57600 (57600L)
230 #define SL_DEVICE_BAUD_115200 (115200L)
231 #define SL_DEVICE_BAUD_230400 (230400L)
232 #define SL_DEVICE_BAUD_460800 (460800L)
233 #define SL_DEVICE_BAUD_921600 (921600L)
234 
235 #endif
236 
237 typedef struct
238 {
239  _u32 ChipId;
240  _u8 FwVersion[4];
241  _u8 PhyVersion[4];
242  _u8 NwpVersion[4];
243  _u16 RomVersion;
244  _u16 Padding;
246 
247 
248 typedef struct
249 {
250  /* time */
251  _u32 tm_sec;
252  _u32 tm_min;
253  _u32 tm_hour;
254  /* date */
255  _u32 tm_day; /* 1-31 */
256  _u32 tm_mon; /* 1-12 */
257  _u32 tm_year; /* YYYY 4 digits */
258  _u32 tm_week_day; /* not required */
259  _u32 tm_year_day; /* not required */
260  _u32 reserved[3];
261 }SlDateTime_t;
262 
263 
264 /******************************************************************************/
265 /* Type declarations */
266 /******************************************************************************/
267 typedef struct
268 {
269  _u32 ChipId;
270  _u32 MoreData;
272 
273 typedef void (*P_INIT_CALLBACK)(_u32 Status, SlDeviceInitInfo_t *DeviceInitInfo);
274 
275 /*****************************************************************************/
276 /* Function prototypes */
277 /*****************************************************************************/
278 
350 #if _SL_INCLUDE_FUNC(sl_Start)
351 _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCallBack);
352 #endif
353 
382 #if _SL_INCLUDE_FUNC(sl_Stop)
383 _i16 sl_Stop(const _u16 Timeout);
384 #endif
385 
386 
436 #if _SL_INCLUDE_FUNC(sl_DeviceSet)
437 _i16 sl_DeviceSet(const _u8 DeviceSetId ,const _u8 Option,const _u16 ConfigLen,const _u8 *pValues);
438 #endif
439 
533 #if _SL_INCLUDE_FUNC(sl_DeviceGet)
534 _i16 sl_DeviceGet(const _u8 DeviceGetId, _u8 *pOption,_u16 *pConfigLen, _u8 *pValues);
535 #endif
536 
537 
606 #if _SL_INCLUDE_FUNC(sl_DeviceEventMaskSet)
607 _i16 sl_DeviceEventMaskSet(const _u8 EventClass ,const _u32 Mask);
608 #endif
609 
645 #if _SL_INCLUDE_FUNC(sl_DeviceEventMaskGet)
646 _i16 sl_DeviceEventMaskGet(const _u8 EventClass,_u32 *pMask);
647 #endif
648 
649 
670 #if _SL_INCLUDE_FUNC(sl_Task)
671 void* sl_Task(void* pEntry);
672 #endif
673 
674 
675 
676 
691 #ifdef SL_IF_TYPE_UART
692 #if _SL_INCLUDE_FUNC(sl_DeviceUartSetMode)
693 _i16 sl_DeviceUartSetMode(const SlDeviceUartIfParams_t* pUartParams);
694 #endif
695 #endif
696 
705 #ifdef __cplusplus
706 }
707 #endif /* __cplusplus */
708 
709 #endif /* __DEVICE_H__ */
710 
711 
_i16 sl_DeviceEventMaskSet(const _u8 EventClass, const _u32 Mask)
Set asynchronous event mask.
Definition: device.c:375
_i16 sl_DeviceGet(const _u8 DeviceGetId, _u8 *pOption, _u16 *pConfigLen, _u8 *pValues)
Internal function for getting device configurations.
Definition: device.c:454
void * sl_Task(void *pEntry)
The SimpleLink task entry.
Definition: device.c:87
_i16 sl_DeviceSet(const _u8 DeviceSetId, const _u8 Option, const _u16 ConfigLen, const _u8 *pValues)
Setting device configurations.
Definition: device.c:526
_i16 sl_Stop(const _u16 Timeout)
Stop the SimpleLink device.
Definition: device.c:261
_i16 sl_DeviceEventMaskGet(const _u8 EventClass, _u32 *pMask)
Get current event mask of the device.
Definition: device.c:413
_i16 sl_DeviceUartSetMode(const SlDeviceUartIfParams_t *pUartParams)
Setting the internal uart mode.
Definition: device.c:705
_i16 sl_Start(const void *pIfHdl, _i8 *pDevName, const P_INIT_CALLBACK pInitCallBack)
Start the SimpleLink device.
Definition: device.c:102