Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

debug.h

Go to the documentation of this file.
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 #ifndef _DEBUG_H_ 00017 #define _DEBUG_H_ 00018 00019 //_____ I N C L U D E S ____________________________________________________ 00020 #include "conf/conf_clock.h" 00021 00022 //_____ M A C R O S ________________________________________________________ 00024 //#define SOFT_OCD // when OCD dongle is not used, only VT100 or hyperterminal 00025 00026 #ifndef _TRACE_ 00027 // Disable this switch to remove the Trace code from the compilation 00028 // Enable it to add Traces code on compilation 00029 #define _TRACE_ (DISABLE) // default value 00030 #endif 00031 00032 #ifndef _ASSERT_ 00033 // Disable this switch to remove the Assert code from the compilation 00034 // Enable it to add the Assert code from the compilation 00035 #define _ASSERT_ (DISABLE) // default value 00036 #endif 00037 00038 #define OCD_BAUDRATE 19200 00039 00041 #ifndef FOSC 00042 #error You must define FOSC in config.h 00043 #elif FOSC == 12000 // Fosc = 12 MHz 00044 # if OCD_BAUDRATE == 4800 00045 # define OCD_BRL_VALUE 155 // error <1% 00046 # elif OCD_BAUDRATE == 9600 00047 # define Ocd_BRL_value 77 // error <1% 00048 # elif OCD_BAUDRATE == 19200 00049 # define OCD_BRL_VALUE 38 // error <1% 00050 # elif OCD_BAUDRATE == 57600 00051 # define Ocd_BRL_value 12 // error <1% 00052 # else 00053 # error Only these baudrates are available : 4800, 9600, 19200, 57600 00054 # endif 00055 #elif FOSC == 16000 // Fosc = 16 MHz 00056 # if OCD_BAUDRATE == 4800 00057 # define OCD_BRL_VALUE 207 // error <1% 00058 # elif OCD_BAUDRATE == 9600 00059 # define OCD_BRL_VALUE 103 // error <1% 00060 # elif OCD_BAUDRATE == 19200 00061 # define OCD_BRL_VALUE 51 // error <1% 00062 # elif OCD_BAUDRATE == 19200 00063 # define OCD_BRL_VALUE 51 // error <1% 00064 # elif OCD_BAUDRATE == 38400 00065 # define OCD_BRL_VALUE 25 // error <1% 00066 # else 00067 # error Only these baudrates are available : 4800, 9600, 19200, 38400 00068 # endif 00069 #elif FOSC == 20000 // Fosc = 20 MHz 00070 # if OCD_BAUDRATE == 9600 00071 # define OCD_BRL_VALUE 129 // error <1% 00072 # elif OCD_BAUDRATE == 19200 00073 # define OCD_BRL_VALUE 64 // error <1% 00074 # elif OCD_BAUDRATE == 38400 00075 # define OCD_BRL_VALUE 32 // 5% error 00076 # else 00077 # error Only these baudrates are available : 9600, 19200, 38400 00078 # endif 00079 #elif FOSC == 24000 // Fosc = 24 MHz 00080 # if OCD_BAUDRATE == 9600 00081 # define OCD_BRL_VALUE 155 // error <1% 00082 # elif OCD_BAUDRATE == 19200 00083 # define OCD_BRL_VALUE 77 // error <1% 00084 # elif OCD_BAUDRATE == 38400 00085 # define OCD_BRL_VALUE 38 // error <1% 00086 # elif OCD_BAUDRATE == 57600 00087 # define OCD_BRL_VALUE 25 // error <1% 00088 # elif OCD_BAUDRATE == 115200 00089 # define OCD_BRL_VALUE 12 // 1.84% error 00090 # else 00091 # error Only these baudrates are available : 9600, 19200, 38400, 57600, 115200 00092 # endif 00093 #endif 00094 00096 #define Ocd_soft_entry() (OACTIV=0x55,OACTIV=0xAA) 00097 00099 #define TRACE_START_CHAR ('#') 00100 #define TRACE_STOP_CHAR ( 0 ) 00101 00102 00110 #if (_ASSERT_==ENABLE) 00111 # define Assert( expr ) \ 00112 { \ 00113 if( !(expr) ) \ 00114 { \ 00115 trace("\n\r"); \ 00116 trace(__FILE__); \ 00117 trace(":"); \ 00118 trace_u16(__LINE__); \ 00119 while(1) { \ 00120 } \ 00121 } \ 00122 } 00123 #else 00124 # define Assert( expr ) 00125 #endif 00126 00127 00128 extern U8 _MEM_TYPE_SLOW_ g_trace_en; 00129 00130 #if (_TRACE_==ENABLE) 00131 # define Trace_ptwo( hex ) (P2 = (hex)) 00132 void trace( const U8* str ); 00133 void trace_hex( U8 val ); 00134 void trace_u8( U16 val ); 00135 void trace_u16( U16 val ); 00136 void trace_u32( U32 val ); 00137 00138 #define Trace_nl() \ 00139 trace("\n\r"); 00140 00141 #define Trace_hex16(u16) \ 00142 trace("0x"); \ 00143 trace_hex(MSB(u16)); \ 00144 trace_hex(LSB(u16)); 00145 00146 #define Trace_hex32(u32) \ 00147 trace("0x"); \ 00148 trace_hex(MSB0(u32)); \ 00149 trace_hex(MSB1(u32)); \ 00150 trace_hex(MSB2(u32)); \ 00151 trace_hex(MSB3(u32)); 00152 00153 #else 00154 00155 # define Trace_ptwo( hex ) 00156 # define trace( str ) 00157 # define trace_hex( val ) 00158 # define trace_u16( val ) 00159 # define trace_u32( val ) 00160 # define Trace_hex16(u16) 00161 # define Trace_hex32(u32) 00162 # define Trace_nl() 00163 # define Traces_u8(expr) 00164 # define Traces_u16(expr) 00165 # define Traces_u32(expr) 00166 #endif 00167 00168 #if (_TRACE_!=ENABLE) && (_TRACE_!=DISABLE) 00169 # error _TRACE_ can only be defined to ENABLE or DISABLE 00170 #endif 00171 #if (_ASSERT_!=ENABLE) && (_ASSERT_!=DISABLE) 00172 # error _ASSERT_ can only be defined to ENABLE or DISABLE 00173 #endif 00174 //_____ D E C L A R A T I O N S ____________________________________________ 00175 void ocd_enable(Bool ocd_activ); 00176 00177 #endif // _DEBUG_H_

Generated on Mon Apr 10 17:23:29 2006 for Atmel by doxygen 1.3.7