]> rtime.felk.cvut.cz Git - arc.git/blob - include/debug.h
Merge branch 'mikulka' of git@rtime.felk.cvut.cz:arc into mikulka
[arc.git] / include / debug.h
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 \r
17 // PC-Lint Exception to MISRA rule 19.12: stdio ok in debug.h.\r
18 //lint -e(829)\r
19 \r
20 \r
21 #ifndef DEBUG_H_\r
22 #define DEBUG_H_\r
23 \r
24 /**\r
25  *\r
26  * NOTE!!!!\r
27  * Do not use this in a header file. Should be used in the *.c file like this.\r
28  *\r
29  * #define USE_DEBUG_PRINTF\r
30  * #include "debug.h"\r
31  *\r
32  * Macro's for debugging and tracing\r
33  *\r
34  * Define USE_LDEBUG_PRINTF and DBG_LEVEL either globally( e.g. a makefile )\r
35  * or in a specific file.  The DBG_LEVEL macro controls the amount\r
36  * of detail you want in the debug printout.\r
37  * There are 3 levels:\r
38  * DEBUG_LOW    - Used mainly by drivers to get very detailed\r
39  * DEBUG_MEDIUM - Medium detail\r
40  * DEBUG_HIGH   - General init\r
41  *\r
42  * Example:\r
43  * #define DEBUG_LVL    DEBUG_HIGH\r
44  * DEBUG(DEBUG_HIGH,"Starting GPT");\r
45  *\r
46  * TRACE\r
47  *   TODO:\r
48  *\r
49  */\r
50 \r
51 #include <stdio.h>\r
52 \r
53 #define DEBUG_LOW               1\r
54 #define DEBUG_MEDIUM    2\r
55 #define DEBUG_HIGH              3\r
56 #define DEBUG_NONE              4\r
57 \r
58 #ifndef DEBUG_LVL\r
59 #define DEBUG_LVL               2\r
60 #endif\r
61 \r
62 #define CH_ISR          0\r
63 #define CH_PROC         1\r
64 \r
65 \r
66 #if defined(USE_DEBUG_PRINTF)\r
67 #define DEBUG(_level,...) \\r
68         do { \\r
69                 if(_level>=DEBUG_LVL) { \\r
70                         printf (__VA_ARGS__); \\r
71                 }; \\r
72         } while(0);\r
73 \r
74 #else\r
75 #define DEBUG(_level,...)\r
76 #endif\r
77 \r
78 #if defined(USE_LDEBUG_PRINTF)\r
79 #define LDEBUG_PRINTF(format,...)       printf(format,## __VA_ARGS__ )\r
80 #define LDEBUG_FPUTS(_str)                      fputs((_str),stdout)\r
81 #else\r
82 #define LDEBUG_PRINTF(format,...)\r
83 #define LDEBUG_FPUTS(_str)\r
84 #endif\r
85 \r
86 \r
87 #endif /*DEBUG_H_*/\r