-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsegger_wrapper_arm.h
112 lines (93 loc) · 3.88 KB
/
segger_wrapper_arm.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* segger_wrapper.h
*
* Created on: 5 oct. 2017
* Author: Vincent
*/
#ifndef LIBRARIES_UTILS_SEGGER_WRAPPER_ARM_H_
#define LIBRARIES_UTILS_SEGGER_WRAPPER_ARM_H_
#include "nrf_log.h"
#include <stddef.h>
///////// PARAMETERS
#ifndef USE_VCOM_LOGS
#define USE_VCOM_LOGS 0
#endif
#ifndef USE_SVIEW
#define USE_SVIEW 0
#endif
#ifndef NRF_LOG_BACKEND_RTT_ENABLED
#define NRF_LOG_BACKEND_RTT_ENABLED 1
#endif
#if USE_SVIEW
#include "SEGGER_SYSVIEW.h"
#endif
///////// DEFINES
#define RTT_LOG_CHANNEL 0
#if USE_SVIEW
#ifdef USB_ENABLED
#include "usb_cdc.h"
#define LOG_INFO(...) usb_printf(__VA_ARGS__)
#else // USDB_ENABLED
#define LOG_INFO(...) EMPTY_MACRO
#endif // USDB_ENABLED
#define LOG_RAW_INFO(...) EMPTY_MACRO
#define LOG_DEBUG(...) EMPTY_MACRO
//#define LOG_ERROR(...) SEGGER_SYSVIEW_ErrorfHost(__VA_ARGS__)
#define LOG_WARNING(...) SEGGER_SYSVIEW_WarnfHost(__VA_ARGS__)
#define LOG_ERROR(...) SEGGER_SYSVIEW_PrintfHost(__VA_ARGS__)
#define LOG_FLUSH(...) EMPTY_MACRO
#define LOG_SET_TERM(X) EMPTY_MACRO
#define SVIEW_INIT(...) segger_init()
#elif USE_VCOM_LOGS
#include "usb_cdc.h"
#define LOG_INFO(...) usb_printf(__VA_ARGS__)
#define LOG_RAW_INFO(...) usb_print(X)
#define LOG_WARNING(...) usb_printf(__VA_ARGS__)
#define LOG_DEBUG(...) EMPTY_MACRO
#define LOG_ERROR(...) usb_printf(__VA_ARGS__)
#define LOG_GRAPH(...) EMPTY_MACRO
#define LOG_FLUSH(...) usb_flush();
#define LOG_SET_TERM(X) EMPTY_MACRO
#define USB_PRINTF(...) usb_printf(__VA_ARGS__)
#define USB_PRINT(X) usb_print(X)
#define SVIEW_INIT(...) EMPTY_MACRO
//#undef NRF_LOG_BACKEND_RTT_ENABLED
//#define NRF_LOG_BACKEND_RTT_ENABLED 0
#elif NRF_LOG_ENABLED
#include "SEGGER_RTT.h"
#define LOG_INFO(...) SEGGER_RTT_printf(0, __VA_ARGS__);SEGGER_RTT_PutChar(0, '\r');SEGGER_RTT_PutChar(0, '\n')
#define LOG_RAW_INFO(...) EMPTY_MACRO
#define LOG_WARNING(...) SEGGER_RTT_printf(0, __VA_ARGS__);SEGGER_RTT_PutChar(0, '\r');SEGGER_RTT_PutChar(0, '\n')
#define LOG_DEBUG(...) EMPTY_MACRO
#define LOG_ERROR(...) SEGGER_RTT_printf(0, __VA_ARGS__);SEGGER_RTT_PutChar(0, '\r');SEGGER_RTT_PutChar(0, '\n')
#define LOG_GRAPH(...) EMPTY_MACRO
#define LOG_FLUSH(...) EMPTY_MACRO
#define LOG_SET_TERM(X) EMPTY_MACRO
#define SVIEW_INIT(...) EMPTY_MACRO
#define USB_PRINTF(...) EMPTY_MACRO
#define USB_PRINT(...) EMPTY_MACRO
#else
#define LOG_INFO(...) EMPTY_MACRO
#define LOG_RAW_INFO(...) EMPTY_MACRO
#define LOG_WARNING(...) EMPTY_MACRO
#define LOG_DEBUG(...) EMPTY_MACRO
#define LOG_ERROR(...) EMPTY_MACRO
#define LOG_GRAPH(...) EMPTY_MACRO
#define LOG_FLUSH(...) EMPTY_MACRO
#define LOG_SET_TERM(X) EMPTY_MACRO
#define SVIEW_INIT(...) EMPTY_MACRO
#endif
#if USE_SVIEW
#define W_SYSVIEW_RecordEnterISR(...) SEGGER_SYSVIEW_RecordEnterISR()
#define W_SYSVIEW_RecordExitISR(...) SEGGER_SYSVIEW_RecordExitISR()
#define W_SYSVIEW_OnTaskCreate(X) SEGGER_SYSVIEW_OnTaskCreate(X)
#else
#define W_SYSVIEW_RecordEnterISR(...) EMPTY_MACRO
#define W_SYSVIEW_RecordExitISR(...) EMPTY_MACRO
#define W_SYSVIEW_OnTaskCreate(X) EMPTY_MACRO
#endif
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#include "task_manager_wrapper.h"
#endif /* LIBRARIES_UTILS_SEGGER_WRAPPER_H_ */