amiro-os / os / core / inc / aos_debug.h @ 3e1a9c79
History | View | Annotate | Download (2.911 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | Copyright (C) 2016..2018 Thomas Schöpping et al.
|
||
4 | |||
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | it under the terms of the GNU General Public License as published by
|
||
7 | the Free Software Foundation, either version 3 of the License, or
|
||
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | GNU General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | #ifndef _AMIROOS_DEBUG_H_
|
||
20 | #define _AMIROOS_DEBUG_H_
|
||
21 | |||
22 | #include <aosconf.h> |
||
23 | #include <ch.h> |
||
24 | |||
25 | #if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__) |
||
26 | |||
27 | /**
|
||
28 | * @brief Function parameters check.
|
||
29 | * @details If the condition check fails, the kernel panics and halts.
|
||
30 | *
|
||
31 | * @param[in] c The condition to be verified to be true.
|
||
32 | */
|
||
33 | #define aosDbgCheck(c) chDbgCheck(c)
|
||
34 | |||
35 | /**
|
||
36 | * @brief Condition assertion.
|
||
37 | * @details If the condition check fails, the kernel panics with a message and halts.
|
||
38 | * @note As a limitation of ChibiOS, the remark string is not currently used.
|
||
39 | *
|
||
40 | * @param[in] c The condition to be verified to be true.
|
||
41 | */
|
||
42 | #define aosDbgAssert(c) chDbgAssert(c, "__FILE__(__LINE__): aosDbgAssert failed") |
||
43 | |||
44 | /**
|
||
45 | * @brief Condition assertion.
|
||
46 | * @details If the condition check fails, the kernel panics with a message and halts.
|
||
47 | * @note As a limitation of ChibiOS, the remark string is not currently used.
|
||
48 | *
|
||
49 | * @param[in] c The condition to be verified to be true.
|
||
50 | * @param[in] r A custom remark string.
|
||
51 | */
|
||
52 | #define aosDbgAssertMsg(c, r) { \
|
||
53 | (void)r; \
|
||
54 | chDbgAssert(c, r); \ |
||
55 | } |
||
56 | |||
57 | 933df08e | Thomas Schöpping | /**
|
58 | * @brief Printf function for messages only printed in debug builds.
|
||
59 | *
|
||
60 | * @param[in] fmt Formatted string to print.
|
||
61 | */
|
||
62 | #define aosDbgPrintf(fmt, ...) chprintf((BaseSequentialStream*)&aos.iostream, fmt, ##__VA_ARGS__) |
||
63 | |||
64 | 3e1a9c79 | Thomas Schöpping | #else /* (AMIROOS_CFG_DBG != true) */ |
65 | e545e620 | Thomas Schöpping | |
66 | #define aosDbgCheck(c) { \
|
||
67 | (void)(c); \
|
||
68 | } |
||
69 | |||
70 | #define aosDbgAssert(c) { \
|
||
71 | (void)(c); \
|
||
72 | } |
||
73 | |||
74 | #define aosDbgAssertMsg(c, r) { \
|
||
75 | (void)(c); \
|
||
76 | (void)(r); \
|
||
77 | } |
||
78 | |||
79 | 933df08e | Thomas Schöpping | #define aosDbgPrintf(fmt, ...) { \
|
80 | (void)(fmt); \
|
||
81 | } |
||
82 | |||
83 | e545e620 | Thomas Schöpping | #endif
|
84 | |||
85 | #ifdef __cplusplus
|
||
86 | extern "C" { |
||
87 | #endif
|
||
88 | void aosPrintHaltErrorCode(const char* reason); |
||
89 | #ifdef __cplusplus
|
||
90 | } |
||
91 | #endif
|
||
92 | |||
93 | #endif /* _AMIROOS_DEBUG_H_ */ |