SLRE(Super Light Regular Expression library) Unit Test Code.

Dependencies:   mbed

Committer:
monpetit
Date:
Thu Jul 28 08:10:30 2016 +0000
Revision:
0:3ca3835f816e
initial commit: unit tests are passed.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
monpetit 0:3ca3835f816e 1 /*********************************************************************
monpetit 0:3ca3835f816e 2 * SEGGER MICROCONTROLLER GmbH & Co. KG *
monpetit 0:3ca3835f816e 3 * Solutions for real time microcontroller applications *
monpetit 0:3ca3835f816e 4 **********************************************************************
monpetit 0:3ca3835f816e 5 * *
monpetit 0:3ca3835f816e 6 * (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
monpetit 0:3ca3835f816e 7 * *
monpetit 0:3ca3835f816e 8 * www.segger.com Support: support@segger.com *
monpetit 0:3ca3835f816e 9 * *
monpetit 0:3ca3835f816e 10 **********************************************************************
monpetit 0:3ca3835f816e 11 * *
monpetit 0:3ca3835f816e 12 * SEGGER RTT * Real Time Transfer for embedded targets *
monpetit 0:3ca3835f816e 13 * *
monpetit 0:3ca3835f816e 14 **********************************************************************
monpetit 0:3ca3835f816e 15 * *
monpetit 0:3ca3835f816e 16 * All rights reserved. *
monpetit 0:3ca3835f816e 17 * *
monpetit 0:3ca3835f816e 18 * * This software may in its unmodified form be freely redistributed *
monpetit 0:3ca3835f816e 19 * in source form. *
monpetit 0:3ca3835f816e 20 * * The source code may be modified, provided the source code *
monpetit 0:3ca3835f816e 21 * retains the above copyright notice, this list of conditions and *
monpetit 0:3ca3835f816e 22 * the following disclaimer. *
monpetit 0:3ca3835f816e 23 * * Modified versions of this software in source or linkable form *
monpetit 0:3ca3835f816e 24 * may not be distributed without prior consent of SEGGER. *
monpetit 0:3ca3835f816e 25 * * This software may only be used for communication with SEGGER *
monpetit 0:3ca3835f816e 26 * J-Link debug probes. *
monpetit 0:3ca3835f816e 27 * *
monpetit 0:3ca3835f816e 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
monpetit 0:3ca3835f816e 29 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
monpetit 0:3ca3835f816e 30 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
monpetit 0:3ca3835f816e 31 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
monpetit 0:3ca3835f816e 32 * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
monpetit 0:3ca3835f816e 33 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
monpetit 0:3ca3835f816e 34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
monpetit 0:3ca3835f816e 35 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
monpetit 0:3ca3835f816e 36 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
monpetit 0:3ca3835f816e 37 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
monpetit 0:3ca3835f816e 38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
monpetit 0:3ca3835f816e 39 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
monpetit 0:3ca3835f816e 40 * DAMAGE. *
monpetit 0:3ca3835f816e 41 * *
monpetit 0:3ca3835f816e 42 **********************************************************************
monpetit 0:3ca3835f816e 43 * *
monpetit 0:3ca3835f816e 44 * RTT version: 5.12g *
monpetit 0:3ca3835f816e 45 * *
monpetit 0:3ca3835f816e 46 **********************************************************************
monpetit 0:3ca3835f816e 47 ----------------------------------------------------------------------
monpetit 0:3ca3835f816e 48 File : SEGGER_RTT_Conf.h
monpetit 0:3ca3835f816e 49 Purpose : Implementation of SEGGER real-time transfer (RTT) which
monpetit 0:3ca3835f816e 50 allows real-time communication on targets which support
monpetit 0:3ca3835f816e 51 debugger memory accesses while the CPU is running.
monpetit 0:3ca3835f816e 52 ---------------------------END-OF-HEADER------------------------------
monpetit 0:3ca3835f816e 53 */
monpetit 0:3ca3835f816e 54
monpetit 0:3ca3835f816e 55 #ifndef SEGGER_RTT_CONF_H
monpetit 0:3ca3835f816e 56 #define SEGGER_RTT_CONF_H
monpetit 0:3ca3835f816e 57
monpetit 0:3ca3835f816e 58 #ifdef __ICCARM__
monpetit 0:3ca3835f816e 59 #include <intrinsics.h>
monpetit 0:3ca3835f816e 60 #endif
monpetit 0:3ca3835f816e 61
monpetit 0:3ca3835f816e 62 /*********************************************************************
monpetit 0:3ca3835f816e 63 *
monpetit 0:3ca3835f816e 64 * Defines, configurable
monpetit 0:3ca3835f816e 65 *
monpetit 0:3ca3835f816e 66 **********************************************************************
monpetit 0:3ca3835f816e 67 */
monpetit 0:3ca3835f816e 68
monpetit 0:3ca3835f816e 69 #define SEGGER_RTT_MAX_NUM_UP_BUFFERS (2) // Max. number of up-buffers (T->H) available on this target (Default: 2)
monpetit 0:3ca3835f816e 70 #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (2) // Max. number of down-buffers (H->T) available on this target (Default: 2)
monpetit 0:3ca3835f816e 71
monpetit 0:3ca3835f816e 72 #define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
monpetit 0:3ca3835f816e 73 #define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
monpetit 0:3ca3835f816e 74
monpetit 0:3ca3835f816e 75 #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
monpetit 0:3ca3835f816e 76
monpetit 0:3ca3835f816e 77 #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
monpetit 0:3ca3835f816e 78
monpetit 0:3ca3835f816e 79 //
monpetit 0:3ca3835f816e 80 // Target is not allowed to perform other RTT operations while string still has not been stored completely.
monpetit 0:3ca3835f816e 81 // Otherwise we would probably end up with a mixed string in the buffer.
monpetit 0:3ca3835f816e 82 // If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here.
monpetit 0:3ca3835f816e 83 //
monpetit 0:3ca3835f816e 84 // SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4.
monpetit 0:3ca3835f816e 85 // Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches.
monpetit 0:3ca3835f816e 86 // When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly.
monpetit 0:3ca3835f816e 87 // (Higher priority = lower priority number)
monpetit 0:3ca3835f816e 88 // Default value for embOS: 128u
monpetit 0:3ca3835f816e 89 // Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
monpetit 0:3ca3835f816e 90 // In case of doubt mask all interrupts: 0u
monpetit 0:3ca3835f816e 91 //
monpetit 0:3ca3835f816e 92
monpetit 0:3ca3835f816e 93 #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
monpetit 0:3ca3835f816e 94
monpetit 0:3ca3835f816e 95 /*********************************************************************
monpetit 0:3ca3835f816e 96 *
monpetit 0:3ca3835f816e 97 * RTT lock configuration for SEGGER Embedded Studio,
monpetit 0:3ca3835f816e 98 * Rowley CrossStudio and GCC
monpetit 0:3ca3835f816e 99 */
monpetit 0:3ca3835f816e 100 #if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || ((defined __GNUC__) && !defined(__CC_ARM))
monpetit 0:3ca3835f816e 101 #ifdef __ARM_ARCH_6M__
monpetit 0:3ca3835f816e 102 #define SEGGER_RTT_LOCK() { \
monpetit 0:3ca3835f816e 103 unsigned int LockState; \
monpetit 0:3ca3835f816e 104 __asm volatile ("mrs %0, primask \n\t" \
monpetit 0:3ca3835f816e 105 "mov r1, $1 \n\t" \
monpetit 0:3ca3835f816e 106 "msr primask, r1 \n\t" \
monpetit 0:3ca3835f816e 107 : "=r" (LockState) \
monpetit 0:3ca3835f816e 108 : \
monpetit 0:3ca3835f816e 109 : "r1" \
monpetit 0:3ca3835f816e 110 );
monpetit 0:3ca3835f816e 111
monpetit 0:3ca3835f816e 112 #define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \
monpetit 0:3ca3835f816e 113 : \
monpetit 0:3ca3835f816e 114 : "r" (LockState) \
monpetit 0:3ca3835f816e 115 : \
monpetit 0:3ca3835f816e 116 ); \
monpetit 0:3ca3835f816e 117 }
monpetit 0:3ca3835f816e 118
monpetit 0:3ca3835f816e 119 #elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__))
monpetit 0:3ca3835f816e 120 #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
monpetit 0:3ca3835f816e 121 #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
monpetit 0:3ca3835f816e 122 #endif
monpetit 0:3ca3835f816e 123 #define SEGGER_RTT_LOCK() { \
monpetit 0:3ca3835f816e 124 unsigned int LockState; \
monpetit 0:3ca3835f816e 125 __asm volatile ("mrs %0, basepri \n\t" \
monpetit 0:3ca3835f816e 126 "mov r1, %1 \n\t" \
monpetit 0:3ca3835f816e 127 "msr basepri, r1 \n\t" \
monpetit 0:3ca3835f816e 128 : "=r" (LockState) \
monpetit 0:3ca3835f816e 129 : "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \
monpetit 0:3ca3835f816e 130 : "r1" \
monpetit 0:3ca3835f816e 131 );
monpetit 0:3ca3835f816e 132
monpetit 0:3ca3835f816e 133 #define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \
monpetit 0:3ca3835f816e 134 : \
monpetit 0:3ca3835f816e 135 : "r" (LockState) \
monpetit 0:3ca3835f816e 136 : \
monpetit 0:3ca3835f816e 137 ); \
monpetit 0:3ca3835f816e 138 }
monpetit 0:3ca3835f816e 139
monpetit 0:3ca3835f816e 140 #elif defined(__ARM_ARCH_7A__)
monpetit 0:3ca3835f816e 141 #define SEGGER_RTT_LOCK() { \
monpetit 0:3ca3835f816e 142 unsigned int LockState; \
monpetit 0:3ca3835f816e 143 __asm volatile ("mrs r1, CPSR \n\t" \
monpetit 0:3ca3835f816e 144 "mov %0, r1 \n\t" \
monpetit 0:3ca3835f816e 145 "orr r1, r1, #0xC0 \n\t" \
monpetit 0:3ca3835f816e 146 "msr CPSR_c, r1 \n\t" \
monpetit 0:3ca3835f816e 147 : "=r" (LockState) \
monpetit 0:3ca3835f816e 148 : \
monpetit 0:3ca3835f816e 149 : "r1" \
monpetit 0:3ca3835f816e 150 );
monpetit 0:3ca3835f816e 151
monpetit 0:3ca3835f816e 152 #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
monpetit 0:3ca3835f816e 153 "mrs r1, CPSR \n\t" \
monpetit 0:3ca3835f816e 154 "bic r1, r1, #0xC0 \n\t" \
monpetit 0:3ca3835f816e 155 "and r0, r0, #0xC0 \n\t" \
monpetit 0:3ca3835f816e 156 "orr r1, r1, r0 \n\t" \
monpetit 0:3ca3835f816e 157 "msr CPSR_c, r1 \n\t" \
monpetit 0:3ca3835f816e 158 : \
monpetit 0:3ca3835f816e 159 : "r" (LockState) \
monpetit 0:3ca3835f816e 160 : "r0", "r1" \
monpetit 0:3ca3835f816e 161 ); \
monpetit 0:3ca3835f816e 162 }
monpetit 0:3ca3835f816e 163 #else
monpetit 0:3ca3835f816e 164 #define SEGGER_RTT_LOCK()
monpetit 0:3ca3835f816e 165 #define SEGGER_RTT_UNLOCK()
monpetit 0:3ca3835f816e 166 #endif
monpetit 0:3ca3835f816e 167 #endif
monpetit 0:3ca3835f816e 168
monpetit 0:3ca3835f816e 169 /*********************************************************************
monpetit 0:3ca3835f816e 170 *
monpetit 0:3ca3835f816e 171 * RTT lock configuration for IAR EWARM
monpetit 0:3ca3835f816e 172 */
monpetit 0:3ca3835f816e 173 #ifdef __ICCARM__
monpetit 0:3ca3835f816e 174 #if (defined (__ARM6M__) && (__CORE__ == __ARM6M__))
monpetit 0:3ca3835f816e 175 #define SEGGER_RTT_LOCK() { \
monpetit 0:3ca3835f816e 176 unsigned int LockState; \
monpetit 0:3ca3835f816e 177 LockState = __get_PRIMASK(); \
monpetit 0:3ca3835f816e 178 __set_PRIMASK(1);
monpetit 0:3ca3835f816e 179
monpetit 0:3ca3835f816e 180 #define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
monpetit 0:3ca3835f816e 181 }
monpetit 0:3ca3835f816e 182 #elif ((defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__)))
monpetit 0:3ca3835f816e 183 #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
monpetit 0:3ca3835f816e 184 #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
monpetit 0:3ca3835f816e 185 #endif
monpetit 0:3ca3835f816e 186 #define SEGGER_RTT_LOCK() { \
monpetit 0:3ca3835f816e 187 unsigned int LockState; \
monpetit 0:3ca3835f816e 188 LockState = __get_BASEPRI(); \
monpetit 0:3ca3835f816e 189 __set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
monpetit 0:3ca3835f816e 190
monpetit 0:3ca3835f816e 191 #define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \
monpetit 0:3ca3835f816e 192 }
monpetit 0:3ca3835f816e 193 #endif
monpetit 0:3ca3835f816e 194 #endif
monpetit 0:3ca3835f816e 195
monpetit 0:3ca3835f816e 196 /*********************************************************************
monpetit 0:3ca3835f816e 197 *
monpetit 0:3ca3835f816e 198 * RTT lock configuration for KEIL ARM
monpetit 0:3ca3835f816e 199 */
monpetit 0:3ca3835f816e 200 #ifdef __CC_ARM
monpetit 0:3ca3835f816e 201 #if (defined __TARGET_ARCH_6S_M)
monpetit 0:3ca3835f816e 202 #define SEGGER_RTT_LOCK() { \
monpetit 0:3ca3835f816e 203 unsigned int LockState; \
monpetit 0:3ca3835f816e 204 register unsigned char PRIMASK __asm( "primask"); \
monpetit 0:3ca3835f816e 205 LockState = PRIMASK; \
monpetit 0:3ca3835f816e 206 PRIMASK = 1u; \
monpetit 0:3ca3835f816e 207 __schedule_barrier();
monpetit 0:3ca3835f816e 208
monpetit 0:3ca3835f816e 209 #define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \
monpetit 0:3ca3835f816e 210 __schedule_barrier(); \
monpetit 0:3ca3835f816e 211 }
monpetit 0:3ca3835f816e 212 #elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
monpetit 0:3ca3835f816e 213 #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
monpetit 0:3ca3835f816e 214 #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
monpetit 0:3ca3835f816e 215 #endif
monpetit 0:3ca3835f816e 216 #define SEGGER_RTT_LOCK() { \
monpetit 0:3ca3835f816e 217 unsigned int LockState; \
monpetit 0:3ca3835f816e 218 register unsigned char BASEPRI __asm( "basepri"); \
monpetit 0:3ca3835f816e 219 LockState = BASEPRI; \
monpetit 0:3ca3835f816e 220 BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
monpetit 0:3ca3835f816e 221 __schedule_barrier();
monpetit 0:3ca3835f816e 222
monpetit 0:3ca3835f816e 223 #define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \
monpetit 0:3ca3835f816e 224 __schedule_barrier(); \
monpetit 0:3ca3835f816e 225 }
monpetit 0:3ca3835f816e 226 #endif
monpetit 0:3ca3835f816e 227 #endif
monpetit 0:3ca3835f816e 228
monpetit 0:3ca3835f816e 229 /*********************************************************************
monpetit 0:3ca3835f816e 230 *
monpetit 0:3ca3835f816e 231 * RTT lock configuration fallback
monpetit 0:3ca3835f816e 232 */
monpetit 0:3ca3835f816e 233 #ifndef SEGGER_RTT_LOCK
monpetit 0:3ca3835f816e 234 #define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts)
monpetit 0:3ca3835f816e 235 #endif
monpetit 0:3ca3835f816e 236
monpetit 0:3ca3835f816e 237 #ifndef SEGGER_RTT_UNLOCK
monpetit 0:3ca3835f816e 238 #define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
monpetit 0:3ca3835f816e 239 #endif
monpetit 0:3ca3835f816e 240
monpetit 0:3ca3835f816e 241 #endif
monpetit 0:3ca3835f816e 242 /*************************** End of file ****************************/