-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.h
80 lines (59 loc) · 2.55 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
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
#ifndef UNFL_DEBUG_H
#define UNFL_DEBUG_H
/*********************************
Settings macros
*********************************/
// Settings
#define DEBUG_MODE 1 // Enable/Disable debug mode
#define USE_FAULTTHREAD 1 // Create a fault detection thread
#define OVERWRITE_OSPRINT 1 // Replaces osSyncPrintf calls with debug_printf
// Fault thread definitions
#define FAULT_THREAD_ID 13
#define FAULT_THREAD_PRI 251
#define FAULT_THREAD_STACK 0x2000
/*********************************
Debug Functions
*********************************/
#if DEBUG_MODE
/*==============================
debug_initialize
Initializes the debug and USB library
==============================*/
extern void debug_initialize();
/*==============================
debug_printf
Prints a formatted message to the developer's command prompt.
Supports up to 256 characters.
@param A string to print
@param variadic arguments to print as well
==============================*/
extern void debug_printf(const char* message, ...);
/*==============================
debug_screenshot
Sends the currently displayed framebuffer through USB.
Does not pause the drawing thread!
@param The size of each pixel of the framebuffer in bytes
Typically 4 if 32-bit or 2 if 16-bit
@param The width of the framebuffer
@param The height of the framebuffer
==============================*/
extern void debug_screenshot(int size, int w, int h);
/*==============================
debug_assert
Halts the program if the expression fails
@param The expression to test
==============================*/
#define debug_assert(expr) (expr) ? ((void)0) : _debug_assert(#expr, __FILE__, __LINE__)
// Ignore this, use the macro instead
extern void _debug_assert(const char* expression, const char* file, int line);
// Include usb.h automatically
#include "usb.h"
#else
#define debug_initialize()
#define debug_printf(__VA_ARGS__)
#define debug_screenshot(a, b, c)
#define debug_assert(a)
#define usb_write(a, b, c)
#define usb_read() 0
#endif
#endif