SAMV71 Xplained Ultra Software Package 1.5

sdmmc_trace.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- */
00002 /*                  Atmel Microcontroller Software Support                      */
00003 /*                       SAM Software Package License                           */
00004 /* ---------------------------------------------------------------------------- */
00005 /* Copyright (c) 2015, Atmel Corporation                                        */
00006 /*                                                                              */
00007 /* All rights reserved.                                                         */
00008 /*                                                                              */
00009 /* Redistribution and use in source and binary forms, with or without           */
00010 /* modification, are permitted provided that the following condition is met:    */
00011 /*                                                                              */
00012 /* - Redistributions of source code must retain the above copyright notice,     */
00013 /* this list of conditions and the disclaimer below.                            */
00014 /*                                                                              */
00015 /* Atmel's name may not be used to endorse or promote products derived from     */
00016 /* this software without specific prior written permission.                     */
00017 /*                                                                              */
00018 /* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
00028 /* ---------------------------------------------------------------------------- */
00029 
00030 /**
00031  *  \file
00032  *
00033  *  \par Purpose
00034  *
00035  *  Standard output methods for reporting debug information, warnings and
00036  *  errors, which can be easily be turned on/off by external value
00037  *  \ref dwTraceLevel.
00038  *
00039  *  \par Usage
00040  *  -# Initialize the debug message port in application, for stdio printf().
00041  *  -# Uses the TRACE_DEBUG(), TRACE_INFO(), TRACE_WARNING(), TRACE_ERROR()
00042  *     TRACE_FATAL() macros to output traces throughout the program.
00043  *  -# Each type of trace has a level : Debug 5, Info 4, Warning 3, Error 2
00044  *     and Fatal 1. Disable a group of traces by changing the value of
00045  *     TRACE_LEVEL during compilation; traces with a level bigger than TRACE_LEVEL
00046  *     are not generated. To generate no trace, use the reserved value 0.
00047  *  -# Trace disabling can be static or dynamic. If dynamic disabling is selected
00048  *     the trace level can be modified in runtime. If static disabling is selected
00049  *     the disabled traces are not compiled.
00050  *
00051  *  \par traceLevels Trace level description
00052  *  -# TRACE_DEBUG (5): Traces whose only purpose is for debugging the program,
00053  *     and which do not produce meaningful information otherwise.
00054  *  -# TRACE_INFO (4): Informational trace about the program execution. Should
00055  *     enable the user to see the execution flow.
00056  *  -# TRACE_WARNING (3): Indicates that a minor error has happened. In most case
00057  *     it can be discarded safely; it may even be expected.
00058  *  -# TRACE_ERROR (2): Indicates an error which may not stop the program execution,
00059  *     but which indicates there is a problem with the code.
00060  *  -# TRACE_FATAL (1): Indicates a major error which prevents the program from going
00061  *     any further.
00062  */
00063 
00064 #ifndef _SDMMC_TRACE_H
00065 #define _SDMMC_TRACE_H
00066 
00067 /*
00068  *         Headers
00069  */
00070 
00071 #include <stdio.h>
00072 
00073 /*
00074  *         Global Definitions
00075  */
00076 
00077 /**  Softpack Version */
00078 #define USBLIB_VERSION         "1.0"
00079 
00080 #define TRACE_LEVEL_DEBUG      5
00081 #define TRACE_LEVEL_INFO       4
00082 #define TRACE_LEVEL_WARNING    3
00083 #define TRACE_LEVEL_ERROR      2
00084 #define TRACE_LEVEL_FATAL      1
00085 #define TRACE_LEVEL_NO_TRACE   0
00086 
00087 /* By default, all traces are output except the debug one. */
00088 #if !defined(TRACE_LEVEL)
00089     #define TRACE_LEVEL TRACE_LEVEL_INFO
00090 #endif
00091 
00092 /* By default, trace level is static (not dynamic) */
00093 #if !defined(DYN_TRACES)
00094     #define DYN_TRACES 0
00095 #endif
00096 
00097 #if defined(NOTRACE)
00098     #define TRACE_LEVEL TRACE_LEVEL_NO_TRACE
00099 #endif
00100 
00101 #undef NOTRACE
00102 #if (DYN_TRACES==0)
00103     #if (TRACE_LEVEL == TRACE_LEVEL_NO_TRACE)
00104         #define NOTRACE
00105     #endif
00106 #endif
00107 
00108 
00109 
00110 /*
00111  *         Global Macros
00112  */
00113 
00114 #ifndef DYNTRACE
00115     #define DYNTRACE 0
00116 #endif
00117 
00118 
00119 /**
00120  *  Outputs a formatted string using 'printf' if the log level is high
00121  *  enough. Can be disabled by defining TRACE_LEVEL=0 during compilation.
00122  *  \param ...  Additional parameters depending on formatted string.
00123  */
00124 #if defined(NOTRACE)
00125 
00126     /* Empty macro */
00127     #define TRACE_DEBUG(...)      { }
00128     #define TRACE_INFO(...)       { }
00129     #define TRACE_WARNING(...)    { }
00130     #define TRACE_ERROR(...)      { }
00131     #define TRACE_FATAL(...)      { while (1); }
00132 
00133     #define TRACE_DEBUG_WP(...)   { }
00134     #define TRACE_INFO_WP(...)    { }
00135     #define TRACE_WARNING_WP(...) { }
00136     #define TRACE_ERROR_WP(...)   { }
00137     #define TRACE_FATAL_WP(...)   { while (1); }
00138 
00139 #elif (DYN_TRACES == 1)
00140 
00141     /* Trace output depends on dwTraceLevel value */
00142     #define TRACE_DEBUG(...)      { if (dwTraceLevel >= TRACE_LEVEL_DEBUG)   { printf("-D- " __VA_ARGS__); } }
00143     #define TRACE_INFO(...)       { if (dwTraceLevel >= TRACE_LEVEL_INFO)    { printf("-I- " __VA_ARGS__); } }
00144     #define TRACE_WARNING(...)    { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf("-W- " __VA_ARGS__); } }
00145     #define TRACE_ERROR(...)      { if (dwTraceLevel >= TRACE_LEVEL_ERROR)   { printf("-E- " __VA_ARGS__); } }
00146     #define TRACE_FATAL(...)      { if (dwTraceLevel >= TRACE_LEVEL_FATAL)   { printf("-F- " __VA_ARGS__); while (1); } }
00147 
00148     #define TRACE_DEBUG_WP(...)   { if (dwTraceLevel >= TRACE_LEVEL_DEBUG)   { printf(__VA_ARGS__); } }
00149     #define TRACE_INFO_WP(...)    { if (dwTraceLevel >= TRACE_LEVEL_INFO)    { printf(__VA_ARGS__); } }
00150     #define TRACE_WARNING_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf(__VA_ARGS__); } }
00151     #define TRACE_ERROR_WP(...)   { if (dwTraceLevel >= TRACE_LEVEL_ERROR)   { printf(__VA_ARGS__); } }
00152     #define TRACE_FATAL_WP(...)   { if (dwTraceLevel >= TRACE_LEVEL_FATAL)   { printf(__VA_ARGS__); while (1); } }
00153 
00154 #else
00155 
00156     /* Trace compilation depends on TRACE_LEVEL value */
00157     #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
00158         #define TRACE_DEBUG(...)      { printf("-D- " __VA_ARGS__); }
00159         #define TRACE_DEBUG_WP(...)   { printf(__VA_ARGS__); }
00160     #else
00161         #define TRACE_DEBUG(...)      { }
00162         #define TRACE_DEBUG_WP(...)   { }
00163     #endif
00164 
00165     #if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
00166         #define TRACE_INFO(...)       { printf("-I- " __VA_ARGS__); }
00167         #define TRACE_INFO_WP(...)    { printf(__VA_ARGS__); }
00168     #else
00169         #define TRACE_INFO(...)       { }
00170         #define TRACE_INFO_WP(...)    { }
00171     #endif
00172 
00173     #if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)
00174         #define TRACE_WARNING(...)    { printf("-W- " __VA_ARGS__); }
00175         #define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); }
00176     #else
00177         #define TRACE_WARNING(...)    { }
00178         #define TRACE_WARNING_WP(...) { }
00179     #endif
00180 
00181     #if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)
00182         #define TRACE_ERROR(...)      { printf("-E- " __VA_ARGS__); }
00183         #define TRACE_ERROR_WP(...)   { printf(__VA_ARGS__); }
00184     #else
00185         #define TRACE_ERROR(...)      { }
00186         #define TRACE_ERROR_WP(...)   { }
00187     #endif
00188 
00189     #if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)
00190         #define TRACE_FATAL(...)      { printf("-F- " __VA_ARGS__); while (1); }
00191         #define TRACE_FATAL_WP(...)   { printf(__VA_ARGS__); while (1); }
00192     #else
00193         #define TRACE_FATAL(...)      { while (1); }
00194         #define TRACE_FATAL_WP(...)   { while (1); }
00195     #endif
00196 
00197 #endif
00198 
00199 
00200 /**
00201  *        Exported variables
00202  */
00203 /** Depending on DYN_TRACES, dwTraceLevel is a modifable runtime variable or a define */
00204 #if !defined(NOTRACE) && (DYN_TRACES == 1)
00205     extern uint32_t dwTraceLevel;
00206 #endif
00207 
00208 #endif /* #define _SDMMC_TRACE_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines