USBLib_Trace.h
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------- */
2 /* Atmel Microcontroller Software Support */
3 /* SAM Software Package License */
4 /* ---------------------------------------------------------------------------- */
5 /* Copyright (c) 2015, Atmel Corporation */
6 /* */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without */
10 /* modification, are permitted provided that the following condition is met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, */
13 /* this list of conditions and the disclaimer below. */
14 /* */
15 /* Atmel's name may not be used to endorse or promote products derived from */
16 /* this software without specific prior written permission. */
17 /* */
18 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
19 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
21 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
22 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
24 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
25 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
26 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28 /* ---------------------------------------------------------------------------- */
29 
63 #ifndef _USBLIB_TRACE_H
64 #define _USBLIB_TRACE_H
65 
66 /*
67  * Headers
68  */
69 
70 #include "conf_stdio.h"
71 
72 /*
73  * Global Definitions
74  */
75 
77 #define USBLIB_VERSION "1.0"
78 
79 #define TRACE_LEVEL_DEBUG 5
80 #define TRACE_LEVEL_INFO 4
81 #define TRACE_LEVEL_WARNING 3
82 #define TRACE_LEVEL_ERROR 2
83 #define TRACE_LEVEL_FATAL 1
84 #define TRACE_LEVEL_NO_TRACE 0
85 
86 /* By default, all traces are output except the debug one. */
87 #if !defined(TRACE_LEVEL)
88 #define TRACE_LEVEL TRACE_LEVEL_INFO
89 #endif
90 
91 /* By default, trace level is static (not dynamic) */
92 #if !defined(DYN_TRACES)
93 #define DYN_TRACES 0
94 #endif
95 
96 #if defined(NOTRACE)
97 #error "Error: NOTRACE has to be not defined !"
98 #endif
99 
100 #undef NOTRACE
101 #if (DYN_TRACES==0)
102  #if (TRACE_LEVEL == TRACE_LEVEL_NO_TRACE)
103  #define NOTRACE
104  #endif
105 #endif
106 
107 
108 
109 /* ------------------------------------------------------------------------------
110  * Global Macros
111  * ------------------------------------------------------------------------------
112  */
113 
114 #ifndef DYNTRACE
115 #define DYNTRACE 0
116 #endif
117 
118 
124 #if defined(NOTRACE)
125 
126 /* Empty macro */
127 #define TRACE_DEBUG(...) { }
128 #define TRACE_INFO(...) { }
129 #define TRACE_WARNING(...) { }
130 #define TRACE_ERROR(...) { }
131 #define TRACE_FATAL(...) { while (1); }
132 
133 #define TRACE_DEBUG_WP(...) { }
134 #define TRACE_INFO_WP(...) { }
135 #define TRACE_WARNING_WP(...) { }
136 #define TRACE_ERROR_WP(...) { }
137 #define TRACE_FATAL_WP(...) { while (1); }
138 
139 #elif (DYN_TRACES == 1)
140 
141 /* Trace output depends on dwTraceLevel value */
142 #define TRACE_DEBUG(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf("-D- " __VA_ARGS__); } }
143 #define TRACE_INFO(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf("-I- " __VA_ARGS__); } }
144 #define TRACE_WARNING(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf("-W- " __VA_ARGS__); } }
145 #define TRACE_ERROR(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf("-E- " __VA_ARGS__); } }
146 #define TRACE_FATAL(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf("-F- " __VA_ARGS__); while (1); } }
147 
148 #define TRACE_DEBUG_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf(__VA_ARGS__); } }
149 #define TRACE_INFO_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf(__VA_ARGS__); } }
150 #define TRACE_WARNING_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf(__VA_ARGS__); } }
151 #define TRACE_ERROR_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf(__VA_ARGS__); } }
152 #define TRACE_FATAL_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf(__VA_ARGS__); while (1); } }
153 
154 #else
155 
156 /* Trace compilation depends on TRACE_LEVEL value */
157 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
158 #define TRACE_DEBUG(...) { printf("-D- " __VA_ARGS__); }
159 #define TRACE_DEBUG_WP(...) { printf(__VA_ARGS__); }
160 #else
161 #define TRACE_DEBUG(...) { }
162 #define TRACE_DEBUG_WP(...) { }
163 #endif
164 
165 #if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
166 #define TRACE_INFO(...) { printf("-I- " __VA_ARGS__); }
167 #define TRACE_INFO_WP(...) { printf(__VA_ARGS__); }
168 #else
169 #define TRACE_INFO(...) { }
170 #define TRACE_INFO_WP(...) { }
171 #endif
172 
173 #if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)
174 #define TRACE_WARNING(...) { printf("-W- " __VA_ARGS__); }
175 #define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); }
176 #else
177 #define TRACE_WARNING(...) { }
178 #define TRACE_WARNING_WP(...) { }
179 #endif
180 
181 #if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)
182 #define TRACE_ERROR(...) { printf("-E- " __VA_ARGS__); }
183 #define TRACE_ERROR_WP(...) { printf(__VA_ARGS__); }
184 #else
185 #define TRACE_ERROR(...) { }
186 #define TRACE_ERROR_WP(...) { }
187 #endif
188 
189 #if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)
190 #define TRACE_FATAL(...) { printf("-F- " __VA_ARGS__); while (1); }
191 #define TRACE_FATAL_WP(...) { printf(__VA_ARGS__); while (1); }
192 #else
193 #define TRACE_FATAL(...) { while (1); }
194 #define TRACE_FATAL_WP(...) { while (1); }
195 #endif
196 
197 #endif
198 
199 
204 #if !defined(NOTRACE) && (DYN_TRACES == 1)
205  extern uint32_t dwTraceLevel;
206 #endif
207 
208 #endif /* #ifndef _USBLIB_TRACE_H */
209 


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:05