Statistics
| Branch: | Tag: | Revision:

amiro-os / core / inc / aos_debug.h @ 6ff06bbf

History | View | Annotate | Download (2.924 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
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
35

    
36
/**
37
 * @brief   Function parameters check.
38
 * @details If the condition check fails, the kernel panics and halts.
39
 *
40
 * @param[in] c The condition to be verified to be true.
41
 */
42
#define aosDbgCheck(c)                chDbgCheck(c)
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
 */
51
#define aosDbgAssert(c)               chDbgAssert(c, "__FILE__(__LINE__): aosDbgAssert failed")
52

    
53
/**
54
 * @brief   Condition assertion.
55
 * @details If the condition check fails, the kernel panics with a message and halts.
56
 * @note    As a limitation of ChibiOS, the remark string is not currently used.
57
 *
58
 * @param[in] c The condition to be verified to be true.
59
 * @param[in] r A custom remark string.
60
 */
61
#define aosDbgAssertMsg(c, r) {                           \
62
  (void)r;                                                \
63
  chDbgAssert(c, r);                                      \
64
}
65

    
66
/**
67
 * @brief   Printf function for messages only printed in debug builds.
68
 *
69
 * @param[in] fmt   Formatted string to print.
70
 */
71
#define aosDbgPrintf(fmt, ...)        chprintf((BaseSequentialStream*)&aos.iostream, fmt, ##__VA_ARGS__)
72

    
73
#else /* (AMIROOS_CFG_DBG != true) */
74

    
75
#define aosDbgCheck(c) {                                  \
76
  (void)(c);                                              \
77
  }
78

    
79
#define aosDbgAssert(c) {                                 \
80
  (void)(c);                                              \
81
}
82

    
83
#define aosDbgAssertMsg(c, r) {                           \
84
  (void)(c);                                              \
85
  (void)(r);                                              \
86
}
87

    
88
#define aosDbgPrintf(fmt, ...) {                          \
89
  (void)(fmt);                                            \
90
}
91

    
92
#endif
93

    
94
#endif /* AMIROOS_DEBUG_H */
95

    
96
/** @} */