Port of TI's CC3100 Websock camera demo. Using FreeRTOS, mbedTLS, also parts of Arducam for cams ov5642 and 0v2640. Can also use MT9D111. Work in progress. Be warned some parts maybe a bit flacky. This is for Seeed Arch max only, for an M3, see the demo for CM3 using the 0v5642 aducam mini.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cc3100_trace.h Source File

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 #ifndef SIMPLELINK_TRACE_H_
00037 #define SIMPLELINK_TRACE_H_
00038 
00039 
00040 #include "cc3100_simplelink.h"
00041 
00042 
00043 /*****************************************************************************/
00044 /* Macro declarations                                                        */
00045 /*****************************************************************************/
00046 
00047 /*  This macro is for use by other macros to form a fully valid C statement. */
00048 #define st(x)      do { x } while (__LINE__ == -1)
00049 
00050 #define SL_SYNC_SCAN_THRESHOLD  (( uint32_t )2000)
00051 
00052 #define _SlDrvAssert(line )  { while(1); }
00053 
00054 #define _SL_ASSERT(expr)            { if(!(expr)){_SlDrvAssert(__LINE__); } }
00055 #define _SL_ERROR(expr, error)      { if(!(expr)){return (error); } }
00056 
00057 #define SL_HANDLING_ASSERT          2
00058 #define SL_HANDLING_ERROR           1
00059 #define SL_HANDLING_NONE            0
00060 
00061 #ifndef SL_TINY_EXT
00062 #define SL_SELF_COND_HANDLING       SL_HANDLING_ASSERT
00063 #define SL_PROTOCOL_HANDLING        SL_HANDLING_ASSERT
00064 #define SL_DRV_RET_CODE_HANDLING    SL_HANDLING_ASSERT
00065 #define SL_NWP_IF_HANDLING          SL_HANDLING_ASSERT
00066 #define SL_OSI_RET_OK_HANDLING      SL_HANDLING_ASSERT
00067 #define SL_MALLOC_OK_HANDLING       SL_HANDLING_ASSERT
00068 #define SL_USER_ARGS_HANDLING       SL_HANDLING_ASSERT
00069 #else
00070 #define SL_SELF_COND_HANDLING       SL_HANDLING_NONE
00071 #define SL_PROTOCOL_HANDLING        SL_HANDLING_NONE
00072 #define SL_DRV_RET_CODE_HANDLING    SL_HANDLING_NONE
00073 #define SL_NWP_IF_HANDLING          SL_HANDLING_NONE
00074 #define SL_OSI_RET_OK_HANDLING      SL_HANDLING_NONE
00075 #define SL_MALLOC_OK_HANDLING       SL_HANDLING_NONE
00076 #define SL_USER_ARGS_HANDLING       SL_HANDLING_NONE
00077 #endif
00078 
00079 #if (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ASSERT)
00080 #define VERIFY_RET_OK(Func)                     {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
00081 #elif (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ERROR)
00082 #define VERIFY_RET_OK(Func)                     {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return  _RetVal;}
00083 #else
00084 #define VERIFY_RET_OK(Func)                     (Func);
00085 #endif
00086 
00087 #if (SL_PROTOCOL_HANDLING == SL_HANDLING_ASSERT)
00088 #define VERIFY_PROTOCOL(expr)                   _SL_ASSERT(expr)
00089 #elif (SL_PROTOCOL_HANDLING == SL_HANDLING_ERROR)
00090 #define VERIFY_PROTOCOL(expr)                   _SL_ERROR(expr, SL_RET_CODE_PROTOCOL_ERROR)
00091 #else
00092 #define VERIFY_PROTOCOL(expr)
00093 #endif
00094 
00095 #if (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ASSERT))
00096 #define VERIFY_SOCKET_CB(expr)                  _SL_ASSERT(expr)
00097 #elif (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ERROR))
00098 #define VERIFY_SOCKET_CB(expr)                  _SL_ERROR(expr, SL_RET_CODE_SELF_ERROR)
00099 #else
00100 #define VERIFY_SOCKET_CB(expr)
00101 #endif
00102 
00103 #if (SL_NWP_IF_HANDLING == SL_HANDLING_ASSERT)
00104 #define NWP_IF_WRITE_CHECK(fd,pBuff,len)       { int16_t RetSize, ExpSize = (len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
00105 #define NWP_IF_READ_CHECK(fd,pBuff,len)        { int16_t RetSize, ExpSize = (len); RetSize = sl_IfRead((fd),(pBuff),ExpSize);  _SL_ASSERT(ExpSize == RetSize)}
00106 #elif (SL_NWP_IF_HANDLING == SL_HANDLING_ERROR)
00107 #define NWP_IF_WRITE_CHECK(fd,pBuff,len)       { _SL_ERROR((len == sl_IfWrite((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
00108 #define NWP_IF_READ_CHECK(fd,pBuff,len)        { _SL_ERROR((len == sl_IfRead((fd),(pBuff),(len))),  SL_RET_CODE_NWP_IF_ERROR);}
00109 #else
00110 #define NWP_IF_WRITE_CHECK(fd,pBuff,len)       { sl_IfWrite((fd),(pBuff),(len));}
00111 #define NWP_IF_READ_CHECK(fd,pBuff,len)        { sl_IfRead((fd),(pBuff),(len));}
00112 #endif
00113 
00114 #if (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ASSERT)
00115 #define OSI_RET_OK_CHECK(Func)                  {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
00116 #elif (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ERROR)
00117 #define OSI_RET_OK_CHECK(Func)                  {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return  _RetVal;}
00118 #else
00119 #define OSI_RET_OK_CHECK(Func)                  (Func);
00120 #endif
00121 
00122 #if (SL_MALLOC_OK_HANDLING == SL_HANDLING_ASSERT)
00123 #define MALLOC_OK_CHECK(Ptr)                    _SL_ASSERT(NULL != Ptr)
00124 #elif (SL_MALLOC_OK_HANDLING == SL_HANDLING_ERROR)
00125 #define MALLOC_OK_CHECK(Ptr)                    _SL_ERROR((NULL != Ptr), SL_RET_CODE_MALLOC_ERROR)
00126 #else
00127 #define MALLOC_OK_CHECK(Ptr)
00128 #endif
00129 
00130 #ifdef SL_INC_ARG_CHECK
00131 
00132 #if (SL_USER_ARGS_HANDLING == SL_HANDLING_ASSERT)
00133 #define ARG_CHECK_PTR(Ptr)                      _SL_ASSERT(NULL != Ptr)
00134 #elif (SL_USER_ARGS_HANDLING == SL_HANDLING_ERROR)
00135 #define ARG_CHECK_PTR(Ptr)                      _SL_ERROR((NULL != Ptr), SL_RET_CODE_INVALID_INPUT)
00136 #else
00137 #define ARG_CHECK_PTR(Ptr)
00138 #endif
00139 
00140 #else
00141 #define ARG_CHECK_PTR(Ptr)
00142 #endif
00143 
00144 //#define SL_DBG_TRACE_ENABLE
00145 #ifdef SL_DBG_TRACE_ENABLE
00146 #define SL_TRACE0(level,msg_id,str)                     printf(str)
00147 #define SL_TRACE1(level,msg_id,str,p1)                  printf(str,(p1))
00148 #define SL_TRACE2(level,msg_id,str,p1,p2)               printf(str,(p1),(p2))
00149 #define SL_TRACE3(level,msg_id,str,p1,p2,p3)            printf(str,(p1),(p2),(p3))
00150 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4)         printf(str,(p1),(p2),(p3),(p4))
00151 #define SL_ERROR_TRACE(msg_id,str)                      printf(str)
00152 #define SL_ERROR_TRACE1(msg_id,str,p1)                  printf(str,(p1))
00153 #define SL_ERROR_TRACE2(msg_id,str,p1,p2)               printf(str,(p1),(p2))
00154 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3)            printf(str,(p1),(p2),(p3))
00155 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4)         printf(str,(p1),(p2),(p3),(p4))
00156 #define SL_TRACE_FLUSH()
00157 #else
00158 #define SL_TRACE0(level,msg_id,str)
00159 #define SL_TRACE1(level,msg_id,str,p1)
00160 #define SL_TRACE2(level,msg_id,str,p1,p2)
00161 #define SL_TRACE3(level,msg_id,str,p1,p2,p3)
00162 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4)
00163 #define SL_ERROR_TRACE(msg_id,str)
00164 #define SL_ERROR_TRACE1(msg_id,str,p1)
00165 #define SL_ERROR_TRACE2(msg_id,str,p1,p2)
00166 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3)
00167 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4)
00168 #define SL_TRACE_FLUSH()
00169 #endif
00170 
00171 //#define SL_DBG_CNT_ENABLE
00172 #ifdef SL_DBG_CNT_ENABLE
00173 #define _SL_DBG_CNT_INC(Cnt)            g_DbgCnt. ## Cnt++
00174 #define _SL_DBG_SYNC_LOG(index,value)   {if(index < SL_DBG_SYNC_LOG_SIZE){*(uint32_t *)&g_DbgCnt.SyncLog[index] = *(uint32_t *)(value);}}
00175 
00176 #else
00177 #define _SL_DBG_CNT_INC(Cnt)
00178 #define _SL_DBG_SYNC_LOG(index,value)
00179 #endif
00180 
00181 #define SL_DBG_LEVEL_1                  1
00182 #define SL_DBG_LEVEL_2                  2
00183 #define SL_DBG_LEVEL_3                  4
00184 #define SL_DBG_LEVEL_MASK               (SL_DBG_LEVEL_2|SL_DBG_LEVEL_3)
00185 
00186 #define SL_INCLUDE_DBG_FUNC(Name)       ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK)
00187 
00188 #define _SlDrvPrintStat_DBG_LEVEL       SL_DBG_LEVEL_3
00189 #define _SlDrvOtherFunc_DBG_LEVEL       SL_DBG_LEVEL_1
00190 
00191 
00192 #endif /*__SIMPLELINK_TRACE_H__*/
00193 
00194