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.5"
00081
00082
00083 #define TRACE_LEVEL_DEBUG 5
00084 #define TRACE_LEVEL_INFO 4
00085 #define TRACE_LEVEL_WARNING 3
00086 #define TRACE_LEVEL_ERROR 2
00087 #define TRACE_LEVEL_FATAL 1
00088 #define TRACE_LEVEL_NO_TRACE 0
00089
00090
00091 #if !defined(TRACE_LEVEL)
00092 #define TRACE_LEVEL TRACE_LEVEL_INFO
00093 #endif
00094
00095
00096 #if !defined(DYN_TRACES)
00097 #define DYN_TRACES 0
00098 #endif
00099
00100 #if defined(NOTRACE)
00101 #error "Error: NOTRACE has to be not defined !"
00102 #endif
00103
00104 #undef NOTRACE
00105 #if (DYN_TRACES==0)
00106 #if (TRACE_LEVEL == TRACE_LEVEL_NO_TRACE)
00107 #define NOTRACE
00108 #endif
00109 #endif
00110
00111
00112
00113
00114
00115
00116
00117
00118 extern void TRACE_CONFIGURE(uint32_t dwBaudRate, uint32_t dwMCk);
00119
00120
00121
00122
00123
00124
00125
00126
00127 #ifndef DYNTRACE
00128 #define DYNTRACE 0
00129 #endif
00130
00131 #if (TRACE_LEVEL==0) && (DYNTRACE==0)
00132 #define TRACE_CONFIGURE_ISP(mode, baudrate, mck) {}
00133 #else
00134 #define TRACE_CONFIGURE_ISP(mode, baudrate, mck) { \
00135 const Pin pinsUART0[] = {PINS_UART}; \
00136 PIO_Configure(pinsUART0, PIO_LISTSIZE(pinsUART0)); \
00137 UART_Configure(baudrate, mck); \
00138 }
00139 #endif
00140
00141
00142
00143
00144
00145
00146 #if defined(NOTRACE)
00147
00148
00149 #define TRACE_DEBUG(...) { }
00150 #define TRACE_INFO(...) { }
00151 #define TRACE_WARNING(...) { }
00152 #define TRACE_ERROR(...) { }
00153 #define TRACE_FATAL(...) { while (1); }
00154
00155 #define TRACE_DEBUG_WP(...) { }
00156 #define TRACE_INFO_WP(...) { }
00157 #define TRACE_WARNING_WP(...) { }
00158 #define TRACE_ERROR_WP(...) { }
00159 #define TRACE_FATAL_WP(...) { while (1); }
00160
00161 #elif (DYN_TRACES == 1)
00162
00163
00164 #define TRACE_DEBUG(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf("-D- " __VA_ARGS__); } }
00165 #define TRACE_INFO(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf("-I- " __VA_ARGS__); } }
00166 #define TRACE_WARNING(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf("-W- " __VA_ARGS__); } }
00167 #define TRACE_ERROR(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf("-E- " __VA_ARGS__); } }
00168 #define TRACE_FATAL(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf("-F- " __VA_ARGS__); while (1); } }
00169
00170 #define TRACE_DEBUG_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf(__VA_ARGS__); } }
00171 #define TRACE_INFO_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf(__VA_ARGS__); } }
00172 #define TRACE_WARNING_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf(__VA_ARGS__); } }
00173 #define TRACE_ERROR_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf(__VA_ARGS__); } }
00174 #define TRACE_FATAL_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf(__VA_ARGS__); while (1); } }
00175
00176 #else
00177
00178
00179 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
00180 #define TRACE_DEBUG(...) { printf("-D- " __VA_ARGS__); }
00181 #define TRACE_DEBUG_WP(...) { printf(__VA_ARGS__); }
00182 #else
00183 #define TRACE_DEBUG(...) { }
00184 #define TRACE_DEBUG_WP(...) { }
00185 #endif
00186
00187 #if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
00188 #define TRACE_INFO(...) { printf("-I- " __VA_ARGS__); }
00189 #define TRACE_INFO_WP(...) { printf(__VA_ARGS__); }
00190 #else
00191 #define TRACE_INFO(...) { }
00192 #define TRACE_INFO_WP(...) { }
00193 #endif
00194
00195 #if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)
00196 #define TRACE_WARNING(...) { printf("-W- " __VA_ARGS__); }
00197 #define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); }
00198 #else
00199 #define TRACE_WARNING(...) { }
00200 #define TRACE_WARNING_WP(...) { }
00201 #endif
00202
00203 #if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)
00204 #define TRACE_ERROR(...) { printf("-E- " __VA_ARGS__); }
00205 #define TRACE_ERROR_WP(...) { printf(__VA_ARGS__); }
00206 #else
00207 #define TRACE_ERROR(...) { }
00208 #define TRACE_ERROR_WP(...) { }
00209 #endif
00210
00211 #if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)
00212 #define TRACE_FATAL(...) { printf("-F- " __VA_ARGS__); while (1); }
00213 #define TRACE_FATAL_WP(...) { printf(__VA_ARGS__); while (1); }
00214 #else
00215 #define TRACE_FATAL(...) { while (1); }
00216 #define TRACE_FATAL_WP(...) { while (1); }
00217 #endif
00218
00219 #endif
00220
00221
00222
00223
00224
00225
00226 #if !defined(NOTRACE) && (DYN_TRACES == 1)
00227 extern uint32_t dwTraceLevel;
00228 #endif
00229
00230 #endif //#ifndef TRACE_H
00231