systemview
1.3.1
systemview
bsp
thirdparty
systemview
inc
SEGGER_RTT_configuration.h
1
/*********************************************************************
2
* SEGGER Microcontroller GmbH & Co. KG *
3
* The Embedded Experts *
4
**********************************************************************
5
* *
6
* (c) 2015 - 2017 SEGGER Microcontroller GmbH & Co. KG *
7
* *
8
* www.segger.com Support: support@segger.com *
9
* *
10
**********************************************************************
11
* *
12
* SEGGER SystemView * Real-time application analysis *
13
* *
14
**********************************************************************
15
* *
16
* All rights reserved. *
17
* *
18
* SEGGER strongly recommends to not make any changes *
19
* to or modify the source code of this software in order to stay *
20
* compatible with the RTT protocol and J-Link. *
21
* *
22
* Redistribution and use in source and binary forms, with or *
23
* without modification, are permitted provided that the following *
24
* conditions are met: *
25
* *
26
* o Redistributions of source code must retain the above copyright *
27
* notice, this list of conditions and the following disclaimer. *
28
* *
29
* o Redistributions in binary form must reproduce the above *
30
* copyright notice, this list of conditions and the following *
31
* disclaimer in the documentation and/or other materials provided *
32
* with the distribution. *
33
* *
34
* o Neither the name of SEGGER Microcontroller GmbH & Co. KG *
35
* nor the names of its contributors may be used to endorse or *
36
* promote products derived from this software without specific *
37
* prior written permission. *
38
* *
39
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
40
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
41
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
42
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
43
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
44
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
45
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
46
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
47
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
48
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
49
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
50
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
51
* DAMAGE. *
52
* *
53
**********************************************************************
54
* *
55
* SystemView version: V2.52a *
56
* *
57
**********************************************************************
58
---------------------------END-OF-HEADER------------------------------
59
File : SEGGER_RTT_configuration.h
60
Purpose : Implementation of SEGGER real-time transfer (RTT) which
61
allows real-time communication on targets which support
62
debugger memory accesses while the CPU is running.
63
Revision: $Rev: 7859 $
64
65
*/
66
67
#ifndef SEGGER_RTT_CONF_H
68
#define SEGGER_RTT_CONF_H
69
70
#ifdef __IAR_SYSTEMS_ICC__
71
#include <intrinsics.h>
72
#endif
73
74
/*********************************************************************
75
*
76
* Defines, configurable
77
*
78
**********************************************************************
79
*/
80
81
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3)
82
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3)
83
84
#define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
85
#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
86
87
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
88
89
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
90
91
#define USE_RTT_ASM (0) // Use assembler version of SEGGER_RTT.c when 1
92
93
/*********************************************************************
94
*
95
* RTT memcpy configuration
96
*
97
* memcpy() is good for large amounts of data,
98
* but the overhead is big for small amounts, which are usually stored via RTT.
99
* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead.
100
*
101
* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions.
102
* This is may be required with memory access restrictions,
103
* such as on Cortex-A devices with MMU.
104
*/
105
#define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop
106
//
107
// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets
108
//
109
//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__))
110
// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes))
111
//#endif
112
113
//
114
// Target is not allowed to perform other RTT operations while string still has not been stored completely.
115
// Otherwise we would probably end up with a mixed string in the buffer.
116
// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here.
117
//
118
// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4.
119
// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches.
120
// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly.
121
// (Higher priority = lower priority number)
122
// Default value for embOS: 128u
123
// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
124
// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC
125
// or define SEGGER_RTT_LOCK() to completely disable interrupts.
126
//
127
128
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
129
130
/*********************************************************************
131
*
132
* RTT lock configuration for SEGGER Embedded Studio,
133
* Rowley CrossStudio and GCC
134
*/
135
#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)
136
#ifdef __ARM_ARCH_6M__
137
#define SEGGER_RTT_LOCK() { \
138
unsigned int LockState; \
139
__asm volatile ("mrs %0, primask \n\t" \
140
"mov r1, $1 \n\t" \
141
"msr primask, r1 \n\t" \
142
: "=r" (LockState) \
143
: \
144
: "r1" \
145
);
146
147
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \
148
: \
149
: "r" (LockState) \
150
: \
151
); \
152
}
153
154
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__))
155
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
156
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
157
#endif
158
#define SEGGER_RTT_LOCK() { \
159
unsigned int LockState; \
160
__asm volatile ("mrs %0, basepri \n\t" \
161
"mov r1, %1 \n\t" \
162
"msr basepri, r1 \n\t" \
163
: "=r" (LockState) \
164
: "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \
165
: "r1" \
166
);
167
168
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \
169
: \
170
: "r" (LockState) \
171
: \
172
); \
173
}
174
175
#elif defined(__ARM_ARCH_7A__)
176
#define SEGGER_RTT_LOCK() { \
177
unsigned int LockState; \
178
__asm volatile ("mrs r1, CPSR \n\t" \
179
"mov %0, r1 \n\t" \
180
"orr r1, r1, #0xC0 \n\t" \
181
"msr CPSR_c, r1 \n\t" \
182
: "=r" (LockState) \
183
: \
184
: "r1" \
185
);
186
187
#define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
188
"mrs r1, CPSR \n\t" \
189
"bic r1, r1, #0xC0 \n\t" \
190
"and r0, r0, #0xC0 \n\t" \
191
"orr r1, r1, r0 \n\t" \
192
"msr CPSR_c, r1 \n\t" \
193
: \
194
: "r" (LockState) \
195
: "r0", "r1" \
196
); \
197
}
198
#else
199
#define SEGGER_RTT_LOCK()
200
#define SEGGER_RTT_UNLOCK()
201
#endif
202
#endif
203
204
/*********************************************************************
205
*
206
* RTT lock configuration for IAR EWARM
207
*/
208
#ifdef __ICCARM__
209
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__))
210
#define SEGGER_RTT_LOCK() { \
211
unsigned int LockState; \
212
LockState = __get_PRIMASK(); \
213
__set_PRIMASK(1);
214
215
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
216
}
217
#elif ((defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__)))
218
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
219
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
220
#endif
221
#define SEGGER_RTT_LOCK() { \
222
unsigned int LockState; \
223
LockState = __get_BASEPRI(); \
224
__set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
225
226
#define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \
227
}
228
#endif
229
#endif
230
231
/*********************************************************************
232
*
233
* RTT lock configuration for IAR RX
234
*/
235
#ifdef __ICCRX__
236
#define SEGGER_RTT_LOCK() { \
237
unsigned long LockState; \
238
LockState = __get_interrupt_state(); \
239
__disable_interrupt();
240
241
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
242
}
243
#endif
244
245
/*********************************************************************
246
*
247
* RTT lock configuration for IAR RL78
248
*/
249
#ifdef __ICCRL78__
250
#define SEGGER_RTT_LOCK() { \
251
__istate_t LockState; \
252
LockState = __get_interrupt_state(); \
253
__disable_interrupt();
254
255
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
256
}
257
#endif
258
259
/*********************************************************************
260
*
261
* RTT lock configuration for KEIL ARM
262
*/
263
#ifdef __CC_ARM
264
#if (defined __TARGET_ARCH_6S_M)
265
#define SEGGER_RTT_LOCK() { \
266
unsigned int LockState; \
267
register unsigned char PRIMASK __asm( "primask"); \
268
LockState = PRIMASK; \
269
PRIMASK = 1u; \
270
__schedule_barrier();
271
272
#define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \
273
__schedule_barrier(); \
274
}
275
#elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
276
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
277
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
278
#endif
279
#define SEGGER_RTT_LOCK() { \
280
unsigned int LockState; \
281
register unsigned char BASEPRI __asm( "basepri"); \
282
LockState = BASEPRI; \
283
BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
284
__schedule_barrier();
285
286
#define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \
287
__schedule_barrier(); \
288
}
289
#endif
290
#endif
291
292
/*********************************************************************
293
*
294
* RTT lock configuration for TI ARM
295
*/
296
#ifdef __TI_ARM__
297
#if defined (__TI_ARM_V6M0__)
298
#define SEGGER_RTT_LOCK() { \
299
unsigned int LockState; \
300
LockState = __get_PRIMASK(); \
301
__set_PRIMASK(1);
302
303
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
304
}
305
#elif (defined (__TI_ARM_V7M3__) || defined (__TI_ARM_V7M4__))
306
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
307
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
308
#endif
309
#define SEGGER_RTT_LOCK() { \
310
unsigned int LockState; \
311
LockState = OS_GetBASEPRI(); \
312
OS_SetBASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
313
314
#define SEGGER_RTT_UNLOCK() OS_SetBASEPRI(LockState); \
315
}
316
#endif
317
#endif
318
319
/*********************************************************************
320
*
321
* RTT lock configuration fallback
322
*/
323
#ifndef SEGGER_RTT_LOCK
324
#define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts)
325
#endif
326
327
#ifndef SEGGER_RTT_UNLOCK
328
#define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
329
#endif
330
331
#endif
332
/*************************** End of file ****************************/
Generated by
1.8.12