-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Debug.c
executable file
·79 lines (72 loc) · 2 KB
/
Debug.c
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
#include "Debug.h"
#include "DebugTrace.h"
#include "MT.h"
#include "OSAL.h"
#include "OSAL_Memory.h"
void vprint(const char *fmt, va_list argp) {
uint8 string[100];
if (0 < vsprintf((char *)string, fmt, argp)) // build string
{
LREPMaster(string);
}
}
#ifdef DO_DEBUG_UART
#ifndef UART_PORT
#define UART_PORT HAL_UART_PORT_0
#endif
bool DebugInit() {
halUARTCfg_t halUARTConfig;
halUARTConfig.configured = TRUE;
halUARTConfig.baudRate = HAL_UART_BR_115200;
halUARTConfig.flowControl = FALSE;
halUARTConfig.flowControlThreshold = 48; // this parameter indicates number of bytes left before Rx Buffer
// reaches maxRxBufSize
halUARTConfig.idleTimeout = 10; // this parameter indicates rx timeout period in millisecond
halUARTConfig.rx.maxBufSize = 0;
halUARTConfig.tx.maxBufSize = BUFFLEN;
halUARTConfig.intEnable = TRUE;
halUARTConfig.callBackFunc = NULL;
HalUARTInit();
if (HalUARTOpen(UART_PORT, &halUARTConfig) == HAL_UART_SUCCESS) {
LREPMaster("Initialized debug module \r\n");
return true;
}
return false;
}
void LREPMaster(uint8 *data) {
if (data == NULL) {
return;
}
HalUARTWrite(UART_PORT, data, osal_strlen((char *)data));
}
void LREP(char *format, ...) {
va_list argp;
va_start(argp, format);
vprint(format, argp);
va_end(argp);
}
#elif defined(DO_DEBUG_MT)
bool DebugInit() {
debugThreshold = 0x04; // increase threshold as soon as we initialize debug module
LREPMaster("Initialized debug module \r\n");
return TRUE;
}
void LREP(char *format, ...) {
va_list argp;
va_start(argp, format);
vprint(format, argp);
va_end(argp);
}
void LREPMaster(uint8 *data) { debug_str(data); }
#else
bool DebugInit() {return true;};
void LREP(char *format, ...) {
va_list argp;
va_start(argp, format);
printf(format, argp);
va_end(argp);
};
void LREPMaster(uint8 *data) {
printf((const char*)data);
};
#endif