Statistics
| Branch: | Tag: | Revision:

amiro-os / core / inc / aos_debug.h @ 691a0632

History | View | Annotate | Download (4.539 KB)

1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  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
/**
20
 * @file    aos_debug.h
21
 * @brief   Macros used for debugging.
22
 *
23
 * @addtogroup aos_debug
24
 * @{
25
 */
26

    
27
#ifndef AMIROOS_DEBUG_H
28
#define AMIROOS_DEBUG_H
29

    
30
#include <amiroos.h>
31

    
32
/******************************************************************************/
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

    
52
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
53

    
54
/**
55
 * @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
 * @brief   Function parameters check.
63
 * @details If the condition check fails, the kernel panics and halts.
64
 *
65
 * @param[in] c The condition to be verified to be true.
66
 */
67
#define aosDbgCheck(c)                chDbgCheck(c)
68

    
69
/**
70
 * @brief   Condition assertion.
71
 * @details If the condition check fails, the kernel panics with a message and halts.
72
 * @note    As a limitation of ChibiOS, the remark string is not currently used.
73
 *
74
 * @param[in] c The condition to be verified to be true.
75
 */
76
#define aosDbgAssert(c)               chDbgAssert(c, "__FILE__(__LINE__): aosDbgAssert failed")
77

    
78
/**
79
 * @brief   Condition assertion.
80
 * @details If the condition check fails, the kernel panics with a message and halts.
81
 * @note    As a limitation of ChibiOS, the remark string is not currently used.
82
 *
83
 * @param[in] c The condition to be verified to be true.
84
 * @param[in] r A custom remark string.
85
 */
86
#define aosDbgAssertMsg(c, r) {                           \
87
  (void)r;                                                \
88
  chDbgAssert(c, r);                                      \
89
}
90

    
91
#else /* (AMIROOS_CFG_DBG != true) */
92

    
93
#define aosDbgPrintf(fmt, ...) {                          \
94
  (void)(fmt);                                            \
95
}
96

    
97
#define aosDbgCheck(c) {                                  \
98
  (void)(c);                                              \
99
  }
100

    
101
#define aosDbgAssert(c) {                                 \
102
  (void)(c);                                              \
103
}
104

    
105
#define aosDbgAssertMsg(c, r) {                           \
106
  (void)(c);                                              \
107
  (void)(r);                                              \
108
}
109

    
110
#endif /* AMIROOS_CFG_DBG */
111

    
112
/******************************************************************************/
113
/* EXTERN DECLARATIONS                                                        */
114
/******************************************************************************/
115

    
116
/******************************************************************************/
117
/* INLINE FUNCTIONS                                                           */
118
/******************************************************************************/
119

    
120
#endif /* AMIROOS_DEBUG_H */
121

    
122
/** @} */