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