Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #ifndef _TRACE_
00065 #define _TRACE_
00066
00067
00068
00069
00070
00071 #include "pio.h"
00072
00073 #include <stdio.h>
00074
00075
00076
00077
00078
00079
00080 #define SOFTPACK_VERSION "1.3"
00081
00082 #define TRACE_LEVEL_DEBUG 5
00083 #define TRACE_LEVEL_INFO 4
00084 #define TRACE_LEVEL_WARNING 3
00085 #define TRACE_LEVEL_ERROR 2
00086 #define TRACE_LEVEL_FATAL 1
00087 #define TRACE_LEVEL_NO_TRACE 0
00088
00089
00090 #if !defined(TRACE_LEVEL)
00091 #define TRACE_LEVEL TRACE_LEVEL_INFO
00092 #endif
00093
00094
00095 #if !defined(DYN_TRACES)
00096 #define DYN_TRACES 0
00097 #endif
00098
00099 #if defined(NOTRACE)
00100 #error "Error: NOTRACE has to be not defined !"
00101 #endif
00102
00103 #undef NOTRACE
00104 #if (DYN_TRACES==0)
00105 #if (TRACE_LEVEL == TRACE_LEVEL_NO_TRACE)
00106 #define NOTRACE
00107 #endif
00108 #endif
00109
00110
00111
00112
00113
00114
00115
00116
00117 extern void TRACE_CONFIGURE( uint32_t dwBaudRate, uint32_t dwMCk ) ;
00118
00119
00120
00121
00122
00123
00124
00125
00126 #ifndef DYNTRACE
00127 #define DYNTRACE 0
00128 #endif
00129
00130 #if (TRACE_LEVEL==0) && (DYNTRACE==0)
00131 #define TRACE_CONFIGURE_ISP(mode, baudrate, mck) {}
00132 #else
00133 #define TRACE_CONFIGURE_ISP(mode, baudrate, mck) { \
00134 const Pin pinsUART0[] = {PINS_UART}; \
00135 PIO_Configure(pinsUART0, PIO_LISTSIZE(pinsUART0)); \
00136 UART_Configure( baudrate, mck ) ; \
00137 }
00138 #endif
00139
00140
00141
00142
00143
00144
00145 #if defined(NOTRACE)
00146
00147
00148 #define TRACE_DEBUG(...) { }
00149 #define TRACE_INFO(...) { }
00150 #define TRACE_WARNING(...) { }
00151 #define TRACE_ERROR(...) { }
00152 #define TRACE_FATAL(...) { while(1); }
00153
00154 #define TRACE_DEBUG_WP(...) { }
00155 #define TRACE_INFO_WP(...) { }
00156 #define TRACE_WARNING_WP(...) { }
00157 #define TRACE_ERROR_WP(...) { }
00158 #define TRACE_FATAL_WP(...) { while(1); }
00159
00160 #elif (DYN_TRACES == 1)
00161
00162
00163 #define TRACE_DEBUG(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf("-D- " __VA_ARGS__); } }
00164 #define TRACE_INFO(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf("-I- " __VA_ARGS__); } }
00165 #define TRACE_WARNING(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf("-W- " __VA_ARGS__); } }
00166 #define TRACE_ERROR(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf("-E- " __VA_ARGS__); } }
00167 #define TRACE_FATAL(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf("-F- " __VA_ARGS__); while(1); } }
00168
00169 #define TRACE_DEBUG_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf(__VA_ARGS__); } }
00170 #define TRACE_INFO_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf(__VA_ARGS__); } }
00171 #define TRACE_WARNING_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf(__VA_ARGS__); } }
00172 #define TRACE_ERROR_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf(__VA_ARGS__); } }
00173 #define TRACE_FATAL_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf(__VA_ARGS__); while(1); } }
00174
00175 #else
00176
00177
00178 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
00179 #define TRACE_DEBUG(...) { printf("-D- " __VA_ARGS__); }
00180 #define TRACE_DEBUG_WP(...) { printf(__VA_ARGS__); }
00181 #else
00182 #define TRACE_DEBUG(...) { }
00183 #define TRACE_DEBUG_WP(...) { }
00184 #endif
00185
00186 #if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
00187 #define TRACE_INFO(...) { printf("-I- " __VA_ARGS__); }
00188 #define TRACE_INFO_WP(...) { printf(__VA_ARGS__); }
00189 #else
00190 #define TRACE_INFO(...) { }
00191 #define TRACE_INFO_WP(...) { }
00192 #endif
00193
00194 #if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)
00195 #define TRACE_WARNING(...) { printf("-W- " __VA_ARGS__); }
00196 #define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); }
00197 #else
00198 #define TRACE_WARNING(...) { }
00199 #define TRACE_WARNING_WP(...) { }
00200 #endif
00201
00202 #if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)
00203 #define TRACE_ERROR(...) { printf("-E- " __VA_ARGS__); }
00204 #define TRACE_ERROR_WP(...) { printf(__VA_ARGS__); }
00205 #else
00206 #define TRACE_ERROR(...) { }
00207 #define TRACE_ERROR_WP(...) { }
00208 #endif
00209
00210 #if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)
00211 #define TRACE_FATAL(...) { printf("-F- " __VA_ARGS__); while(1); }
00212 #define TRACE_FATAL_WP(...) { printf(__VA_ARGS__); while(1); }
00213 #else
00214 #define TRACE_FATAL(...) { while(1); }
00215 #define TRACE_FATAL_WP(...) { while(1); }
00216 #endif
00217
00218 #endif
00219
00220
00221
00222
00223
00224
00225 #if !defined(NOTRACE) && (DYN_TRACES == 1)
00226 extern uint32_t dwTraceLevel ;
00227 #endif
00228
00229 #endif //#ifndef TRACE_H
00230