1 /* ----------------------------------------------------------------------------
\r
2 * ATMEL Microcontroller Software Support
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2008, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
34 Standard output methods for reporting debug information, warnings and
\r
35 errors, which can be turned on/off.
\r
38 1 - Initialize the DBGU using <trace_CONFIGURE>.
\r
39 2 - Uses the <trace_LOG> macro to output traces throughout the program.
\r
40 3 - Turn off all traces by defining the NOTRACE symbol during
\r
42 4 - Disable a group of trace by changing the value of <trace_LEVEL>
\r
43 during compilation; traces with a level below <trace_LEVEL> are not
\r
50 //------------------------------------------------------------------------------
\r
52 //------------------------------------------------------------------------------
\r
54 #if !defined(NOTRACE)
\r
56 #include <dbgu/dbgu.h>
\r
57 #include <pio/pio.h>
\r
61 //------------------------------------------------------------------------------
\r
63 //------------------------------------------------------------------------------
\r
65 Constants: Trace levels
\r
66 trace_FATAL - Indicates a major error which prevents the program from
\r
68 trace_ERROR - Indicates an error which may not stop the program
\r
69 execution, but which indicates there is a problem with the code.
\r
70 trace_WARNING - Indicates that a minor error has happened. In most case
\r
71 it can be discarded safely; it may even be expected.
\r
72 trace_INFO - Informational trace about the program execution. Should
\r
73 enable the user to see the execution flow.
\r
74 trace_DEBUG - Traces whose only purpose is for debugging the program,
\r
75 and which do not produce meaningful information otherwise.
\r
77 #define trace_DEBUG 0
\r
78 #define trace_INFO 1
\r
79 #define trace_WARNING 2
\r
80 #define trace_ERROR 3
\r
81 #define trace_FATAL 4
\r
84 Constant: trace_LEVEL
\r
85 Minimum level of traces that are output. By default, all traces are
\r
86 output; change the value of this symbol during compilation for a more
\r
87 restrictive behavior.
\r
89 #if !defined(trace_LEVEL)
\r
90 #define trace_LEVEL 0
\r
94 Macro: trace_CONFIGURE
\r
95 Initializes the DBGU unless the NOTRACE symbol has been defined.
\r
99 baudrate - DBGU baudrate.
\r
100 mck - Master clock frequency.
\r
102 #if !defined(NOTRACE)
\r
103 #define trace_CONFIGURE(mode, baudrate, mck) { \
\r
104 const Pin pinsDbgu[] = {PINS_DBGU}; \
\r
105 PIO_Configure(pinsDbgu, PIO_LISTSIZE(pinsDbgu)); \
\r
106 DBGU_Configure(mode, baudrate, mck); \
\r
109 #define trace_CONFIGURE(...)
\r
114 Outputs a formatted string using <printf> if the log level is high
\r
115 enough. Can be disabled by defining the NOTRACE symbol during
\r
119 level - Trace level (see <Trace levels>).
\r
120 format - Formatted string to output.
\r
121 ... - Additional parameters, depending on the formatted string.
\r
123 #if !defined(NOTRACE)
\r
124 #define trace_LOG(level, ...) { \
\r
125 if (level >= trace_LEVEL) { \
\r
126 printf(__VA_ARGS__); \
\r
130 #define trace_LOG(...)
\r
133 #endif //#ifndef TRACE_H
\r