-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathdebug.h
50 lines (40 loc) · 1.17 KB
/
debug.h
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
/*
* Copyright (C) 2006 Microchip Technology Inc. and its subsidiaries
*
* SPDX-License-Identifier: MIT
*/
#ifndef __DEBUG_H__
#define __DEBUG_H__
#define DEBUG_INFO 1
#define DEBUG_LOUD 2
#define DEBUG_VERY_LOUD 4
#define DUMP_WIDTH_BIT_8 1
#define DUMP_WIDTH_BIT_32 2
#ifdef CONFIG_DEBUG
extern int dbg_printf(const char *fmt_str, ...);
extern void dbg_hexdump(const unsigned char *buf,
unsigned int size, unsigned int width);
#else
#define BOOTSTRAP_DEBUG_LEVEL 0
#include "usart.h"
static inline int dbg_printf(const char *fmt_str, ...)
{
usart_puts(fmt_str);
return 0;
}
static inline void dbg_hexdump(const unsigned char *buf,
unsigned int size, unsigned int width) { }
#endif
#define console_printf(fmt_str, args...) \
dbg_printf(fmt_str , ## args)
#define dbg_log(level, fmt_str, args...) \
({ \
(level) <= BOOTSTRAP_DEBUG_LEVEL ? dbg_printf((fmt_str), ##args) : 0; \
})
#define dbg_info(fmt_str, arg...) \
dbg_log(DEBUG_INFO, fmt_str , ## arg)
#define dbg_loud(fmt_str, arg...) \
dbg_log(DEBUG_LOUD, fmt_str , ## arg)
#define dbg_very_loud(fmt_str, arg...) \
dbg_log(DEBUG_VERY_LOUD, fmt_str , ## arg)
#endif /* #ifndef __DEBUG_H__ */