SimpleLink CC31xx/CC32xx Host Driver  Version 3.0.1.46
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 - 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 
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 #define SL_DEVICE_FIPS (6)
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 #define SL_DEVICE_FIPS_ZEROIZATION (20)
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 /****************** SYSCONFIG ****************/
197 #define SL_DEVICE_SYSCONFIG_AS_CONFIGURED (99)
198 
199 /****************** DEVICE CLASS status ****************/
200 #define SL_DEVICE_EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR (0x00000001L)
201 #define SL_DEVICE_STATUS_DEVICE_SMART_CONFIG_ACTIVE (0x80000000L)
202 
203 /****************** WLAN CLASS status ****************/
204 #define SL_DEVICE_EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE (0x00000001L)
205 #define SL_DEVICE_EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE (0x00000002L)
206 #define SL_DEVICE_EVENT_DROPPED_WLAN_STA_CONNECTED (0x00000004L)
207 #define SL_DEVICE_EVENT_DROPPED_WLAN_STA_DISCONNECTED (0x00000008L)
208 #define SL_DEVICE_EVENT_DROPPED_WLAN_P2P_DEV_FOUND (0x00000010L)
209 #define SL_DEVICE_EVENT_DROPPED_WLAN_CONNECTION_FAILED (0x00000020L)
210 #define SL_DEVICE_EVENT_DROPPED_WLAN_P2P_NEG_REQ_RECEIVED (0x00000040L)
211 #define SL_DEVICE_EVENT_DROPPED_WLAN_RX_FILTERS (0x00000080L)
212 
213 /****************** NETAPP CLASS status ****************/
214 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED (0x00000001L)
215 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPACQUIRED_V6 (0x00000002L)
216 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_LEASED (0x00000004L)
217 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_RELEASED (0x00000008L)
218 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPV4_LOST (0x00000010L)
219 #define SL_DEVICE_EVENT_DROPPED_NETAPP_DHCP_ACQUIRE_TIMEOUT (0x00000020L)
220 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IP_COLLISION (0x00000040L)
221 #define SL_DEVICE_EVENT_DROPPED_NETAPP_IPV6_LOST (0x00000080L)
222 
223 /****************** BSD CLASS status ****************/
224 #define SL_DEVICE_EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE (0x00000001L)
225 
226 /****************** FS CLASS ****************/
227 
228 
229 
230 /*****************************************************************************/
231 /* Structure/Enum declarations */
232 /*****************************************************************************/
233 
234 #ifdef SL_IF_TYPE_UART
235 typedef struct
236 {
237  _u32 BaudRate;
238  _u8 FlowControlEnable;
239  _u8 CommPort;
241 #endif
242 
243 #ifdef SL_IF_TYPE_UART
244 
245 #define SL_DEVICE_BAUD_9600 (9600L)
246 #define SL_DEVICE_BAUD_14400 (14400L)
247 #define SL_DEVICE_BAUD_19200 (19200L)
248 #define SL_DEVICE_BAUD_38400 (38400L)
249 #define SL_DEVICE_BAUD_57600 (57600L)
250 #define SL_DEVICE_BAUD_115200 (115200L)
251 #define SL_DEVICE_BAUD_230400 (230400L)
252 #define SL_DEVICE_BAUD_460800 (460800L)
253 #define SL_DEVICE_BAUD_921600 (921600L)
254 
255 #endif
256 
257 typedef struct
258 {
259  _u32 ChipId;
260  _u8 FwVersion[4];
261  _u8 PhyVersion[4];
262  _u8 NwpVersion[4];
263  _u16 RomVersion;
264  _u16 Padding;
266 
267 
268 typedef struct
269 {
270  /* time */
271  _u32 tm_sec;
272  _u32 tm_min;
273  _u32 tm_hour;
274  /* date */
275  _u32 tm_day; /* 1-31 */
276  _u32 tm_mon; /* 1-12 */
277  _u32 tm_year; /* YYYY 4 digits */
278  _u32 tm_week_day; /* not required */
279  _u32 tm_year_day; /* not required */
280  _u32 reserved[3];
281 }SlDateTime_t;
282 
283 
284 
285 
286 /******************************************************************************/
287 /* Type declarations */
288 /******************************************************************************/
289 typedef struct
290 {
291  _u32 ChipId;
292  _u32 MoreData;
294 
295 typedef void (*P_INIT_CALLBACK)(_u32 Status, SlDeviceInitInfo_t *DeviceInitInfo);
296 
297 /*****************************************************************************/
298 /* Function prototypes */
299 /*****************************************************************************/
300 
374 #if _SL_INCLUDE_FUNC(sl_Start)
375 _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCallBack);
376 #endif
377 
406 #if _SL_INCLUDE_FUNC(sl_Stop)
407 _i16 sl_Stop(const _u16 Timeout);
408 #endif
409 
410 
461 #if _SL_INCLUDE_FUNC(sl_DeviceSet)
462 _i16 sl_DeviceSet(const _u8 DeviceSetId ,const _u8 Option,const _u16 ConfigLen,const _u8 *pValues);
463 #endif
464 
558 #if _SL_INCLUDE_FUNC(sl_DeviceGet)
559 _i16 sl_DeviceGet(const _u8 DeviceGetId, _u8 *pOption,_u16 *pConfigLen, _u8 *pValues);
560 #endif
561 
562 
631 #if _SL_INCLUDE_FUNC(sl_DeviceEventMaskSet)
632 _i16 sl_DeviceEventMaskSet(const _u8 EventClass ,const _u32 Mask);
633 #endif
634 
670 #if _SL_INCLUDE_FUNC(sl_DeviceEventMaskGet)
671 _i16 sl_DeviceEventMaskGet(const _u8 EventClass,_u32 *pMask);
672 #endif
673 
674 
695 #if _SL_INCLUDE_FUNC(sl_Task)
696 void* sl_Task(void* pEntry);
697 #endif
698 
699 
700 
701 
717 #ifdef SL_IF_TYPE_UART
718 #if _SL_INCLUDE_FUNC(sl_DeviceUartSetMode)
719 _i16 sl_DeviceUartSetMode(const SlDeviceUartIfParams_t* pUartParams);
720 #endif
721 #endif
722 
746 _i32 sl_WifiConfig();
747 
756 #ifdef __cplusplus
757 }
758 #endif /* __cplusplus */
759 
760 #endif /* __DEVICE_H__ */
761 
762 
_i16 sl_DeviceEventMaskSet(const _u8 EventClass, const _u32 Mask)
Set asynchronous event mask.
Definition: device.c:399
_i16 sl_DeviceGet(const _u8 DeviceGetId, _u8 *pOption, _u16 *pConfigLen, _u8 *pValues)
Internal function for getting device configurations.
Definition: device.c:478
void * sl_Task(void *pEntry)
The SimpleLink task entry.
Definition: device.c:105
_i16 sl_DeviceSet(const _u8 DeviceSetId, const _u8 Option, const _u16 ConfigLen, const _u8 *pValues)
Setting device configurations.
Definition: device.c:550
_i16 sl_Stop(const _u16 Timeout)
Stop the SimpleLink device.
Definition: device.c:273
_i32 sl_WifiConfig()
Configure SimpleLink to default state.
Definition: wlanconfig.c:46
_i16 sl_DeviceEventMaskGet(const _u8 EventClass, _u32 *pMask)
Get current event mask of the device.
Definition: device.c:437
_i16 sl_DeviceUartSetMode(const SlDeviceUartIfParams_t *pUartParams)
Setting the internal uart mode.
Definition: device.c:721
_i16 sl_Start(const void *pIfHdl, _i8 *pDevName, const P_INIT_CALLBACK pInitCallBack)
Start the SimpleLink device.
Definition: device.c:119