11/*********************************************************************
2- * SEGGER Microcontroller GmbH & Co. KG *
2+ * SEGGER Microcontroller GmbH *
33* The Embedded Experts *
44**********************************************************************
55* *
6- * (c) 2015 - 2017 SEGGER Microcontroller GmbH & Co. KG *
6+ * (c) 1995 - 2019 SEGGER Microcontroller GmbH *
77* *
88* www.segger.com Support: [email protected] * 99* *
1717* *
1818* SEGGER strongly recommends to not make any changes *
1919* to or modify the source code of this software in order to stay *
20- * compatible with the RTT protocol and J-Link. *
20+ * compatible with the SystemView and RTT protocol, and J-Link. *
2121* *
2222* Redistribution and use in source and binary forms, with or *
2323* without modification, are permitted provided that the following *
24- * conditions are met: *
24+ * condition is met: *
2525* *
2626* 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. *
27+ * notice, this condition and the following disclaimer. *
3828* *
3929* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
4030* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
5242* *
5343**********************************************************************
5444* *
55- * SystemView version: V2.52d *
45+ * SystemView version: 3.10 *
5646* *
5747**********************************************************************
5848---------------------------END-OF-HEADER------------------------------
5949File : SEGGER_RTT_Conf.h
6050Purpose : Implementation of SEGGER real-time transfer (RTT) which
6151 allows real-time communication on targets which support
6252 debugger memory accesses while the CPU is running.
63- Revision: $Rev: 12706 $
53+ Revision: $Rev: 17066 $
6454
6555*/
6656
@@ -77,18 +67,29 @@ Revision: $Rev: 12706 $
7767*
7868**********************************************************************
7969*/
70+ #ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS
71+ #define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3)
72+ #endif
8073
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)
74+ #ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
75+ #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3)
76+ #endif
8377
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)
78+ #ifndef BUFFER_SIZE_UP
79+ #define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
80+ #endif
8681
87- #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
82+ #ifndef BUFFER_SIZE_DOWN
83+ #define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
84+ #endif
8885
89- #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
86+ #ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
87+ #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
88+ #endif
9089
91- #define USE_RTT_ASM (0) // Use assembler version of SEGGER_RTT.c when 1
90+ #ifndef SEGGER_RTT_MODE_DEFAULT
91+ #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
92+ #endif
9293
9394/*********************************************************************
9495*
@@ -102,7 +103,9 @@ Revision: $Rev: 12706 $
102103* This is may be required with memory access restrictions,
103104* such as on Cortex-A devices with MMU.
104105*/
105- #define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop
106+ #ifndef SEGGER_RTT_MEMCPY_USE_BYTELOOP
107+ #define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop
108+ #endif
106109//
107110// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets
108111//
@@ -124,20 +127,21 @@ Revision: $Rev: 12706 $
124127// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC
125128// or define SEGGER_RTT_LOCK() to completely disable interrupts.
126129//
127-
128- #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (2 << 5) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
130+ #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
131+ #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
132+ #endif
129133
130134/*********************************************************************
131135*
132136* RTT lock configuration for SEGGER Embedded Studio,
133137* Rowley CrossStudio and GCC
134138*/
135- #if (defined __SES_ARM ) || ( defined __CROSSWORKS_ARM ) || ( defined __GNUC__ )
136- #if (defined __ARM_ARCH_6M__ ) || ( defined __ARM_ARCH_8M_BASE__ )
139+ #if (defined( __SES_ARM ) || defined( __CROSSWORKS_ARM ) || defined( __GNUC__ ) || defined( __clang__ )) && !defined ( __CC_ARM )
140+ #if (defined( __ARM_ARCH_6M__ ) || defined( __ARM_ARCH_8M_BASE__ ) )
137141 #define SEGGER_RTT_LOCK () { \
138142 unsigned int LockState; \
139143 __asm volatile ("mrs %0, primask \n\t" \
140- "mov r1, $1 \n\t" \
144+ "movs r1, $1 \n\t" \
141145 "msr primask, r1 \n\t" \
142146 : "=r" (LockState) \
143147 : \
@@ -150,8 +154,7 @@ Revision: $Rev: 12706 $
150154 : \
151155 ); \
152156 }
153-
154- #elif (defined(__ARM_ARCH_7M__ ) || defined(__ARM_ARCH_7EM__ ))
157+ #elif (defined(__ARM_ARCH_7M__ ) || defined(__ARM_ARCH_7EM__ ) || defined(__ARM_ARCH_8M_MAIN__ ))
155158 #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
156159 #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
157160 #endif
@@ -195,9 +198,6 @@ Revision: $Rev: 12706 $
195198 : "r0", "r1" \
196199 ); \
197200 }
198- #else
199- #define SEGGER_RTT_LOCK ()
200- #define SEGGER_RTT_UNLOCK ()
201201 #endif
202202#endif
203203
@@ -308,14 +308,44 @@ Revision: $Rev: 12706 $
308308 #endif
309309 #define SEGGER_RTT_LOCK () { \
310310 unsigned int LockState; \
311- LockState = OS_GetBASEPRI(); \
312- OS_SetBASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
311+ LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
313312
314- #define SEGGER_RTT_UNLOCK () OS_SetBASEPRI (LockState); \
313+ #define SEGGER_RTT_UNLOCK () _set_interrupt_priority (LockState); \
315314 }
316315 #endif
317316#endif
318317
318+ /*********************************************************************
319+ *
320+ * RTT lock configuration for CCRX
321+ */
322+ #ifdef __RX
323+ #define SEGGER_RTT_LOCK () { \
324+ unsigned long LockState; \
325+ LockState = get_psw() & 0x010000; \
326+ clrpsw_i();
327+
328+ #define SEGGER_RTT_UNLOCK () set_psw(get_psw() | LockState); \
329+ }
330+ #endif
331+
332+ /*********************************************************************
333+ *
334+ * RTT lock configuration for embOS Simulation on Windows
335+ * (Can also be used for generic RTT locking with embOS)
336+ */
337+ #if defined(WIN32 ) || defined(SEGGER_RTT_LOCK_EMBOS )
338+
339+ void OS_SIM_EnterCriticalSection (void );
340+ void OS_SIM_LeaveCriticalSection (void );
341+
342+ #define SEGGER_RTT_LOCK () { \
343+ OS_SIM_EnterCriticalSection();
344+
345+ #define SEGGER_RTT_UNLOCK () OS_SIM_LeaveCriticalSection(); \
346+ }
347+ #endif
348+
319349/*********************************************************************
320350*
321351* RTT lock configuration fallback
0 commit comments