Statistics
| Branch: | Tag: | Revision:

amiro-os / core / inc / aos_debug.h @ f3ac1c96

History | View | Annotate | Download (4.576 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 <aosconf.h>
31
#include <hal.h>
32
#include <chprintf.h>
33
/******************************************************************************/
34
/* CONSTANTS                                                                  */
35
/******************************************************************************/
36

    
37
/******************************************************************************/
38
/* SETTINGS                                                                   */
39
/******************************************************************************/
40

    
41
/******************************************************************************/
42
/* CHECKS                                                                     */
43
/******************************************************************************/
44

    
45
/******************************************************************************/
46
/* DATA STRUCTURES AND TYPES                                                  */
47
/******************************************************************************/
48

    
49
/******************************************************************************/
50
/* MACROS                                                                     */
51
/******************************************************************************/
52

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

    
55
/**
56
 * @brief   Printf function for messages only printed in debug builds.
57
 *
58
 * @param[in] fmt   Formatted string to print.
59
 */
60
#define aosDbgPrintf(fmt, ...)        aosprintf(fmt, ##__VA_ARGS__)
61

    
62
/**
63
 * @brief   Function parameters check.
64
 * @details If the condition check fails, the kernel panics and halts.
65
 *
66
 * @param[in] c The condition to be verified to be true.
67
 */
68
#define aosDbgCheck(c)                chDbgCheck(c)
69

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

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

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

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

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

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

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

    
111
#endif /* AMIROOS_CFG_DBG */
112

    
113
/******************************************************************************/
114
/* EXTERN DECLARATIONS                                                        */
115
/******************************************************************************/
116

    
117
/******************************************************************************/
118
/* INLINE FUNCTIONS                                                           */
119
/******************************************************************************/
120

    
121
#endif /* AMIROOS_DEBUG_H */
122

    
123
/** @} */