Rev 254 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 254 | Rev 396 | ||
---|---|---|---|
1 | #ifndef _DEBUG_H |
1 | #ifndef _DEBUG_H |
2 | #define _DEBUG_H |
2 | #define _DEBUG_H |
3 | // ---------------------------------------------- |
3 | // ---------------------------------------------- |
4 | #define CMD_NONE 0x00 |
4 | #define CMD_NONE 0x00 |
5 | #define CMD_RAW_OUTPUT 0x01 |
5 | #define CMD_RAW_OUTPUT 0x01 |
6 | #define CMD_ERROR_MSG 0x02 |
6 | #define CMD_ERROR_MSG 0x02 |
7 | #define CMD_WARNING_MSG 0x04 |
7 | #define CMD_WARNING_MSG 0x04 |
8 | #define CMD_GREEN_MSG 0x08 |
8 | #define CMD_GREEN_MSG 0x08 |
9 | 9 | ||
10 | // debug console in MK-Tool can also handle ANSI ESC seq. |
10 | // debug console in MK-Tool can also handle ANSI ESC seq. |
11 | #define ANSI_ATTRIBUTE_OFF "\033[0m" |
11 | #define ANSI_ATTRIBUTE_OFF "\033[0m" |
12 | #define ANSI_BOLD "\033[1m" |
12 | #define ANSI_BOLD "\033[1m" |
13 | #define ANSI_UNDERSCORE "\033[4m" |
13 | #define ANSI_UNDERSCORE "\033[4m" |
14 | #define ANSI_BLINK "\033[5m" |
14 | #define ANSI_BLINK "\033[5m" |
15 | #define ANSI_INVERSE "\033[7m" |
15 | #define ANSI_INVERSE "\033[7m" |
16 | #define ANSI_INVISIBLE "\033[8m" |
16 | #define ANSI_INVISIBLE "\033[8m" |
17 | 17 | ||
18 | #define ANSI_COLOR_BLACK "\033[30m" |
18 | #define ANSI_COLOR_BLACK "\033[30m" |
19 | #define ANSI_COLOR_RED "\033[31m" |
19 | #define ANSI_COLOR_RED "\033[31m" |
20 | #define ANSI_COLOR_GREEN "\033[32m" |
20 | #define ANSI_COLOR_GREEN "\033[32m" |
21 | #define ANSI_COLOR_YELLOW "\033[33m" |
21 | #define ANSI_COLOR_YELLOW "\033[33m" |
22 | #define ANSI_COLOR_BLUE "\033[34m" |
22 | #define ANSI_COLOR_BLUE "\033[34m" |
23 | #define ANSI_COLOR_VIOLETT "\033[35m" |
23 | #define ANSI_COLOR_VIOLETT "\033[35m" |
24 | #define ANSI_COLOR_KOBALTBLUE "\033[36m" |
24 | #define ANSI_COLOR_KOBALTBLUE "\033[36m" |
25 | #define ANSI_COLOR_WHITE "\033[37m" |
25 | #define ANSI_COLOR_WHITE "\033[37m" |
26 | 26 | ||
27 | #define ANSI_CLEAR "\033[2J" |
27 | #define ANSI_CLEAR "\033[2J" |
28 | #define ANSI_HOME "\033[H" |
28 | #define ANSI_HOME "\033[H" |
29 | 29 | ||
30 | // macros for easier use |
30 | // macros for easier use |
- | 31 | ||
- | 32 | extern void Backtrace(void* fp); |
|
- | 33 | ||
31 | #ifdef DEBUG |
34 | #ifdef DEBUG |
32 | #include "printf_P.h" // only include functions if DEBUG is defined in main.h |
35 | #include "printf_P.h" // only include functions if DEBUG is defined in main.h |
33 | 36 | ||
34 | #define Debug(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_NONE); } |
37 | #define Debug(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_NONE); } |
35 | #define Debug_Raw(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_RAW_OUTPUT); } |
38 | #define Debug_Raw(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_RAW_OUTPUT); } |
36 | #define Debug_Warning(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_WARNING_MSG); } |
39 | #define Debug_Warning(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_WARNING_MSG); } |
37 | #define Debug_Error(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_ERROR_MSG); } |
40 | #define Debug_Error(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_ERROR_MSG); } |
38 | #define Debug_OK(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_GREEN_MSG); } |
41 | #define Debug_OK(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_GREEN_MSG); } |
39 | 42 | ||
40 | typedef struct |
43 | typedef struct |
41 | { |
44 | { |
42 | u8 Cmd; // bitcoded command |
45 | u8 Cmd; // bitcoded command |
43 | u8 Text[32]; |
46 | u8 Text[32]; |
44 | } __attribute__((packed)) Debug_t; |
47 | } __attribute__((packed)) Debug_t; |
45 | 48 | ||
46 | extern Debug_t tDebug; |
49 | extern Debug_t tDebug; |
47 | extern u8 SendDebugOutput; |
50 | extern u8 SendDebugOutput; |
48 | 51 | ||
49 | void Debug_Putchar(char c); |
52 | void Debug_Putchar(char c); |
50 | void DebugSend(unsigned char cmd); |
53 | void DebugSend(unsigned char cmd); |
51 | 54 | ||
52 | #else // dummy macros (won't waste flash, if #DEBUG is disabled) |
55 | #else // dummy macros (won't waste flash, if #DEBUG is disabled) |
53 | #define Debug(format, args...) ; |
56 | #define Debug(format, args...) ; |
54 | #define Debug_Raw(format, args...) ; |
57 | #define Debug_Raw(format, args...) ; |
55 | #define Debug_Warning(format, args...) ; |
58 | #define Debug_Warning(format, args...) ; |
56 | #define Debug_Error(format, args...) ; |
59 | #define Debug_Error(format, args...) ; |
57 | #define Debug_OK(format, args...) ; |
60 | #define Debug_OK(format, args...) ; |
58 | #endif |
61 | #endif |
59 | 62 | ||
60 | // ---------------------------------------------- |
63 | // ---------------------------------------------- |
61 | #endif |
64 | #endif |
62 | 65 |