SimpleLink CC31xx/CC32xx Host Driver  Version 3.0.1.46
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_TICKS_IN_10_MILLISECONDS (_u32)(10)
55 #define SL_TIMESTAMP_MAX_VALUE (_u32)(0xFFFFFFFF)
56 
92 #define SL_MEMORY_MGMT_DYNAMIC
93 
94 #ifdef SL_MEMORY_MGMT_DYNAMIC
95 
96 
97 #include <stdlib.h>
104 #define sl_Malloc(Size) malloc(Size)
105 
112 #define sl_Free(pMem) free(pMem)
113 #endif
114 
115 
150 #ifdef SL_MEMORY_MGMT_DYNAMIC
151 #define MAX_CONCURRENT_ACTIONS 18
152 #else
153 #define MAX_CONCURRENT_ACTIONS 5
154 #endif
155 
156 
179 #define SL_MAX_ASYNC_BUFFERS MAX_CONCURRENT_ACTIONS
180 
190 /* #define CPU_FREQ_IN_MHZ 80 */
191 
192 
193 
204 #define SL_RUNTIME_EVENT_REGISTERATION
205 
206 
227 #define SL_INC_ARG_CHECK
228 
229 
243 #define SL_INC_EXT_API
244 
245 
259 #define SL_INC_WLAN_PKG
260 
261 
275 #define SL_INC_SOCKET_PKG
276 
277 
291 #define SL_INC_NET_APP_PKG
292 
293 
307 #define SL_INC_NET_CFG_PKG
308 
309 
323 #define SL_INC_NVMEM_PKG
324 
325 
339 #define SL_INC_NVMEM_EXT_PKG
340 
341 
355 #define SL_INC_SOCK_SERVER_SIDE_API
356 
357 
371 #define SL_INC_SOCK_CLIENT_SIDE_API
372 
373 
387 #define SL_INC_SOCK_RECV_API
388 
389 
403 #define SL_INC_SOCK_SEND_API
404 
405 
439 #define sl_DeviceEnablePreamble()
440 
441 
442 
451 #define sl_DeviceEnable() NwpPowerOn()
452 
453 
461 #define sl_DeviceDisable() NwpPowerOff()
462 
463 
493 #define _SlFd_t Fd_t
494 
495 
529 #define sl_IfOpen spi_Open
530 
531 
549 #define sl_IfClose spi_Close
550 
551 
576 #define sl_IfRead spi_Read
577 
578 
607 #define sl_IfWrite spi_Write
608 
609 
633 #define sl_IfRegIntHdlr(InterruptHdl , pValue) NwpRegisterInterruptHandler(InterruptHdl , pValue)
634 
635 
647 #define sl_IfMaskIntHdlr() NwpMaskInterrupt()
648 
649 
661 #define sl_IfUnMaskIntHdlr() NwpUnMaskInterrupt()
662 
663 
680 /* #define SL_START_WRITE_STAT */
681 
682 #ifdef SL_START_WRITE_STAT
683 #define sl_IfStartWriteSequence
684 #define sl_IfEndWriteSequence
685 #endif
686 
687 
706 #undef slcb_GetTimestamp
707 /* A timer must be started before using this function */
708 #define slcb_GetTimestamp TimerGetCurrentTimestamp
709 
710 
721 #define WAIT_NWP_SHUTDOWN_READY NwpWaitForShutDownInd()
722 
723 
761 /*
762 #define SL_PLATFORM_MULTI_THREADED
763 */
764 
765 #ifdef SL_PLATFORM_MULTI_THREADED
766 
773 #define SL_OS_RET_CODE_OK ((int)OS_OK)
774 
781 #define SL_OS_WAIT_FOREVER ((uint32_t)OS_WAIT_FOREVER)
782 
789 #define SL_OS_NO_WAIT ((uint32_t)OS_NO_WAIT)
790 
798 #define _SlTime_t uint32_t
799 
800 
801 
802 
816 #define _SlSyncObj_t sem_t
817 
818 
833 #define sl_SyncObjCreate(pSyncObj,pName) sem_init(pSyncObj, 0, 0)
834 
835 
846 #define sl_SyncObjDelete(pSyncObj) sem_destroy(pSyncObj)
847 
848 
861 #define sl_SyncObjSignal(pSyncObj) sem_post(pSyncObj)
862 
863 
876 #define sl_SyncObjSignalFromIRQ(pSyncObj) sem_post(pSyncObj)
877 
878 
895 #define sl_SyncObjWait(pSyncObj,Timeout) Semaphore_pend_handle(pSyncObj,Timeout)
896 
897 
907 #define sl_SyncObjGetCount(pSyncObj,pValue) sem_getvalue(pSyncObj, pValue);
908 
919 #define _SlLockObj_t pthread_mutex_t
920 
934 #define sl_LockObjCreate(pLockObj, pName) Mutex_create_handle(pLockObj)
935 
936 
947 #define sl_LockObjDelete(pLockObj) pthread_mutex_destroy(pLockObj)
948 
949 
969 #define sl_LockObjLock(pLockObj,Timeout) pthread_mutex_lock(pLockObj)
970 
971 
982 #define sl_LockObjUnlock(pLockObj) pthread_mutex_unlock(pLockObj)
983 
984 #else
985 
999 #define _SlSyncObj_t SemaphoreP_Handle
1000 
1001 
1016 #define sl_SyncObjCreate(pSyncObj,pName) SemaphoreP_create_handle(pSyncObj)
1017 
1018 
1029 #define sl_SyncObjDelete(pSyncObj) SemaphoreP_delete_handle(pSyncObj)
1030 
1031 
1044 #define sl_SyncObjSignal(pSyncObj) SemaphoreP_post_handle(pSyncObj)
1045 
1046 
1059 #define sl_SyncObjSignalFromIRQ(pSyncObj) SemaphoreP_post_handle(pSyncObj)
1060 
1061 
1077 #define sl_SyncObjWait(pSyncObj,Timeout) SemaphoreP_pend((*(pSyncObj)),Timeout)
1078 
1079 
1080 
1081 #define sl_SyncObjGetCount(pSyncObj,pValue)
1082 
1092 #define _SlLockObj_t MutexP_Handle
1093 
1107 #define sl_LockObjCreate(pLockObj, pName) Mutex_create_handle(pLockObj)
1108 
1109 
1120 #define sl_LockObjDelete(pLockObj) MutexP_delete_handle(pLockObj)
1121 
1122 
1142 #define sl_LockObjLock(pLockObj,Timeout) Mutex_lock(*(pLockObj))
1143 
1144 
1155 #define sl_LockObjUnlock(pLockObj) Mutex_unlock(*(pLockObj))
1156 
1157 #endif
1158 
1177 //#define SL_PLATFORM_EXTERNAL_SPAWN
1178 
1179 #ifdef SL_PLATFORM_EXTERNAL_SPAWN
1180 #define sl_Spawn(pEntry,pValue,flags) os_Spawn(pEntry,pValue,flags)
1181 #endif
1182 
1232 #define slcb_DeviceFatalErrorEvtHdlr SimpleLinkFatalErrorEventHandler
1233 
1244 #define slcb_DeviceGeneralEvtHdlr SimpleLinkGeneralEventHandler
1245 
1326 #define slcb_WlanEvtHdlr SimpleLinkWlanEventHandler
1327 
1328 
1362 #define slcb_NetAppEvtHdlr SimpleLinkNetAppEventHandler
1363 
1399 #define slcb_NetAppHttpServerHdlr SimpleLinkHttpServerEventHandler
1400 
1401 
1402 
1419 #define slcb_NetAppRequestHdlr SimpleLinkNetAppRequestEventHandler
1420 
1421 
1422 
1437 #define slcb_NetAppRequestMemFree SimpleLinkNetAppRequestMemFreeEventHandler
1438 
1439 
1440 
1465 #define slcb_SockEvtHdlr SimpleLinkSockEventHandler
1466 
1467 
1486 #ifndef SL_PLATFORM_MULTI_THREADED
1487 #define slcb_SocketTriggerEventHandler SimpleLinkSocketTriggerEventHandler
1488 #endif
1489 
1497 #ifdef __cplusplus
1498 }
1499 #endif // __cplusplus
1500 
1501 #endif // __USER_H__