Statistics
| Branch: | Tag: | Revision:

amiro-os / core / inc / aos_debug.h @ 2a9f9ad7

History | View | Annotate | Download (5.226 KB)

1 e545e620 Thomas Schöpping
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3 84f0ce9e Thomas Schöpping
Copyright (C) 2016..2019  Thomas Schöpping et al.
4 e545e620 Thomas Schöpping

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 53710ca3 Marc Rothmann
/**
20
 * @file    aos_debug.h
21
 * @brief   Macros used for debugging.
22
 *
23
 * @addtogroup aos_debug
24
 * @{
25
 */
26
27 6ff06bbf Thomas Schöpping
#ifndef AMIROOS_DEBUG_H
28
#define AMIROOS_DEBUG_H
29 e545e620 Thomas Schöpping
30 3940ba8a Thomas Schöpping
#include <amiroos.h>
31
32 f3ac1c96 Thomas Schöpping
/******************************************************************************/
33
/* CONSTANTS                                                                  */
34
/******************************************************************************/
35
36
/******************************************************************************/
37
/* SETTINGS                                                                   */
38
/******************************************************************************/
39
40
/******************************************************************************/
41
/* CHECKS                                                                     */
42
/******************************************************************************/
43
44
/******************************************************************************/
45
/* DATA STRUCTURES AND TYPES                                                  */
46
/******************************************************************************/
47
48
/******************************************************************************/
49
/* MACROS                                                                     */
50
/******************************************************************************/
51 e545e620 Thomas Schöpping
52
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
53
54
/**
55 f3ac1c96 Thomas Schöpping
 * @brief   Printf function for messages only printed in debug builds.
56
 *
57
 * @param[in] fmt   Formatted string to print.
58
 */
59
#define aosDbgPrintf(fmt, ...)        aosprintf(fmt, ##__VA_ARGS__)
60
61
/**
62 e545e620 Thomas Schöpping
 * @brief   Function parameters check.
63 9487b4cd Thomas Schöpping
 * @details If the condition check fails, the thread complains and exits.
64 e545e620 Thomas Schöpping
 *
65
 * @param[in] c The condition to be verified to be true.
66
 */
67 9487b4cd Thomas Schöpping
#define aosDbgCheck(c) {                                                      \
68
  if (!(c)) {                                                                 \
69
    aosDbgPrintf("%s(%u): aosDbgCheck failed", __FILE__, __LINE__);           \
70
    chThdExit(MSG_RESET);                                                     \
71
  }                                                                           \
72
}
73 e545e620 Thomas Schöpping
74
/**
75
 * @brief   Condition assertion.
76 9487b4cd Thomas Schöpping
 * @details If the condition check fails, the thread complains and exits.
77 e545e620 Thomas Schöpping
 *
78
 * @param[in] c The condition to be verified to be true.
79
 */
80 9487b4cd Thomas Schöpping
#define aosDbgAssert(c) {                                                     \
81
  if (!(c)) {                                                                 \
82
    aosDbgPrintf("%s(%u): aosDbgAssert failed", __FILE__, __LINE__);          \
83
    chThdExit(MSG_RESET);                                                     \
84
  }                                                                           \
85
}
86 e545e620 Thomas Schöpping
87
/**
88
 * @brief   Condition assertion.
89 9487b4cd Thomas Schöpping
 * @details If the condition check fails, the thread complains and exits.
90 e545e620 Thomas Schöpping
 *
91
 * @param[in] c The condition to be verified to be true.
92
 * @param[in] r A custom remark string.
93
 */
94 9487b4cd Thomas Schöpping
#define aosDbgAssertMsg(c, fmt, ...) {                                        \
95
  if (!(c)) {                                                                 \
96
    aosDbgPrintf(fmt, ##__VA_ARGS__);                                         \
97
    chThdExit(MSG_RESET);                                                     \
98
  }                                                                           \
99 e545e620 Thomas Schöpping
}
100
101 7de0cc90 Thomas Schöpping
#else /* (AMIROOS_CFG_DBG == true) */
102 e545e620 Thomas Schöpping
103 f3ac1c96 Thomas Schöpping
#define aosDbgPrintf(fmt, ...) {                          \
104
  (void)(fmt);                                            \
105
}
106
107 e545e620 Thomas Schöpping
#define aosDbgCheck(c) {                                  \
108
  (void)(c);                                              \
109
  }
110
111
#define aosDbgAssert(c) {                                 \
112
  (void)(c);                                              \
113
}
114
115
#define aosDbgAssertMsg(c, r) {                           \
116
  (void)(c);                                              \
117
  (void)(r);                                              \
118
}
119
120 7de0cc90 Thomas Schöpping
#endif /* (AMIROOS_CFG_DBG == true) */
121 f3ac1c96 Thomas Schöpping
122
/******************************************************************************/
123
/* EXTERN DECLARATIONS                                                        */
124
/******************************************************************************/
125 933df08e Thomas Schöpping
126 f3ac1c96 Thomas Schöpping
/******************************************************************************/
127
/* INLINE FUNCTIONS                                                           */
128
/******************************************************************************/
129 e545e620 Thomas Schöpping
130 6ff06bbf Thomas Schöpping
#endif /* AMIROOS_DEBUG_H */
131 53710ca3 Marc Rothmann
132
/** @} */