]> rtime.felk.cvut.cz Git - arc.git/blob - include/debug.h
Converted all line endings to Windows (CR LF)
[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 \r
18 #ifndef DEBUG_H_\r
19 #define DEBUG_H_\r
20 \r
21 \r
22 /**\r
23  *\r
24  * NOTE!!!!\r
25  * Do not use this in a header file. Should be used in the *.c file like this.\r
26  *\r
27  * #define USE_DEBUG_PRINTF\r
28  * #include "debug.h"\r
29  *\r
30  * Macro's for debugging and tracing\r
31  *\r
32  * Define USE_LDEBUG_PRINTF and DBG_LEVEL either globally( e.g. a makefile )\r
33  * or in a specific file.  The DBG_LEVEL macro controls the amount\r
34  * of detail you want in the debug printout.\r
35  * There are 3 levels:\r
36  * DEBUG_LOW    - Used mainly by drivers to get very detailed\r
37  * DEBUG_MEDIUM - Medium detail\r
38  * DEBUG_HIGH   - General init\r
39  *\r
40  * Example:\r
41  * #define DEBUG_LVL    DEBUG_HIGH\r
42  * DEBUG(DEBUG_HIGH,"Starting GPT");\r
43  *\r
44  * TRACE\r
45  *   TODO:\r
46  *\r
47  */\r
48 \r
49 #include <stdio.h>\r
50 \r
51 #define DEBUG_LOW               1\r
52 #define DEBUG_MEDIUM    2\r
53 #define DEBUG_HIGH              3\r
54 \r
55 #ifndef DEBUG_LVL\r
56 #define DEBUG_LVL               2\r
57 #endif\r
58 \r
59 #define CH_ISR          0\r
60 #define CH_PROC         1\r
61 \r
62 \r
63 #if defined(USE_DEBUG_PRINTF)\r
64 #define DEBUG(_level,...) \\r
65         do { \\r
66                 if(_level>=DEBUG_LVL) { \\r
67                         printf (__VA_ARGS__); \\r
68                 }; \\r
69         } while(0);\r
70 \r
71 #else\r
72 #define DEBUG(_level,...)\r
73 #endif\r
74 \r
75 #if defined(USE_LDEBUG_PRINTF)\r
76 #define LDEBUG_PRINTF(format,...) printf(format,## __VA_ARGS__ )\r
77 #else\r
78 #define LDEBUG_PRINTF(format,...)\r
79 #endif\r
80 \r
81 \r
82 #endif /*DEBUG_H_*/\r