TI's CC3100. A test demo with very little testing done!

Dependencies:   mbed

Fork of cc3100_Test_Demo2 by 高 杨

Committer:
gaoyang
Date:
Sun Jul 30 06:32:08 2017 +0000
Revision:
9:b8da46b97970
Parent:
6:778b081f6a13
DAS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 6:778b081f6a13 1 /*
dflet 6:778b081f6a13 2 * trace.h - CC31xx/CC32xx Host Driver Implementation
dflet 6:778b081f6a13 3 *
dflet 6:778b081f6a13 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 6:778b081f6a13 5 *
dflet 6:778b081f6a13 6 *
dflet 6:778b081f6a13 7 * Redistribution and use in source and binary forms, with or without
dflet 6:778b081f6a13 8 * modification, are permitted provided that the following conditions
dflet 6:778b081f6a13 9 * are met:
dflet 6:778b081f6a13 10 *
dflet 6:778b081f6a13 11 * Redistributions of source code must retain the above copyright
dflet 6:778b081f6a13 12 * notice, this list of conditions and the following disclaimer.
dflet 6:778b081f6a13 13 *
dflet 6:778b081f6a13 14 * Redistributions in binary form must reproduce the above copyright
dflet 6:778b081f6a13 15 * notice, this list of conditions and the following disclaimer in the
dflet 6:778b081f6a13 16 * documentation and/or other materials provided with the
dflet 6:778b081f6a13 17 * distribution.
dflet 6:778b081f6a13 18 *
dflet 6:778b081f6a13 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 6:778b081f6a13 20 * its contributors may be used to endorse or promote products derived
dflet 6:778b081f6a13 21 * from this software without specific prior written permission.
dflet 6:778b081f6a13 22 *
dflet 6:778b081f6a13 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 6:778b081f6a13 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 6:778b081f6a13 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 6:778b081f6a13 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 6:778b081f6a13 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 6:778b081f6a13 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 6:778b081f6a13 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 6:778b081f6a13 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 6:778b081f6a13 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 6:778b081f6a13 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 6:778b081f6a13 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 6:778b081f6a13 34 *
dflet 6:778b081f6a13 35 */
dflet 6:778b081f6a13 36 #ifndef SIMPLELINK_TRACE_H_
dflet 6:778b081f6a13 37 #define SIMPLELINK_TRACE_H_
dflet 6:778b081f6a13 38
dflet 6:778b081f6a13 39
dflet 6:778b081f6a13 40 #include "cc3100_simplelink.h"
dflet 6:778b081f6a13 41
dflet 6:778b081f6a13 42 /*****************************************************************************/
dflet 6:778b081f6a13 43 /* Macro declarations */
dflet 6:778b081f6a13 44 /*****************************************************************************/
dflet 6:778b081f6a13 45
dflet 6:778b081f6a13 46 /* This macro is for use by other macros to form a fully valid C statement. */
dflet 6:778b081f6a13 47 #define st(x) do { x } while (__LINE__ == -1)
dflet 6:778b081f6a13 48
dflet 6:778b081f6a13 49 #define SL_SYNC_SCAN_THRESHOLD (( uint32_t )2000)
dflet 6:778b081f6a13 50
dflet 6:778b081f6a13 51 #define _SlDrvAssert(line ) { while(1); }
dflet 6:778b081f6a13 52
dflet 6:778b081f6a13 53 #define _SL_ASSERT(expr) { if(!(expr)){_SlDrvAssert(__LINE__); } }
dflet 6:778b081f6a13 54 #define _SL_ERROR(expr, error) { if(!(expr)){return (error); } }
dflet 6:778b081f6a13 55
dflet 6:778b081f6a13 56 #define SL_HANDLING_ASSERT 2
dflet 6:778b081f6a13 57 #define SL_HANDLING_ERROR 1
dflet 6:778b081f6a13 58 #define SL_HANDLING_NONE 0
dflet 6:778b081f6a13 59
dflet 6:778b081f6a13 60 #ifndef SL_TINY_EXT
dflet 6:778b081f6a13 61 #define SL_SELF_COND_HANDLING SL_HANDLING_ASSERT
dflet 6:778b081f6a13 62 #define SL_PROTOCOL_HANDLING SL_HANDLING_ASSERT
dflet 6:778b081f6a13 63 #define SL_DRV_RET_CODE_HANDLING SL_HANDLING_ASSERT
dflet 6:778b081f6a13 64 #define SL_NWP_IF_HANDLING SL_HANDLING_ASSERT
dflet 6:778b081f6a13 65 #define SL_OSI_RET_OK_HANDLING SL_HANDLING_ASSERT
dflet 6:778b081f6a13 66 #define SL_MALLOC_OK_HANDLING SL_HANDLING_ASSERT
dflet 6:778b081f6a13 67 #define SL_USER_ARGS_HANDLING SL_HANDLING_ASSERT
dflet 6:778b081f6a13 68 #else
dflet 6:778b081f6a13 69 #define SL_SELF_COND_HANDLING SL_HANDLING_NONE
dflet 6:778b081f6a13 70 #define SL_PROTOCOL_HANDLING SL_HANDLING_NONE
dflet 6:778b081f6a13 71 #define SL_DRV_RET_CODE_HANDLING SL_HANDLING_NONE
dflet 6:778b081f6a13 72 #define SL_NWP_IF_HANDLING SL_HANDLING_NONE
dflet 6:778b081f6a13 73 #define SL_OSI_RET_OK_HANDLING SL_HANDLING_NONE
dflet 6:778b081f6a13 74 #define SL_MALLOC_OK_HANDLING SL_HANDLING_NONE
dflet 6:778b081f6a13 75 #define SL_USER_ARGS_HANDLING SL_HANDLING_NONE
dflet 6:778b081f6a13 76 #endif
dflet 6:778b081f6a13 77
dflet 6:778b081f6a13 78 #if (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ASSERT)
dflet 6:778b081f6a13 79 #define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
dflet 6:778b081f6a13 80 #elif (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ERROR)
dflet 6:778b081f6a13 81 #define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;}
dflet 6:778b081f6a13 82 #else
dflet 6:778b081f6a13 83 #define VERIFY_RET_OK(Func) (Func);
dflet 6:778b081f6a13 84 #endif
dflet 6:778b081f6a13 85
dflet 6:778b081f6a13 86 #if (SL_PROTOCOL_HANDLING == SL_HANDLING_ASSERT)
dflet 6:778b081f6a13 87 #define VERIFY_PROTOCOL(expr) _SL_ASSERT(expr)
dflet 6:778b081f6a13 88 #elif (SL_PROTOCOL_HANDLING == SL_HANDLING_ERROR)
dflet 6:778b081f6a13 89 #define VERIFY_PROTOCOL(expr) _SL_ERROR(expr, SL_RET_CODE_PROTOCOL_ERROR)
dflet 6:778b081f6a13 90 #else
dflet 6:778b081f6a13 91 #define VERIFY_PROTOCOL(expr)
dflet 6:778b081f6a13 92 #endif
dflet 6:778b081f6a13 93
dflet 6:778b081f6a13 94 #if (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ASSERT))
dflet 6:778b081f6a13 95 #define VERIFY_SOCKET_CB(expr) _SL_ASSERT(expr)
dflet 6:778b081f6a13 96 #elif (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ERROR))
dflet 6:778b081f6a13 97 #define VERIFY_SOCKET_CB(expr) _SL_ERROR(expr, SL_RET_CODE_SELF_ERROR)
dflet 6:778b081f6a13 98 #else
dflet 6:778b081f6a13 99 #define VERIFY_SOCKET_CB(expr)
dflet 6:778b081f6a13 100 #endif
dflet 6:778b081f6a13 101
dflet 6:778b081f6a13 102 #if (SL_NWP_IF_HANDLING == SL_HANDLING_ASSERT)
dflet 6:778b081f6a13 103 //#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { int16_t RetSize, ExpSize = (len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
dflet 6:778b081f6a13 104 //#define NWP_IF_READ_CHECK(fd,pBuff,len) { int16_t RetSize, ExpSize = (len); RetSize = sl_IfRead((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
dflet 6:778b081f6a13 105 #elif (SL_NWP_IF_HANDLING == SL_HANDLING_ERROR)
dflet 6:778b081f6a13 106 //#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfWrite((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
dflet 6:778b081f6a13 107 //#define NWP_IF_READ_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfRead((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
dflet 6:778b081f6a13 108 #else
dflet 6:778b081f6a13 109 //#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { sl_IfWrite((fd),(pBuff),(len));}
dflet 6:778b081f6a13 110 //#define NWP_IF_READ_CHECK(fd,pBuff,len) { sl_IfRead((fd),(pBuff),(len));}
dflet 6:778b081f6a13 111 #endif
dflet 6:778b081f6a13 112
dflet 6:778b081f6a13 113 #if (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ASSERT)
dflet 6:778b081f6a13 114 #define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
dflet 6:778b081f6a13 115 #elif (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ERROR)
dflet 6:778b081f6a13 116 #define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;}
dflet 6:778b081f6a13 117 #else
dflet 6:778b081f6a13 118 #define OSI_RET_OK_CHECK(Func) (Func);
dflet 6:778b081f6a13 119 #endif
dflet 6:778b081f6a13 120
dflet 6:778b081f6a13 121 #if (SL_MALLOC_OK_HANDLING == SL_HANDLING_ASSERT)
dflet 6:778b081f6a13 122 #define MALLOC_OK_CHECK(Ptr) _SL_ASSERT(NULL != Ptr)
dflet 6:778b081f6a13 123 #elif (SL_MALLOC_OK_HANDLING == SL_HANDLING_ERROR)
dflet 6:778b081f6a13 124 #define MALLOC_OK_CHECK(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_MALLOC_ERROR)
dflet 6:778b081f6a13 125 #else
dflet 6:778b081f6a13 126 #define MALLOC_OK_CHECK(Ptr)
dflet 6:778b081f6a13 127 #endif
dflet 6:778b081f6a13 128
dflet 6:778b081f6a13 129 #ifdef SL_INC_ARG_CHECK
dflet 6:778b081f6a13 130
dflet 6:778b081f6a13 131 #if (SL_USER_ARGS_HANDLING == SL_HANDLING_ASSERT)
dflet 6:778b081f6a13 132 #define ARG_CHECK_PTR(Ptr) _SL_ASSERT(NULL != Ptr)
dflet 6:778b081f6a13 133 #elif (SL_USER_ARGS_HANDLING == SL_HANDLING_ERROR)
dflet 6:778b081f6a13 134 #define ARG_CHECK_PTR(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_INVALID_INPUT)
dflet 6:778b081f6a13 135 #else
dflet 6:778b081f6a13 136 #define ARG_CHECK_PTR(Ptr)
dflet 6:778b081f6a13 137 #endif
dflet 6:778b081f6a13 138
dflet 6:778b081f6a13 139 #else
dflet 6:778b081f6a13 140 #define ARG_CHECK_PTR(Ptr)
dflet 6:778b081f6a13 141 #endif
dflet 6:778b081f6a13 142
dflet 6:778b081f6a13 143 //#define SL_DBG_TRACE_ENABLE
dflet 6:778b081f6a13 144 #ifdef SL_DBG_TRACE_ENABLE
dflet 6:778b081f6a13 145 #define SL_TRACE0(level,msg_id,str) printf(str)
dflet 6:778b081f6a13 146 #define SL_TRACE1(level,msg_id,str,p1) printf(str,(p1))
dflet 6:778b081f6a13 147 #define SL_TRACE2(level,msg_id,str,p1,p2) printf(str,(p1),(p2))
dflet 6:778b081f6a13 148 #define SL_TRACE3(level,msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3))
dflet 6:778b081f6a13 149 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4))
dflet 6:778b081f6a13 150 #define SL_ERROR_TRACE(msg_id,str) printf(str)
dflet 6:778b081f6a13 151 #define SL_ERROR_TRACE1(msg_id,str,p1) printf(str,(p1))
dflet 6:778b081f6a13 152 #define SL_ERROR_TRACE2(msg_id,str,p1,p2) printf(str,(p1),(p2))
dflet 6:778b081f6a13 153 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3))
dflet 6:778b081f6a13 154 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4))
dflet 6:778b081f6a13 155 #define SL_TRACE_FLUSH()
dflet 6:778b081f6a13 156 #else
dflet 6:778b081f6a13 157 #define SL_TRACE0(level,msg_id,str)
dflet 6:778b081f6a13 158 #define SL_TRACE1(level,msg_id,str,p1)
dflet 6:778b081f6a13 159 #define SL_TRACE2(level,msg_id,str,p1,p2)
dflet 6:778b081f6a13 160 #define SL_TRACE3(level,msg_id,str,p1,p2,p3)
dflet 6:778b081f6a13 161 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4)
dflet 6:778b081f6a13 162 #define SL_ERROR_TRACE(msg_id,str)
dflet 6:778b081f6a13 163 #define SL_ERROR_TRACE1(msg_id,str,p1)
dflet 6:778b081f6a13 164 #define SL_ERROR_TRACE2(msg_id,str,p1,p2)
dflet 6:778b081f6a13 165 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3)
dflet 6:778b081f6a13 166 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4)
dflet 6:778b081f6a13 167 #define SL_TRACE_FLUSH()
dflet 6:778b081f6a13 168 #endif
dflet 6:778b081f6a13 169
dflet 6:778b081f6a13 170 //#define SL_DBG_CNT_ENABLE
dflet 6:778b081f6a13 171 #ifdef SL_DBG_CNT_ENABLE
dflet 6:778b081f6a13 172 #define _SL_DBG_CNT_INC(Cnt) g_DbgCnt. ## Cnt++
dflet 6:778b081f6a13 173 #define _SL_DBG_SYNC_LOG(index,value) {if(index < SL_DBG_SYNC_LOG_SIZE){*(uint32_t *)&g_DbgCnt.SyncLog[index] = *(uint32_t *)(value);}}
dflet 6:778b081f6a13 174
dflet 6:778b081f6a13 175 #else
dflet 6:778b081f6a13 176 #define _SL_DBG_CNT_INC(Cnt)
dflet 6:778b081f6a13 177 #define _SL_DBG_SYNC_LOG(index,value)
dflet 6:778b081f6a13 178 #endif
dflet 6:778b081f6a13 179
dflet 6:778b081f6a13 180 #define SL_DBG_LEVEL_1 1
dflet 6:778b081f6a13 181 #define SL_DBG_LEVEL_2 2
dflet 6:778b081f6a13 182 #define SL_DBG_LEVEL_3 4
dflet 6:778b081f6a13 183 #define SL_DBG_LEVEL_MASK (SL_DBG_LEVEL_2|SL_DBG_LEVEL_3)
dflet 6:778b081f6a13 184
dflet 6:778b081f6a13 185 #define SL_INCLUDE_DBG_FUNC(Name) ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK)
dflet 6:778b081f6a13 186
dflet 6:778b081f6a13 187 #define _SlDrvPrintStat_DBG_LEVEL SL_DBG_LEVEL_3
dflet 6:778b081f6a13 188 #define _SlDrvOtherFunc_DBG_LEVEL SL_DBG_LEVEL_1
dflet 6:778b081f6a13 189
dflet 6:778b081f6a13 190
dflet 6:778b081f6a13 191 #endif /*__SIMPLELINK_TRACE_H__*/
dflet 6:778b081f6a13 192
dflet 6:778b081f6a13 193