SimpleLink CC3120/CC3220 Host Driver  Version 2.0.1.22
Simplifies the implementation of Internet connectivity
device.h
1 /*
2  * device.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2017 Texas Instruments Incorporated - https://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 
38 
39 /*****************************************************************************/
40 /* Include files */
41 /*****************************************************************************/
42 #include <ti/drivers/net/wifi/simplelink.h>
43 
44 #ifndef __DEVICE_H__
45 #define __DEVICE_H__
46 
47 
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
66 /*****************************************************************************/
67 /* Macro declarations */
68 /*****************************************************************************/
69 /* Convert event id to event mask to be used in sl_DeviceEventMaskSet and sl_DeviceEventMaskGet */
70 #define SL_DEVICE_EVENT_BIT(EventId) (SL_WLAN_VAL_2_MASK(EventId,1) )
71 
72 
73 
74 typedef enum
75 {
76  SL_DEVICE_EVENT_FATAL_DEVICE_ABORT = 1,
77  SL_DEVICE_EVENT_FATAL_DRIVER_ABORT,
78  SL_DEVICE_EVENT_FATAL_SYNC_LOSS,
79  SL_DEVICE_EVENT_FATAL_NO_CMD_ACK,
80  SL_DEVICE_EVENT_FATAL_CMD_TIMEOUT,
81  SL_DEVICE_EVENT_RESET_REQUEST,
82  SL_DEVICE_EVENT_ERROR,
83  SL_DEVICE_EVENT_MAX
84 
85 } SlDeviceEventId_e;
86 
87 typedef struct
88 {
89  _i16 Status;
90  _u16 Caller;
92 
93 typedef enum
94 {
95  SL_DEVICE_SOURCE_OTHER,
96  SL_DEVICE_SOURCE_WLAN,
97  SL_DEVICE_SOURCE_NETCFG,
98  SL_DEVICE_SOURCE_NETAPP,
99  SL_DEVICE_SOURCE_SECURITY,
100 
101  SL_DEVICE_SOURCE_LAST = 0xFF /* last one */
102 }SlDeviceSource_e;
103 
104 typedef struct
105 {
106  SlDeviceSource_e Source;
107  _i16 Code;
109 
110 typedef union
111 {
112  SlDeviceEventResetRequest_t ResetRequest;
113  SlDeviceEventError_t Error;
115 
116 
117 
118 typedef enum
119 {
120  SL_DEVICE_RESET_REQUEST_CALLER_PROVISIONING,
121  SL_DEVICE_RESET_REQUEST_CALLER_PROVISIONING_EXTERNAL_CONFIGURATION,
122  SL_DEVICE_RESET_REQUEST_NUM_OF_CALLERS
123 }SlDeviceResetRequestCaller_e;
124 
125 typedef struct
126 {
127  _u32 Id;
128  SlDeviceEventData_u Data;
130 
134 void slcb_DeviceEvtHdlr(SlDeviceEvent_t* pEvent);
139 typedef struct
140 {
141  _u32 Code;
142  _u32 Value;
144 
145 
146 typedef struct
147 {
148  _u32 Code;
150 
151 
152 typedef union
153 {
154  SlDeviceFatalDeviceAssert_t DeviceAssert;
155  SlDeviceFatalNoCmdAck_t NoCmdAck;
156  SlDeviceFatalCmdTimeout_t CmdTimeout;
158 
159 
160 typedef struct
161 {
162  _u32 Id;
163  SlDeviceFatalData_u Data;
165 
166 
167 
168 /*
169  Declare the different IDs for sl_DeviceGet and sl_DeviceSet
170  */
171 #define SL_DEVICE_GENERAL (1)
172 #define SL_DEVICE_IOT (4)
173 #define SL_DEVICE_STATUS (2)
174 
175 /*
176  Declare the different Options for SL_DEVICE_GENERAL in sl_DeviceGet and sl_DeviceSet
177  */
178 #define SL_DEVICE_GENERAL_DATE_TIME (11)
179 #define SL_DEVICE_GENERAL_PERSISTENT (5)
180 #define SL_DEVICE_GENERAL_VERSION (12)
181 
182 /*
183  Declare the different Options for SL_DEVICE_IOT in sl_DeviceGet and sl_DeviceSet
184 */
185 #define SL_DEVICE_IOT_UDID (41)
186 
187 /* Events list to mask/unmask*/
188 #define SL_DEVICE_EVENT_CLASS_DEVICE (1)
189 #define SL_DEVICE_EVENT_CLASS_WLAN (2)
190 #define SL_DEVICE_EVENT_CLASS_BSD (3)
191 #define SL_DEVICE_EVENT_CLASS_NETAPP (4)
192 #define SL_DEVICE_EVENT_CLASS_NETCFG (5)
193 #define SL_DEVICE_EVENT_CLASS_FS (6)
194 #define SL_DEVICE_EVENT_CLASS_NETUTIL (7)
195 
196 
197 /****************** DEVICE CLASS status ****************/
198 #define SL_DEVICE_EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR (0x00000001L)
199 #define SL_DEVICE_STATUS_DEVICE_SMART_CONFIG_ACTIVE (0x80000000L)
200 
201 /****************** WLAN CLASS status ****************/
202 #define SL_DEVICE_EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE (0x00000001L)
203 #define SL_DEVICE_EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE (0x00000002L)
204 #define SL_DEVICE_EVENT_DROPPED_WLAN_STA_CONNECTED (0x00000004L)
205 #define SL_DEVICE_EVENT_DROPPED_WLAN_STA_DISCONNECTED (0x00000008L)
206 #define SL_DEVICE_EVENT_DROPPED_WLAN_P2P_DEV_FOUND (0x00000010L)
207 #define SL_DEVICE_EVENT_DROPPED_WLAN_CONNECTION_FAILED (0x00000020L)
208 #define SL_DEVICE_EVENT_DROPPED_WLAN_P2P_NEG_REQ_RECEIVED (0x00000040L)
209 #define SL_DEVICE_EVENT_DROPPED_WLAN_RX_FILTERS (0x00000080L)
210 #define SL_DEVICE_STATUS_WLAN_STA_CONNECTED (0x80000000L)
211 
212 /****************** NETAPP CLASS status ****************/
213 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED (0x00000001L)
214 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED_V6 (0x00000002L)
215 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_LEASED (0x00000004L)
216 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_RELEASED (0x00000008L)
217 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPV4_LOST (0x00000010L)
218 #define SL_DEVICE_EVENT_DROPPED_NETAPP_DHCP_ACQUIRE_TIMEOUT (0x00000020L)
219 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_COLLISION (0x00000040L)
220 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPV6_LOST (0x00000080L)
221 
222 /****************** BSD CLASS status ****************/
223 #define SL_DEVICE_EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE (0x00000001L)
224 
225 /****************** FS CLASS ****************/
226 
227 
228 
229 /*****************************************************************************/
230 /* Structure/Enum declarations */
231 /*****************************************************************************/
232 
233 #ifdef SL_IF_TYPE_UART
234 typedef struct
235 {
236  _u32 BaudRate;
237  _u8 FlowControlEnable;
238  _u8 CommPort;
240 #endif
241 
242 #ifdef SL_IF_TYPE_UART
243 
244 #define SL_DEVICE_BAUD_9600 (9600L)
245 #define SL_DEVICE_BAUD_14400 (14400L)
246 #define SL_DEVICE_BAUD_19200 (19200L)
247 #define SL_DEVICE_BAUD_38400 (38400L)
248 #define SL_DEVICE_BAUD_57600 (57600L)
249 #define SL_DEVICE_BAUD_115200 (115200L)
250 #define SL_DEVICE_BAUD_230400 (230400L)
251 #define SL_DEVICE_BAUD_460800 (460800L)
252 #define SL_DEVICE_BAUD_921600 (921600L)
253 
254 #endif
255 
256 typedef struct
257 {
258  _u32 ChipId;
259  _u8 FwVersion[4];
260  _u8 PhyVersion[4];
261  _u8 NwpVersion[4];
262  _u16 RomVersion;
263  _u16 Padding;
265 
266 
267 typedef struct
268 {
269  /* time */
270  _u32 tm_sec;
271  _u32 tm_min;
272  _u32 tm_hour;
273  /* date */
274  _u32 tm_day; /* 1-31 */
275  _u32 tm_mon; /* 1-12 */
276  _u32 tm_year; /* YYYY 4 digits */
277  _u32 tm_week_day; /* not required */
278  _u32 tm_year_day; /* not required */
279  _u32 reserved[3];
280 }SlDateTime_t;
281 
282 
283 /******************************************************************************/
284 /* Type declarations */
285 /******************************************************************************/
286 typedef struct
287 {
288  _u32 ChipId;
289  _u32 MoreData;
291 
292 typedef void (*P_INIT_CALLBACK)(_u32 Status, SlDeviceInitInfo_t *DeviceInitInfo);
293 
294 /*****************************************************************************/
295 /* Function prototypes */
296 /*****************************************************************************/
297 
369 #if _SL_INCLUDE_FUNC(sl_Start)
370 _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCallBack);
371 #endif
372 
401 #if _SL_INCLUDE_FUNC(sl_Stop)
402 _i16 sl_Stop(const _u16 Timeout);
403 #endif
404 
405 
455 #if _SL_INCLUDE_FUNC(sl_DeviceSet)
456 _i16 sl_DeviceSet(const _u8 DeviceSetId ,const _u8 Option,const _u16 ConfigLen,const _u8 *pValues);
457 #endif
458 
552 #if _SL_INCLUDE_FUNC(sl_DeviceGet)
553 _i16 sl_DeviceGet(const _u8 DeviceGetId, _u8 *pOption,_u16 *pConfigLen, _u8 *pValues);
554 #endif
555 
556 
625 #if _SL_INCLUDE_FUNC(sl_DeviceEventMaskSet)
626 _i16 sl_DeviceEventMaskSet(const _u8 EventClass ,const _u32 Mask);
627 #endif
628 
664 #if _SL_INCLUDE_FUNC(sl_DeviceEventMaskGet)
665 _i16 sl_DeviceEventMaskGet(const _u8 EventClass,_u32 *pMask);
666 #endif
667 
668 
689 #if _SL_INCLUDE_FUNC(sl_Task)
690 void* sl_Task(void* pEntry);
691 #endif
692 
693 
694 
695 
710 #ifdef SL_IF_TYPE_UART
711 #if _SL_INCLUDE_FUNC(sl_DeviceUartSetMode)
712 _i16 sl_DeviceUartSetMode(const SlDeviceUartIfParams_t* pUartParams);
713 #endif
714 #endif
715 
724 #ifdef __cplusplus
725 }
726 #endif /* __cplusplus */
727 
728 #endif /* __DEVICE_H__ */
729 
730 
_i16 sl_DeviceEventMaskSet(const _u8 EventClass, const _u32 Mask)
Set asynchronous event mask.
Definition: device.c:411
_i16 sl_DeviceGet(const _u8 DeviceGetId, _u8 *pOption, _u16 *pConfigLen, _u8 *pValues)
Internal function for getting device configurations.
Definition: device.c:490
void * sl_Task(void *pEntry)
The SimpleLink task entry.
Definition: device.c:109
_i16 sl_DeviceSet(const _u8 DeviceSetId, const _u8 Option, const _u16 ConfigLen, const _u8 *pValues)
Setting device configurations.
Definition: device.c:562
_i16 sl_Stop(const _u16 Timeout)
Stop the SimpleLink device.
Definition: device.c:283
_i16 sl_DeviceEventMaskGet(const _u8 EventClass, _u32 *pMask)
Get current event mask of the device.
Definition: device.c:449
_i16 sl_DeviceUartSetMode(const SlDeviceUartIfParams_t *pUartParams)
Setting the internal uart mode.
Definition: device.c:737
_i16 sl_Start(const void *pIfHdl, _i8 *pDevName, const P_INIT_CALLBACK pInitCallBack)
Start the SimpleLink device.
Definition: device.c:124