OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [Atmel/] [at91lib/] [utility/] [trace.h] - Blame information for rev 608

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.