Segger rtt lib
Dependents: acnSensa_LIS acd52832_Indoor_Posit_Peripheral acd52832_Indoor_Posit_Central iBeacon acnsensa ... more
SEGGER_RTT_Conf.h@0:e61e7fc7cfe1, 2017-09-22 (annotated)
- Committer:
- jurica238814
- Date:
- Fri Sep 22 10:36:47 2017 +0000
- Revision:
- 0:e61e7fc7cfe1
SEGER RTT library init commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jurica238814 | 0:e61e7fc7cfe1 | 1 | /********************************************************************* |
jurica238814 | 0:e61e7fc7cfe1 | 2 | * SEGGER MICROCONTROLLER GmbH & Co. KG * |
jurica238814 | 0:e61e7fc7cfe1 | 3 | * Solutions for real time microcontroller applications * |
jurica238814 | 0:e61e7fc7cfe1 | 4 | ********************************************************************** |
jurica238814 | 0:e61e7fc7cfe1 | 5 | * * |
jurica238814 | 0:e61e7fc7cfe1 | 6 | * (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG * |
jurica238814 | 0:e61e7fc7cfe1 | 7 | * * |
jurica238814 | 0:e61e7fc7cfe1 | 8 | * www.segger.com Support: support@segger.com * |
jurica238814 | 0:e61e7fc7cfe1 | 9 | * * |
jurica238814 | 0:e61e7fc7cfe1 | 10 | ********************************************************************** |
jurica238814 | 0:e61e7fc7cfe1 | 11 | ---------------------------------------------------------------------- |
jurica238814 | 0:e61e7fc7cfe1 | 12 | File : SEGGER_RTT_Conf.h |
jurica238814 | 0:e61e7fc7cfe1 | 13 | Purpose : Implementation of SEGGER real-time transfer (RTT) which |
jurica238814 | 0:e61e7fc7cfe1 | 14 | allows real-time communication on targets which support |
jurica238814 | 0:e61e7fc7cfe1 | 15 | debugger memory accesses while the CPU is running. |
jurica238814 | 0:e61e7fc7cfe1 | 16 | ---------------------------END-OF-HEADER------------------------------ |
jurica238814 | 0:e61e7fc7cfe1 | 17 | */ |
jurica238814 | 0:e61e7fc7cfe1 | 18 | |
jurica238814 | 0:e61e7fc7cfe1 | 19 | #ifndef SEGGER_RTT_CONF_H |
jurica238814 | 0:e61e7fc7cfe1 | 20 | #define SEGGER_RTT_CONF_H |
jurica238814 | 0:e61e7fc7cfe1 | 21 | |
jurica238814 | 0:e61e7fc7cfe1 | 22 | #ifdef __ICCARM__ |
jurica238814 | 0:e61e7fc7cfe1 | 23 | #include <intrinsics.h> |
jurica238814 | 0:e61e7fc7cfe1 | 24 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 25 | |
jurica238814 | 0:e61e7fc7cfe1 | 26 | /********************************************************************* |
jurica238814 | 0:e61e7fc7cfe1 | 27 | * |
jurica238814 | 0:e61e7fc7cfe1 | 28 | * Defines, configurable |
jurica238814 | 0:e61e7fc7cfe1 | 29 | * |
jurica238814 | 0:e61e7fc7cfe1 | 30 | ********************************************************************** |
jurica238814 | 0:e61e7fc7cfe1 | 31 | */ |
jurica238814 | 0:e61e7fc7cfe1 | 32 | |
jurica238814 | 0:e61e7fc7cfe1 | 33 | #define SEGGER_RTT_MAX_NUM_UP_BUFFERS (2) // Max. number of up-buffers (T->H) available on this target (Default: 2) |
jurica238814 | 0:e61e7fc7cfe1 | 34 | #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (2) // Max. number of down-buffers (H->T) available on this target (Default: 2) |
jurica238814 | 0:e61e7fc7cfe1 | 35 | |
jurica238814 | 0:e61e7fc7cfe1 | 36 | #define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k) |
jurica238814 | 0:e61e7fc7cfe1 | 37 | #define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16) |
jurica238814 | 0:e61e7fc7cfe1 | 38 | |
jurica238814 | 0:e61e7fc7cfe1 | 39 | #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) |
jurica238814 | 0:e61e7fc7cfe1 | 40 | |
jurica238814 | 0:e61e7fc7cfe1 | 41 | #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0) |
jurica238814 | 0:e61e7fc7cfe1 | 42 | |
jurica238814 | 0:e61e7fc7cfe1 | 43 | // |
jurica238814 | 0:e61e7fc7cfe1 | 44 | // Target is not allowed to perform other RTT operations while string still has not been stored completely. |
jurica238814 | 0:e61e7fc7cfe1 | 45 | // Otherwise we would probably end up with a mixed string in the buffer. |
jurica238814 | 0:e61e7fc7cfe1 | 46 | // If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here. |
jurica238814 | 0:e61e7fc7cfe1 | 47 | // |
jurica238814 | 0:e61e7fc7cfe1 | 48 | // SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4. |
jurica238814 | 0:e61e7fc7cfe1 | 49 | // Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches. |
jurica238814 | 0:e61e7fc7cfe1 | 50 | // When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly. |
jurica238814 | 0:e61e7fc7cfe1 | 51 | // (Higher priority = lower priority number) |
jurica238814 | 0:e61e7fc7cfe1 | 52 | // Default value for embOS: 128u |
jurica238814 | 0:e61e7fc7cfe1 | 53 | // Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) |
jurica238814 | 0:e61e7fc7cfe1 | 54 | // In case of doubt mask all interrupts: 0u |
jurica238814 | 0:e61e7fc7cfe1 | 55 | // |
jurica238814 | 0:e61e7fc7cfe1 | 56 | |
jurica238814 | 0:e61e7fc7cfe1 | 57 | #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20) |
jurica238814 | 0:e61e7fc7cfe1 | 58 | |
jurica238814 | 0:e61e7fc7cfe1 | 59 | /********************************************************************* |
jurica238814 | 0:e61e7fc7cfe1 | 60 | * |
jurica238814 | 0:e61e7fc7cfe1 | 61 | * RTT lock configuration for SEGGER Embedded Studio, |
jurica238814 | 0:e61e7fc7cfe1 | 62 | * Rowley CrossStudio and GCC |
jurica238814 | 0:e61e7fc7cfe1 | 63 | */ |
jurica238814 | 0:e61e7fc7cfe1 | 64 | #if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__) |
jurica238814 | 0:e61e7fc7cfe1 | 65 | #ifdef __ARM_ARCH_6M__ |
jurica238814 | 0:e61e7fc7cfe1 | 66 | #define SEGGER_RTT_LOCK() { \ |
jurica238814 | 0:e61e7fc7cfe1 | 67 | unsigned int LockState; \ |
jurica238814 | 0:e61e7fc7cfe1 | 68 | __asm volatile ("mrs %0, primask \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 69 | "mov r1, $1 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 70 | "msr primask, r1 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 71 | : "=r" (LockState) \ |
jurica238814 | 0:e61e7fc7cfe1 | 72 | : \ |
jurica238814 | 0:e61e7fc7cfe1 | 73 | : "r1" \ |
jurica238814 | 0:e61e7fc7cfe1 | 74 | ); |
jurica238814 | 0:e61e7fc7cfe1 | 75 | |
jurica238814 | 0:e61e7fc7cfe1 | 76 | #define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 77 | : \ |
jurica238814 | 0:e61e7fc7cfe1 | 78 | : "r" (LockState) \ |
jurica238814 | 0:e61e7fc7cfe1 | 79 | : \ |
jurica238814 | 0:e61e7fc7cfe1 | 80 | ); \ |
jurica238814 | 0:e61e7fc7cfe1 | 81 | } |
jurica238814 | 0:e61e7fc7cfe1 | 82 | |
jurica238814 | 0:e61e7fc7cfe1 | 83 | #elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)) |
jurica238814 | 0:e61e7fc7cfe1 | 84 | #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY |
jurica238814 | 0:e61e7fc7cfe1 | 85 | #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) |
jurica238814 | 0:e61e7fc7cfe1 | 86 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 87 | #define SEGGER_RTT_LOCK() { \ |
jurica238814 | 0:e61e7fc7cfe1 | 88 | unsigned int LockState; \ |
jurica238814 | 0:e61e7fc7cfe1 | 89 | __asm volatile ("mrs %0, basepri \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 90 | "mov r1, %1 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 91 | "msr basepri, r1 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 92 | : "=r" (LockState) \ |
jurica238814 | 0:e61e7fc7cfe1 | 93 | : "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \ |
jurica238814 | 0:e61e7fc7cfe1 | 94 | : "r1" \ |
jurica238814 | 0:e61e7fc7cfe1 | 95 | ); |
jurica238814 | 0:e61e7fc7cfe1 | 96 | |
jurica238814 | 0:e61e7fc7cfe1 | 97 | #define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 98 | : \ |
jurica238814 | 0:e61e7fc7cfe1 | 99 | : "r" (LockState) \ |
jurica238814 | 0:e61e7fc7cfe1 | 100 | : \ |
jurica238814 | 0:e61e7fc7cfe1 | 101 | ); \ |
jurica238814 | 0:e61e7fc7cfe1 | 102 | } |
jurica238814 | 0:e61e7fc7cfe1 | 103 | |
jurica238814 | 0:e61e7fc7cfe1 | 104 | #elif defined(__ARM_ARCH_7A__) |
jurica238814 | 0:e61e7fc7cfe1 | 105 | #define SEGGER_RTT_LOCK() { \ |
jurica238814 | 0:e61e7fc7cfe1 | 106 | unsigned int LockState; \ |
jurica238814 | 0:e61e7fc7cfe1 | 107 | __asm volatile ("mrs r1, CPSR \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 108 | "mov %0, r1 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 109 | "orr r1, r1, #0xC0 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 110 | "msr CPSR_c, r1 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 111 | : "=r" (LockState) \ |
jurica238814 | 0:e61e7fc7cfe1 | 112 | : \ |
jurica238814 | 0:e61e7fc7cfe1 | 113 | : "r1" \ |
jurica238814 | 0:e61e7fc7cfe1 | 114 | ); |
jurica238814 | 0:e61e7fc7cfe1 | 115 | |
jurica238814 | 0:e61e7fc7cfe1 | 116 | #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 117 | "mrs r1, CPSR \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 118 | "bic r1, r1, #0xC0 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 119 | "and r0, r0, #0xC0 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 120 | "orr r1, r1, r0 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 121 | "msr CPSR_c, r1 \n\t" \ |
jurica238814 | 0:e61e7fc7cfe1 | 122 | : \ |
jurica238814 | 0:e61e7fc7cfe1 | 123 | : "r" (LockState) \ |
jurica238814 | 0:e61e7fc7cfe1 | 124 | : "r0", "r1" \ |
jurica238814 | 0:e61e7fc7cfe1 | 125 | ); \ |
jurica238814 | 0:e61e7fc7cfe1 | 126 | } |
jurica238814 | 0:e61e7fc7cfe1 | 127 | #else |
jurica238814 | 0:e61e7fc7cfe1 | 128 | #define SEGGER_RTT_LOCK() |
jurica238814 | 0:e61e7fc7cfe1 | 129 | #define SEGGER_RTT_UNLOCK() |
jurica238814 | 0:e61e7fc7cfe1 | 130 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 131 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 132 | |
jurica238814 | 0:e61e7fc7cfe1 | 133 | /********************************************************************* |
jurica238814 | 0:e61e7fc7cfe1 | 134 | * |
jurica238814 | 0:e61e7fc7cfe1 | 135 | * RTT lock configuration for IAR EWARM |
jurica238814 | 0:e61e7fc7cfe1 | 136 | */ |
jurica238814 | 0:e61e7fc7cfe1 | 137 | #ifdef __ICCARM__ |
jurica238814 | 0:e61e7fc7cfe1 | 138 | #if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) |
jurica238814 | 0:e61e7fc7cfe1 | 139 | #define SEGGER_RTT_LOCK() { \ |
jurica238814 | 0:e61e7fc7cfe1 | 140 | unsigned int LockState; \ |
jurica238814 | 0:e61e7fc7cfe1 | 141 | LockState = __get_PRIMASK(); \ |
jurica238814 | 0:e61e7fc7cfe1 | 142 | __set_PRIMASK(1); |
jurica238814 | 0:e61e7fc7cfe1 | 143 | |
jurica238814 | 0:e61e7fc7cfe1 | 144 | #define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \ |
jurica238814 | 0:e61e7fc7cfe1 | 145 | } |
jurica238814 | 0:e61e7fc7cfe1 | 146 | #elif ((defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__))) |
jurica238814 | 0:e61e7fc7cfe1 | 147 | #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY |
jurica238814 | 0:e61e7fc7cfe1 | 148 | #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) |
jurica238814 | 0:e61e7fc7cfe1 | 149 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 150 | #define SEGGER_RTT_LOCK() { \ |
jurica238814 | 0:e61e7fc7cfe1 | 151 | unsigned int LockState; \ |
jurica238814 | 0:e61e7fc7cfe1 | 152 | LockState = __get_BASEPRI(); \ |
jurica238814 | 0:e61e7fc7cfe1 | 153 | __set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); |
jurica238814 | 0:e61e7fc7cfe1 | 154 | |
jurica238814 | 0:e61e7fc7cfe1 | 155 | #define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \ |
jurica238814 | 0:e61e7fc7cfe1 | 156 | } |
jurica238814 | 0:e61e7fc7cfe1 | 157 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 158 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 159 | |
jurica238814 | 0:e61e7fc7cfe1 | 160 | /********************************************************************* |
jurica238814 | 0:e61e7fc7cfe1 | 161 | * |
jurica238814 | 0:e61e7fc7cfe1 | 162 | * RTT lock configuration for KEIL ARM |
jurica238814 | 0:e61e7fc7cfe1 | 163 | */ |
jurica238814 | 0:e61e7fc7cfe1 | 164 | #ifdef __CC_ARM |
jurica238814 | 0:e61e7fc7cfe1 | 165 | #if (defined __TARGET_ARCH_6S_M) |
jurica238814 | 0:e61e7fc7cfe1 | 166 | #define SEGGER_RTT_LOCK() { \ |
jurica238814 | 0:e61e7fc7cfe1 | 167 | unsigned int LockState; \ |
jurica238814 | 0:e61e7fc7cfe1 | 168 | register unsigned char PRIMASK __asm( "primask"); \ |
jurica238814 | 0:e61e7fc7cfe1 | 169 | LockState = PRIMASK; \ |
jurica238814 | 0:e61e7fc7cfe1 | 170 | PRIMASK = 1u; \ |
jurica238814 | 0:e61e7fc7cfe1 | 171 | __schedule_barrier(); |
jurica238814 | 0:e61e7fc7cfe1 | 172 | |
jurica238814 | 0:e61e7fc7cfe1 | 173 | #define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \ |
jurica238814 | 0:e61e7fc7cfe1 | 174 | __schedule_barrier(); \ |
jurica238814 | 0:e61e7fc7cfe1 | 175 | } |
jurica238814 | 0:e61e7fc7cfe1 | 176 | #elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M)) |
jurica238814 | 0:e61e7fc7cfe1 | 177 | #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY |
jurica238814 | 0:e61e7fc7cfe1 | 178 | #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) |
jurica238814 | 0:e61e7fc7cfe1 | 179 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 180 | #define SEGGER_RTT_LOCK() { \ |
jurica238814 | 0:e61e7fc7cfe1 | 181 | unsigned int LockState; \ |
jurica238814 | 0:e61e7fc7cfe1 | 182 | register unsigned char BASEPRI __asm( "basepri"); \ |
jurica238814 | 0:e61e7fc7cfe1 | 183 | LockState = BASEPRI; \ |
jurica238814 | 0:e61e7fc7cfe1 | 184 | BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \ |
jurica238814 | 0:e61e7fc7cfe1 | 185 | __schedule_barrier(); |
jurica238814 | 0:e61e7fc7cfe1 | 186 | |
jurica238814 | 0:e61e7fc7cfe1 | 187 | #define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \ |
jurica238814 | 0:e61e7fc7cfe1 | 188 | __schedule_barrier(); \ |
jurica238814 | 0:e61e7fc7cfe1 | 189 | } |
jurica238814 | 0:e61e7fc7cfe1 | 190 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 191 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 192 | |
jurica238814 | 0:e61e7fc7cfe1 | 193 | /********************************************************************* |
jurica238814 | 0:e61e7fc7cfe1 | 194 | * |
jurica238814 | 0:e61e7fc7cfe1 | 195 | * RTT lock configuration fallback |
jurica238814 | 0:e61e7fc7cfe1 | 196 | */ |
jurica238814 | 0:e61e7fc7cfe1 | 197 | #ifndef SEGGER_RTT_LOCK |
jurica238814 | 0:e61e7fc7cfe1 | 198 | #define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts) |
jurica238814 | 0:e61e7fc7cfe1 | 199 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 200 | |
jurica238814 | 0:e61e7fc7cfe1 | 201 | #ifndef SEGGER_RTT_UNLOCK |
jurica238814 | 0:e61e7fc7cfe1 | 202 | #define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state) |
jurica238814 | 0:e61e7fc7cfe1 | 203 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 204 | |
jurica238814 | 0:e61e7fc7cfe1 | 205 | #endif |
jurica238814 | 0:e61e7fc7cfe1 | 206 | /*************************** End of file ****************************/ |
jurica238814 | 0:e61e7fc7cfe1 | 207 |