-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug.h
More file actions
81 lines (69 loc) · 2.45 KB
/
Copy pathdebug.h
File metadata and controls
81 lines (69 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
\file debug.h
\brief Macros for assisting debug of the peripheral library.
\version V0.0.3
\date 08/01/2014
\author Nelson Lombardo
*/
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include <stdio.h>
/**
\addtogroup Development_Tools
\brief Some APIs for make _easy_ the development with the
framework.
@{
*/
/**
\addtogroup Debug
\brief Provided some assert macros to help debug.
This module provides a macro called ASSERT, Used to assert
some conditions if is correct.
\section Debug_When When User the Debug feature?
- Verify the legitimacy of the parameters
- Judge execution of the accuracy of the results
- where you want to determine if actual == expected ?
\section Debug_How How to use the Debug Feature?
- Enable the debug feature by doing a DEBUG build.
- add the ASSERT where you want.
@{
*/
/**
\addtogroup Debug_Exported_APIs Debug API
\brief Debug API Reference.
@{
*/
/**
\brief Error Handler function.
This function can be used to print error file name and error line
number.
\param pcFilename is a string pointer point to error filename.
\param ulLine is the error line number.
\param ulFunc Function from error born.
\param ulParam Parameter with conflict (const).
\return None.
*/
extern void __xerror__(char *pcFilename, unsigned long ulLine, char *ulFunc, unsigned long ulParam);
/**
\brief The ASSERT macro.
It does the actual assertion checking. Typically, this will be for
procedure arguments.
\param [in] expr is the expression to be check and parameter with conflict.
\param param Is the number of conflict parameter.
*/
#ifdef DEBUG
#define ASSERT(expr, param) \
{ \
if(!(expr)) \
{ \
__xerror__(__FILE__, __LINE__, __FUNCTION__, param); \
} \
}
#else
// If wasn't define, then nothing to do here...
#define ASSERT(expr, param)
#endif
/** @} */
/** @} */
/** @} */
#endif // __DEBUG_H__