debug.h

Go to the documentation of this file.
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
00015 
00016 /* Copyright (c) 2007, Atmel Corporation All rights reserved.
00017  *
00018  * Redistribution and use in source and binary forms, with or without
00019  * modification, are permitted provided that the following conditions are met:
00020  *
00021  * 1. Redistributions of source code must retain the above copyright notice,
00022  * this list of conditions and the following disclaimer.
00023  *
00024  * 2. Redistributions in binary form must reproduce the above copyright notice,
00025  * this list of conditions and the following disclaimer in the documentation
00026  * and/or other materials provided with the distribution.
00027  *
00028  * 3. The name of ATMEL may not be used to endorse or promote products derived
00029  * from this software without specific prior written permission.
00030  *
00031  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
00032  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00033  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
00034  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00035  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00036  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00037  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00038  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00039  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00040  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00041  */
00042 
00043 #ifndef _DEBUG_H_
00044 #define _DEBUG_H_
00045 
00046 //_____ I N C L U D E S ____________________________________________________
00047 #include <stdio.h>
00048 
00049 //_____ M A C R O S ________________________________________________________
00051 //#define SOFT_OCD          // when OCD dongle is not used, only VT100 or hyperterminal
00052 
00053 #ifndef _TRACE_
00054 // Disable this switch to remove the Trace code from the compilation
00055 // Enable it to add Traces code on compilation
00056 #define _TRACE_  (DISABLE) // default value
00057 #endif
00058 
00059 #ifndef _ASSERT_
00060 // Disable this switch to remove the Assert code from the compilation
00061 // Enable it to add the Assert code from the compilation
00062 #define _ASSERT_ (DISABLE) // default value
00063 #endif
00064 
00072 #if (_ASSERT_==ENABLE)
00073 #  define Assert( expr )      \
00074    {                          \
00075       if( !(expr) )           \
00076       {                       \
00077          trace("\n\r");       \
00078          trace(__FILE__);     \
00079          trace(":");          \
00080          trace_u16(__LINE__); \
00081          while(1) {           \
00082          }                    \
00083       }                       \
00084    }
00085 #else
00086 #  define Assert( expr )
00087 #endif
00088 
00089 
00090 extern U8 _MEM_TYPE_SLOW_ g_trace_en;
00091 
00092 #if (_TRACE_==ENABLE)
00093 void    trace        ( const U8* str );
00094 void    trace_nl     ( void    );
00095 void    trace_hex    ( U8  val );
00096 void    trace_hex16  ( U16 val );
00097 void    trace_hex32  ( U32 val );
00098 void    trace_u8     ( U8  val );
00099 void    trace_u16    ( U16 val );
00100 void    trace_u32    ( U32 val );
00101 void    trace_ptwo   ( U8  hex );
00102 
00103 #else
00104 
00105 #  define trace(        str )
00106 #  define trace_nl(         )
00107 #  define trace_hex(    val )
00108 #  define trace_hex16(  val )
00109 #  define trace_hex32(  val )
00110 #  define trace_u8(     val )
00111 #  define trace_u16(    val )
00112 #  define trace_u32(    val )
00113 #  define trace_ptwo(   hex )
00114 #endif
00115 
00116 #if (_TRACE_!=ENABLE) && (_TRACE_!=DISABLE)
00117 #  error _TRACE_ can only be defined to ENABLE or DISABLE
00118 #endif
00119 #if (_ASSERT_!=ENABLE) && (_ASSERT_!=DISABLE)
00120 #  error _ASSERT_ can only be defined to ENABLE or DISABLE
00121 #endif
00122 
00123 #endif  // _DEBUG_H_

Generated on Fri Oct 31 14:31:23 2008 for ATMEL by  doxygen 1.5.3