00001 /*This file is prepared for Doxygen automatic documentation generation.*/ 00015 00016 /* Copyright (c) 2009 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 * 4. This software may only be redistributed and used in connection with an Atmel 00032 * AVR product. 00033 * 00034 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00035 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00036 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND 00037 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, 00038 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00039 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00040 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00041 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00042 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00043 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00044 */ 00045 00046 #ifndef _DEBUG_H_ 00047 #define _DEBUG_H_ 00048 00049 //_____ I N C L U D E S ____________________________________________________ 00050 #include <stdio.h> 00051 00052 //_____ M A C R O S ________________________________________________________ 00054 //#define SOFT_OCD // when OCD dongle is not used, only VT100 or hyperterminal 00055 00056 #ifndef _TRACE_ 00057 // Disable this switch to remove the Trace code from the compilation 00058 // Enable it to add Traces code on compilation 00059 #define _TRACE_ (DISABLE) // default value 00060 #endif 00061 00062 #ifndef _ASSERT_ 00063 // Disable this switch to remove the Assert code from the compilation 00064 // Enable it to add the Assert code from the compilation 00065 #define _ASSERT_ (DISABLE) // default value 00066 #endif 00067 00075 #if (_ASSERT_==ENABLE) 00076 # define Assert( expr ) \ 00077 { \ 00078 if( !(expr) ) \ 00079 { \ 00080 trace("\n\r"); \ 00081 trace(__FILE__); \ 00082 trace(":"); \ 00083 trace_u16(__LINE__); \ 00084 while(1) { \ 00085 } \ 00086 } \ 00087 } 00088 #else 00089 # define Assert( expr ) 00090 #endif 00091 00092 00093 extern U8 _MEM_TYPE_SLOW_ g_trace_en; 00094 00095 #if (_TRACE_==ENABLE) 00096 void trace ( const U8* str ); 00097 void trace_nl ( void ); 00098 void trace_hex ( U8 val ); 00099 void trace_hex16 ( U16 val ); 00100 void trace_hex32 ( U32 val ); 00101 void trace_u8 ( U8 val ); 00102 void trace_u16 ( U16 val ); 00103 void trace_u32 ( U32 val ); 00104 void trace_ptwo ( U8 hex ); 00105 00106 #else 00107 00108 # define trace( str ) 00109 # define trace_nl( ) 00110 # define trace_hex( val ) 00111 # define trace_hex16( val ) 00112 # define trace_hex32( val ) 00113 # define trace_u8( val ) 00114 # define trace_u16( val ) 00115 # define trace_u32( val ) 00116 # define trace_ptwo( hex ) 00117 #endif 00118 00119 #if (_TRACE_!=ENABLE) && (_TRACE_!=DISABLE) 00120 # error _TRACE_ can only be defined to ENABLE or DISABLE 00121 #endif 00122 #if (_ASSERT_!=ENABLE) && (_ASSERT_!=DISABLE) 00123 # error _ASSERT_ can only be defined to ENABLE or DISABLE 00124 #endif 00125 00126 #endif // _DEBUG_H_