David Fletcher
/
cc3100_test
TI's CC3100 host driver and demo. Experimental and a work in progress.
Embed:
(wiki syntax)
Show/hide line numbers
cc3100_trace.h
00001 /* 00002 * trace.h - CC31xx/CC32xx Host Driver Implementation 00003 * 00004 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 00005 * 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * Neither the name of Texas Instruments Incorporated nor the names of 00020 * its contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00026 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 */ 00036 00037 00038 00039 #include "cc3100_simplelink.h" 00040 00041 #ifndef __SIMPLELINK_TRACE_H__ 00042 #define __SIMPLELINK_TRACE_H__ 00043 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 /*****************************************************************************/ 00050 /* Macro declarations */ 00051 /*****************************************************************************/ 00052 00053 #define SL_SYNC_SCAN_THRESHOLD (( _u32 )2000) 00054 00055 #define _SlDrvAssert(line ) { while(1); } 00056 00057 #define _SL_ASSERT(expr) { if(!(expr)){_SlDrvAssert(__LINE__); } } 00058 #define _SL_ERROR(expr, error) { if(!(expr)){return (error); } } 00059 00060 #define SL_HANDLING_ASSERT 2 00061 #define SL_HANDLING_ERROR 1 00062 #define SL_HANDLING_NONE 0 00063 00064 #define SL_SELF_COND_HANDLING SL_HANDLING_ASSERT 00065 #define SL_PROTOCOL_HANDLING SL_HANDLING_ASSERT 00066 #define SL_DRV_RET_CODE_HANDLING SL_HANDLING_ASSERT 00067 #define SL_NWP_IF_HANDLING SL_HANDLING_ASSERT 00068 #define SL_OSI_RET_OK_HANDLING SL_HANDLING_ASSERT 00069 #define SL_MALLOC_OK_HANDLING SL_HANDLING_ASSERT 00070 #define SL_USER_ARGS_HANDLING SL_HANDLING_ASSERT 00071 00072 #if (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ASSERT) 00073 #define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)} 00074 #elif (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ERROR) 00075 #define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;} 00076 #else 00077 #define VERIFY_RET_OK(Func) (Func); 00078 #endif 00079 00080 #if (SL_PROTOCOL_HANDLING == SL_HANDLING_ASSERT) 00081 #define VERIFY_PROTOCOL(expr) _SL_ASSERT(expr) 00082 #elif (SL_PROTOCOL_HANDLING == SL_HANDLING_ERROR) 00083 #define VERIFY_PROTOCOL(expr) _SL_ERROR(expr, SL_RET_CODE_PROTOCOL_ERROR) 00084 #else 00085 #define VERIFY_PROTOCOL(expr) 00086 #endif 00087 00088 #if (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ASSERT)) 00089 #define VERIFY_SOCKET_CB(expr) _SL_ASSERT(expr) 00090 #elif (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ERROR)) 00091 #define VERIFY_SOCKET_CB(expr) _SL_ERROR(expr, SL_RET_CODE_SELF_ERROR) 00092 #else 00093 #define VERIFY_SOCKET_CB(expr) 00094 #endif 00095 00096 #if (SL_NWP_IF_HANDLING == SL_HANDLING_ASSERT) 00097 #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)} 00098 #define NWP_IF_READ_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (len); RetSize = sl_IfRead((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)} 00099 #elif (SL_NWP_IF_HANDLING == SL_HANDLING_ERROR) 00100 #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfWrite((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);} 00101 #define NWP_IF_READ_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfRead((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);} 00102 #else 00103 #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { sl_IfWrite((fd),(pBuff),(len));} 00104 #define NWP_IF_READ_CHECK(fd,pBuff,len) { sl_IfRead((fd),(pBuff),(len));} 00105 #endif 00106 00107 #if (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ASSERT) 00108 #define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)} 00109 #elif (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ERROR) 00110 #define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;} 00111 #else 00112 #define OSI_RET_OK_CHECK(Func) (Func); 00113 #endif 00114 00115 #if (SL_MALLOC_OK_HANDLING == SL_HANDLING_ASSERT) 00116 #define MALLOC_OK_CHECK(Ptr) _SL_ASSERT(NULL != Ptr) 00117 #elif (SL_MALLOC_OK_HANDLING == SL_HANDLING_ERROR) 00118 #define MALLOC_OK_CHECK(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_MALLOC_ERROR) 00119 #else 00120 #define MALLOC_OK_CHECK(Ptr) 00121 #endif 00122 00123 #ifdef SL_INC_ARG_CHECK 00124 00125 #if (SL_USER_ARGS_HANDLING == SL_HANDLING_ASSERT) 00126 #define ARG_CHECK_PTR(Ptr) _SL_ASSERT(NULL != Ptr) 00127 #elif (SL_USER_ARGS_HANDLING == SL_HANDLING_ERROR) 00128 #define ARG_CHECK_PTR(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_INVALID_INPUT) 00129 #else 00130 #define ARG_CHECK_PTR(Ptr) 00131 #endif 00132 00133 #else 00134 #define ARG_CHECK_PTR(Ptr) 00135 #endif 00136 00137 /*#define SL_DBG_TRACE_ENABLE*/ 00138 #ifdef SL_DBG_TRACE_ENABLE 00139 #define SL_TRACE0(level,msg_id,str) printf(str) 00140 #define SL_TRACE1(level,msg_id,str,p1) printf(str,(p1)) 00141 #define SL_TRACE2(level,msg_id,str,p1,p2) printf(str,(p1),(p2)) 00142 #define SL_TRACE3(level,msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3)) 00143 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4)) 00144 #define SL_ERROR_TRACE(msg_id,str) printf(str) 00145 #define SL_ERROR_TRACE1(msg_id,str,p1) printf(str,(p1)) 00146 #define SL_ERROR_TRACE2(msg_id,str,p1,p2) printf(str,(p1),(p2)) 00147 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3)) 00148 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4)) 00149 #define SL_TRACE_FLUSH() 00150 #else 00151 #define SL_TRACE0(level,msg_id,str) 00152 #define SL_TRACE1(level,msg_id,str,p1) 00153 #define SL_TRACE2(level,msg_id,str,p1,p2) 00154 #define SL_TRACE3(level,msg_id,str,p1,p2,p3) 00155 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4) 00156 #define SL_ERROR_TRACE(msg_id,str) 00157 #define SL_ERROR_TRACE1(msg_id,str,p1) 00158 #define SL_ERROR_TRACE2(msg_id,str,p1,p2) 00159 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3) 00160 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4) 00161 #define SL_TRACE_FLUSH() 00162 #endif 00163 00164 /* #define SL_DBG_CNT_ENABLE */ 00165 #ifdef SL_DBG_CNT_ENABLE 00166 #define _SL_DBG_CNT_INC(Cnt) g_DbgCnt. ## Cnt++ 00167 #define _SL_DBG_SYNC_LOG(index,value) {if(index < SL_DBG_SYNC_LOG_SIZE){*(_u32 *)&g_DbgCnt.SyncLog[index] = *(_u32 *)(value);}} 00168 00169 #else 00170 #define _SL_DBG_CNT_INC(Cnt) 00171 #define _SL_DBG_SYNC_LOG(index,value) 00172 #endif 00173 00174 #define SL_DBG_LEVEL_1 1 00175 #define SL_DBG_LEVEL_2 2 00176 #define SL_DBG_LEVEL_3 4 00177 #define SL_DBG_LEVEL_MASK (SL_DBG_LEVEL_2|SL_DBG_LEVEL_3) 00178 00179 #define SL_INCLUDE_DBG_FUNC(Name) ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK) 00180 00181 #define _SlDrvPrintStat_DBG_LEVEL SL_DBG_LEVEL_3 00182 #define _SlDrvOtherFunc_DBG_LEVEL SL_DBG_LEVEL_1 00183 00184 #ifdef __cplusplus 00185 } 00186 #endif 00187 00188 00189 #endif /*__SIMPLELINK_TRACE_H__*/ 00190 00191
Generated on Tue Jul 12 2022 22:55:20 by 1.7.2