SimpleLink CC31xx/CC32xx Host Driver  Version 3.0.1.55
Simplifies the implementation of Internet connectivity
user.h
1 /*
2  * user.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 * user.h - CC31xx/CC32xx Host Driver Implementation
39 ******************************************************************************/
40 
41 #ifndef __USER_H__
42 #define __USER_H__
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 
49 #include <string.h>
50 #include <ti/drivers/net/wifi/porting/cc_pal.h>
51 
52 typedef signed int _SlFd_t;
53 
54 #define SL_TIMESTAMP_MAX_VALUE (_u32)(0xFFFFFFFF)
55 
91 #define SL_MEMORY_MGMT_DYNAMIC
92 
93 #ifdef SL_MEMORY_MGMT_DYNAMIC
94 
95 
96 #include <stdlib.h>
103 #define sl_Malloc(Size) malloc(Size)
104 
111 #define sl_Free(pMem) free(pMem)
112 #endif
113 
114 
149 #ifdef SL_MEMORY_MGMT_DYNAMIC
150 #define MAX_CONCURRENT_ACTIONS 18
151 #else
152 #define MAX_CONCURRENT_ACTIONS 5
153 #endif
154 
155 
178 #define SL_MAX_ASYNC_BUFFERS MAX_CONCURRENT_ACTIONS
179 
189 /* #define CPU_FREQ_IN_MHZ 80 */
190 
191 
192 
203 #define SL_RUNTIME_EVENT_REGISTERATION
204 
205 
226 #define SL_INC_ARG_CHECK
227 
228 
242 #define SL_INC_EXT_API
243 
244 
258 #define SL_INC_WLAN_PKG
259 
260 
274 #define SL_INC_SOCKET_PKG
275 
276 
290 #define SL_INC_NET_APP_PKG
291 
292 
306 #define SL_INC_NET_CFG_PKG
307 
308 
322 #define SL_INC_NVMEM_PKG
323 
324 
338 #define SL_INC_NVMEM_EXT_PKG
339 
340 
354 #define SL_INC_SOCK_SERVER_SIDE_API
355 
356 
370 #define SL_INC_SOCK_CLIENT_SIDE_API
371 
372 
386 #define SL_INC_SOCK_RECV_API
387 
388 
402 #define SL_INC_SOCK_SEND_API
403 
404 
438 #define sl_DeviceEnablePreamble()
439 
440 
441 
450 #define sl_DeviceEnable() NwpPowerOn()
451 
452 
460 #define sl_DeviceDisable() NwpPowerOff()
461 
462 
492 #define _SlFd_t Fd_t
493 
494 
528 #define sl_IfOpen spi_Open
529 
530 
548 #define sl_IfClose spi_Close
549 
550 
575 #define sl_IfRead spi_Read
576 
577 
606 #define sl_IfWrite spi_Write
607 
608 
632 #define sl_IfRegIntHdlr(InterruptHdl , pValue) NwpRegisterInterruptHandler(InterruptHdl , pValue)
633 
634 
646 #define sl_IfMaskIntHdlr() NwpMaskInterrupt()
647 
648 
660 #define sl_IfUnMaskIntHdlr() NwpUnMaskInterrupt()
661 
662 
679 /* #define SL_START_WRITE_STAT */
680 
681 #ifdef SL_START_WRITE_STAT
682 #define sl_IfStartWriteSequence
683 #define sl_IfEndWriteSequence
684 #endif
685 
686 
705 #undef slcb_GetTimestamp
706 /* A timer must be started before using this function */
707 #define slcb_GetTimestamp TimerGetCurrentTimestamp
708 
709 
720 #define WAIT_NWP_SHUTDOWN_READY NwpWaitForShutDownInd()
721 
722 
760 /*
761 #define SL_PLATFORM_MULTI_THREADED
762 */
763 
764 #ifdef SL_PLATFORM_MULTI_THREADED
765 
772 #define SL_OS_RET_CODE_OK ((int)OS_OK)
773 
780 #define SL_OS_WAIT_FOREVER ((uint32_t)OS_WAIT_FOREVER)
781 
788 #define SL_OS_NO_WAIT ((uint32_t)OS_NO_WAIT)
789 
797 #define _SlTime_t uint32_t
798 
799 
800 
801 
815 #define _SlSyncObj_t sem_t
816 
817 
832 #define sl_SyncObjCreate(pSyncObj,pName) sem_init(pSyncObj, 0, 0)
833 
834 
845 #define sl_SyncObjDelete(pSyncObj) sem_destroy(pSyncObj)
846 
847 
860 #define sl_SyncObjSignal(pSyncObj) sem_post(pSyncObj)
861 
862 
875 #define sl_SyncObjSignalFromIRQ(pSyncObj) sem_post(pSyncObj)
876 
877 
894 #define sl_SyncObjWait(pSyncObj,Timeout) Semaphore_pend_handle(pSyncObj,Timeout)
895 
896 
906 #define sl_SyncObjGetCount(pSyncObj,pValue) sem_getvalue(pSyncObj, pValue);
907 
918 #define _SlLockObj_t pthread_mutex_t
919 
933 #define sl_LockObjCreate(pLockObj, pName) Mutex_create_handle(pLockObj)
934 
935 
946 #define sl_LockObjDelete(pLockObj) pthread_mutex_destroy(pLockObj)
947 
948 
968 #define sl_LockObjLock(pLockObj,Timeout) pthread_mutex_lock(pLockObj)
969 
970 
979 #define sl_GetThreadID() pthread_self()
980 
991 #define sl_LockObjUnlock(pLockObj) pthread_mutex_unlock(pLockObj)
992 
993 #else
994 
1008 #define _SlSyncObj_t SemaphoreP_Handle
1009 
1010 
1025 #define sl_SyncObjCreate(pSyncObj,pName) SemaphoreP_create_handle(pSyncObj)
1026 
1027 
1038 #define sl_SyncObjDelete(pSyncObj) SemaphoreP_delete_handle(pSyncObj)
1039 
1040 
1053 #define sl_SyncObjSignal(pSyncObj) SemaphoreP_post_handle(pSyncObj)
1054 
1055 
1068 #define sl_SyncObjSignalFromIRQ(pSyncObj) SemaphoreP_post_handle(pSyncObj)
1069 
1070 
1086 #define sl_SyncObjWait(pSyncObj,Timeout) SemaphoreP_pend((*(pSyncObj)),Timeout)
1087 
1088 
1089 
1090 #define sl_SyncObjGetCount(pSyncObj,pValue)
1091 
1101 #define _SlLockObj_t MutexP_Handle
1102 
1116 #define sl_LockObjCreate(pLockObj, pName) Mutex_create_handle(pLockObj)
1117 
1118 
1129 #define sl_LockObjDelete(pLockObj) MutexP_delete_handle(pLockObj)
1130 
1131 
1151 #define sl_LockObjLock(pLockObj,Timeout) Mutex_lock(*(pLockObj))
1152 
1153 
1164 #define sl_LockObjUnlock(pLockObj) Mutex_unlock(*(pLockObj))
1165 
1166 #endif
1167 
1186 //#define SL_PLATFORM_EXTERNAL_SPAWN
1187 
1188 #ifdef SL_PLATFORM_EXTERNAL_SPAWN
1189 #define sl_Spawn(pEntry,pValue,flags) os_Spawn(pEntry,pValue,flags)
1190 #endif
1191 
1192 
1193 
1201 #define SL_TIMESTAMP_TICKS_IN_10_MILLISECONDS (10000/ClockP_getSystemTickPeriod())
1202 
1251 #define slcb_DeviceFatalErrorEvtHdlr SimpleLinkFatalErrorEventHandler
1252 
1263 #define slcb_DeviceGeneralEvtHdlr SimpleLinkGeneralEventHandler
1264 
1345 #define slcb_WlanEvtHdlr SimpleLinkWlanEventHandler
1346 
1347 
1381 #define slcb_NetAppEvtHdlr SimpleLinkNetAppEventHandler
1382 
1418 #define slcb_NetAppHttpServerHdlr SimpleLinkHttpServerEventHandler
1419 
1420 
1421 
1438 #define slcb_NetAppRequestHdlr SimpleLinkNetAppRequestEventHandler
1439 
1440 
1441 
1456 #define slcb_NetAppRequestMemFree SimpleLinkNetAppRequestMemFreeEventHandler
1457 
1458 
1459 
1484 #define slcb_SockEvtHdlr SimpleLinkSockEventHandler
1485 
1486 
1505 #ifndef SL_PLATFORM_MULTI_THREADED
1506 #define slcb_SocketTriggerEventHandler SimpleLinkSocketTriggerEventHandler
1507 #endif
1508 
1516 #ifdef __cplusplus
1517 }
1518 #endif // __cplusplus
1519 
1520 #endif // __USER_H__