SimpleLink CC31xx/CC32xx Host Driver
Version 3.0.1.39
Simplifies the implementation of Internet connectivity
trace.h
1
/*
2
* trace.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
#include <ti/drivers/net/wifi/simplelink.h>
40
41
#ifndef __SIMPLELINK_TRACE_H__
42
#define __SIMPLELINK_TRACE_H__
43
44
45
#ifdef __cplusplus
46
extern
"C"
{
47
#endif
48
49
/*****************************************************************************/
50
/* Macro declarations */
51
/*****************************************************************************/
52
53
#define SL_SYNC_SCAN_THRESHOLD (( _u32 )2000)
54
55
#ifdef SL_TINY
56
#define _SlDrvAssert(line ) { while(1); }
57
#else
58
#define _SlDrvAssert() _SlDrvHandleFatalError(SL_DEVICE_EVENT_FATAL_DRIVER_ABORT, 0, 0)
59
#endif
60
61
#define _SL_ASSERT(expr) {if(!(expr)){ _SlDrvAssert();}}
62
#define _SL_ERROR(expr, error) {if(!(expr)){return (error);}}
63
64
#define _SL_ASSERT_ERROR(expr, error) {if(!(expr)){_SlDrvAssert(); return (error);}}
65
66
#define SL_HANDLING_ASSERT 2
67
#define SL_HANDLING_ERROR 1
68
#define SL_HANDLING_NONE 0
69
70
#ifndef SL_TINY
71
#define SL_SELF_COND_HANDLING SL_HANDLING_ASSERT
72
#define SL_PROTOCOL_HANDLING SL_HANDLING_ASSERT
73
#define SL_DRV_RET_CODE_HANDLING SL_HANDLING_ERROR
74
#define SL_NWP_IF_HANDLING SL_HANDLING_ASSERT
75
#define SL_OSI_RET_OK_HANDLING SL_HANDLING_ERROR
76
#define SL_MALLOC_OK_HANDLING SL_HANDLING_ASSERT
77
#define SL_USER_ARGS_HANDLING SL_HANDLING_ASSERT
78
#define SL_ERR_IN_PROGRESS_HANDLING SL_HANDLING_ERROR
79
#define SL_ERR_IN_API_ALLOWED SL_HANDLING_ERROR
80
#else
81
#define SL_SELF_COND_HANDLING SL_HANDLING_NONE
82
#define SL_PROTOCOL_HANDLING SL_HANDLING_NONE
83
#define SL_DRV_RET_CODE_HANDLING SL_HANDLING_NONE
84
#define SL_NWP_IF_HANDLING SL_HANDLING_NONE
85
#define SL_OSI_RET_OK_HANDLING SL_HANDLING_NONE
86
#define SL_MALLOC_OK_HANDLING SL_HANDLING_NONE
87
#define SL_USER_ARGS_HANDLING SL_HANDLING_NONE
88
#define SL_ERR_IN_PROGRESS_HANDLING SL_HANDLING_NONE
89
#define SL_ERR_IN_API_ALLOWED SL_HANDLING_NONE
90
#endif
91
92
93
#if (SL_ERR_IN_PROGRESS_HANDLING == SL_HANDLING_ERROR)
94
#define VERIFY_NO_ERROR_HANDLING_IN_PROGRESS() { \
95
if (SL_IS_RESTART_REQUIRED) return SL_API_ABORTED; }
96
#else
97
#define VERIFY_NO_ERROR_HANDLING_IN_PROGRESS()
98
#endif
99
100
#if (SL_ERR_IN_API_ALLOWED == SL_HANDLING_ERROR)
101
#define VERIFY_API_ALLOWED(Silo) { \
102
_SlReturnVal_t status = _SlDrvDriverIsApiAllowed(Silo); \
103
if ( status ) return status; }
104
#else
105
#define VERIFY_API_ALLOWED(Silo)
106
#endif
107
108
#if (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ASSERT)
109
#define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
110
#elif (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ERROR)
111
#define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return (_SlReturnVal_t)_RetVal;}
112
#else
113
#define VERIFY_RET_OK(Func) (Func);
114
#endif
115
116
#if (SL_PROTOCOL_HANDLING == SL_HANDLING_ASSERT)
117
#define VERIFY_PROTOCOL(expr) _SL_ASSERT(expr)
118
#elif (SL_PROTOCOL_HANDLING == SL_HANDLING_ERROR)
119
#define VERIFY_PROTOCOL(expr) _SL_ERROR(expr, SL_RET_CODE_PROTOCOL_ERROR)
120
#else
121
#define VERIFY_PROTOCOL(expr)
122
#endif
123
124
#if (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ASSERT))
125
#define VERIFY_SOCKET_CB(expr) _SL_ASSERT(expr)
126
#elif (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ERROR))
127
#define VERIFY_SOCKET_CB(expr) _SL_ERROR(expr, SL_RET_CODE_SELF_ERROR)
128
#else
129
#define VERIFY_SOCKET_CB(expr)
130
#endif
131
132
#if (SL_NWP_IF_HANDLING == SL_HANDLING_ASSERT)
133
#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (_i16)(len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
134
#define NWP_IF_READ_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (_i16)(len); RetSize = sl_IfRead((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
135
#elif (SL_NWP_IF_HANDLING == SL_HANDLING_ERROR)
136
#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfWrite((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
137
#define NWP_IF_READ_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfRead((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
138
#else
139
#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { sl_IfWrite((fd),(pBuff),(len));}
140
#define NWP_IF_READ_CHECK(fd,pBuff,len) { sl_IfRead((fd),(pBuff),(len));}
141
#endif
142
143
#if (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ASSERT)
144
#define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
145
#elif (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ERROR)
146
#define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;}
147
#else
148
#define OSI_RET_OK_CHECK(Func) (Func);
149
#endif
150
151
#if (SL_MALLOC_OK_HANDLING == SL_HANDLING_ASSERT)
152
#define MALLOC_OK_CHECK(Ptr) _SL_ASSERT(NULL != Ptr)
153
#elif (SL_MALLOC_OK_HANDLING == SL_HANDLING_ERROR)
154
#define MALLOC_OK_CHECK(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_MALLOC_ERROR)
155
#else
156
#define MALLOC_OK_CHECK(Ptr)
157
#endif
158
159
#ifdef SL_INC_ARG_CHECK
160
161
#if (SL_USER_ARGS_HANDLING == SL_HANDLING_ASSERT)
162
#define ARG_CHECK_PTR(Ptr) _SL_ASSERT(NULL != Ptr)
163
#elif (SL_USER_ARGS_HANDLING == SL_HANDLING_ERROR)
164
#define ARG_CHECK_PTR(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_INVALID_INPUT)
165
#else
166
#define ARG_CHECK_PTR(Ptr)
167
#endif
168
169
#else
170
#define ARG_CHECK_PTR(Ptr)
171
#endif
172
173
/*#define SL_DBG_TRACE_ENABLE*/
174
#ifdef SL_DBG_TRACE_ENABLE
175
#define SL_TRACE0(level,msg_id,str) printf(str)
176
#define SL_TRACE1(level,msg_id,str,p1) printf(str,(p1))
177
#define SL_TRACE2(level,msg_id,str,p1,p2) printf(str,(p1),(p2))
178
#define SL_TRACE3(level,msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3))
179
#define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4))
180
#define SL_ERROR_TRACE(msg_id,str) printf(str)
181
#define SL_ERROR_TRACE1(msg_id,str,p1) printf(str,(p1))
182
#define SL_ERROR_TRACE2(msg_id,str,p1,p2) printf(str,(p1),(p2))
183
#define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3))
184
#define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4))
185
#define SL_TRACE_FLUSH()
186
#else
187
#define SL_TRACE0(level,msg_id,str)
188
#define SL_TRACE1(level,msg_id,str,p1)
189
#define SL_TRACE2(level,msg_id,str,p1,p2)
190
#define SL_TRACE3(level,msg_id,str,p1,p2,p3)
191
#define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4)
192
#define SL_ERROR_TRACE(msg_id,str)
193
#define SL_ERROR_TRACE1(msg_id,str,p1)
194
#define SL_ERROR_TRACE2(msg_id,str,p1,p2)
195
#define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3)
196
#define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4)
197
#define SL_TRACE_FLUSH()
198
#endif
199
200
/* #define SL_DBG_CNT_ENABLE */
201
#ifdef SL_DBG_CNT_ENABLE
202
#define _SL_DBG_CNT_INC(Cnt) g_DbgCnt. ## Cnt++
203
#define _SL_DBG_SYNC_LOG(index,value) {if(index < SL_DBG_SYNC_LOG_SIZE){*(_u32 *)&g_DbgCnt.SyncLog[index] = *(_u32 *)(value);}}
204
205
#else
206
#define _SL_DBG_CNT_INC(Cnt)
207
#define _SL_DBG_SYNC_LOG(index,value)
208
#endif
209
210
#define SL_DBG_LEVEL_1 1
211
#define SL_DBG_LEVEL_2 2
212
#define SL_DBG_LEVEL_3 4
213
#define SL_DBG_LEVEL_MASK (SL_DBG_LEVEL_2|SL_DBG_LEVEL_3)
214
215
#define SL_INCLUDE_DBG_FUNC(Name) ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK)
216
217
#define _SlDrvPrintStat_DBG_LEVEL SL_DBG_LEVEL_3
218
#define _SlDrvOtherFunc_DBG_LEVEL SL_DBG_LEVEL_1
219
220
#ifdef __cplusplus
221
}
222
#endif
223
224
225
#endif
/*__SIMPLELINK_TRACE_H__*/
226
source
ti
drivers
net
wifi
trace.h
Generated by
1.8.12