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 ---------------------------END-OF-HEADER------------------------------
monpetit 0:3ca3835f816e 48 File : SEGGER_RTT.h
monpetit 0:3ca3835f816e 49 Purpose : Implementation of SEGGER real-time transfer which allows
monpetit 0:3ca3835f816e 50 real-time communication on targets which support debugger
monpetit 0:3ca3835f816e 51 memory accesses while the CPU is running.
monpetit 0:3ca3835f816e 52 ----------------------------------------------------------------------
monpetit 0:3ca3835f816e 53 */
monpetit 0:3ca3835f816e 54
monpetit 0:3ca3835f816e 55 #ifndef SEGGER_RTT_H
monpetit 0:3ca3835f816e 56 #define SEGGER_RTT_H
monpetit 0:3ca3835f816e 57
monpetit 0:3ca3835f816e 58 #include "SEGGER_RTT_Conf.h"
monpetit 0:3ca3835f816e 59
monpetit 0:3ca3835f816e 60 /*********************************************************************
monpetit 0:3ca3835f816e 61 *
monpetit 0:3ca3835f816e 62 * Defines, fixed
monpetit 0:3ca3835f816e 63 *
monpetit 0:3ca3835f816e 64 **********************************************************************
monpetit 0:3ca3835f816e 65 */
monpetit 0:3ca3835f816e 66
monpetit 0:3ca3835f816e 67 /*********************************************************************
monpetit 0:3ca3835f816e 68 *
monpetit 0:3ca3835f816e 69 * Types
monpetit 0:3ca3835f816e 70 *
monpetit 0:3ca3835f816e 71 **********************************************************************
monpetit 0:3ca3835f816e 72 */
monpetit 0:3ca3835f816e 73
monpetit 0:3ca3835f816e 74 //
monpetit 0:3ca3835f816e 75 // Description for a circular buffer (also called "ring buffer")
monpetit 0:3ca3835f816e 76 // which is used as up-buffer (T->H)
monpetit 0:3ca3835f816e 77 //
monpetit 0:3ca3835f816e 78 typedef struct {
monpetit 0:3ca3835f816e 79 const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
monpetit 0:3ca3835f816e 80 char* pBuffer; // Pointer to start of buffer
monpetit 0:3ca3835f816e 81 unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
monpetit 0:3ca3835f816e 82 unsigned WrOff; // Position of next item to be written by either target.
monpetit 0:3ca3835f816e 83 volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
monpetit 0:3ca3835f816e 84 unsigned Flags; // Contains configuration flags
monpetit 0:3ca3835f816e 85 } SEGGER_RTT_BUFFER_UP;
monpetit 0:3ca3835f816e 86
monpetit 0:3ca3835f816e 87 //
monpetit 0:3ca3835f816e 88 // Description for a circular buffer (also called "ring buffer")
monpetit 0:3ca3835f816e 89 // which is used as down-buffer (H->T)
monpetit 0:3ca3835f816e 90 //
monpetit 0:3ca3835f816e 91 typedef struct {
monpetit 0:3ca3835f816e 92 const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
monpetit 0:3ca3835f816e 93 char* pBuffer; // Pointer to start of buffer
monpetit 0:3ca3835f816e 94 unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
monpetit 0:3ca3835f816e 95 volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
monpetit 0:3ca3835f816e 96 unsigned RdOff; // Position of next item to be read by target (down-buffer).
monpetit 0:3ca3835f816e 97 unsigned Flags; // Contains configuration flags
monpetit 0:3ca3835f816e 98 } SEGGER_RTT_BUFFER_DOWN;
monpetit 0:3ca3835f816e 99
monpetit 0:3ca3835f816e 100 //
monpetit 0:3ca3835f816e 101 // RTT control block which describes the number of buffers available
monpetit 0:3ca3835f816e 102 // as well as the configuration for each buffer
monpetit 0:3ca3835f816e 103 //
monpetit 0:3ca3835f816e 104 //
monpetit 0:3ca3835f816e 105 typedef struct {
monpetit 0:3ca3835f816e 106 char acID[16]; // Initialized to "SEGGER RTT"
monpetit 0:3ca3835f816e 107 int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
monpetit 0:3ca3835f816e 108 int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
monpetit 0:3ca3835f816e 109 SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
monpetit 0:3ca3835f816e 110 SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
monpetit 0:3ca3835f816e 111 } SEGGER_RTT_CB;
monpetit 0:3ca3835f816e 112
monpetit 0:3ca3835f816e 113 /*********************************************************************
monpetit 0:3ca3835f816e 114 *
monpetit 0:3ca3835f816e 115 * Global data
monpetit 0:3ca3835f816e 116 *
monpetit 0:3ca3835f816e 117 **********************************************************************
monpetit 0:3ca3835f816e 118 */
monpetit 0:3ca3835f816e 119 extern SEGGER_RTT_CB _SEGGER_RTT;
monpetit 0:3ca3835f816e 120
monpetit 0:3ca3835f816e 121 /*********************************************************************
monpetit 0:3ca3835f816e 122 *
monpetit 0:3ca3835f816e 123 * RTT API functions
monpetit 0:3ca3835f816e 124 *
monpetit 0:3ca3835f816e 125 **********************************************************************
monpetit 0:3ca3835f816e 126 */
monpetit 0:3ca3835f816e 127 #ifdef __cplusplus
monpetit 0:3ca3835f816e 128 extern "C" {
monpetit 0:3ca3835f816e 129 #endif
monpetit 0:3ca3835f816e 130 int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
monpetit 0:3ca3835f816e 131 int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
monpetit 0:3ca3835f816e 132 int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
monpetit 0:3ca3835f816e 133 int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
monpetit 0:3ca3835f816e 134 int SEGGER_RTT_GetKey (void);
monpetit 0:3ca3835f816e 135 unsigned SEGGER_RTT_HasData (unsigned BufferIndex);
monpetit 0:3ca3835f816e 136 int SEGGER_RTT_HasKey (void);
monpetit 0:3ca3835f816e 137 void SEGGER_RTT_Init (void);
monpetit 0:3ca3835f816e 138 unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
monpetit 0:3ca3835f816e 139 unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
monpetit 0:3ca3835f816e 140 int SEGGER_RTT_SetNameDownBuffer(unsigned BufferIndex, const char* sName);
monpetit 0:3ca3835f816e 141 int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName);
monpetit 0:3ca3835f816e 142 int SEGGER_RTT_WaitKey (void);
monpetit 0:3ca3835f816e 143 unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
monpetit 0:3ca3835f816e 144 unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
monpetit 0:3ca3835f816e 145 unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
monpetit 0:3ca3835f816e 146 unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
monpetit 0:3ca3835f816e 147 void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
monpetit 0:3ca3835f816e 148 //
monpetit 0:3ca3835f816e 149 // Function macro for performance optimization
monpetit 0:3ca3835f816e 150 //
monpetit 0:3ca3835f816e 151 #define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)
monpetit 0:3ca3835f816e 152
monpetit 0:3ca3835f816e 153 /*********************************************************************
monpetit 0:3ca3835f816e 154 *
monpetit 0:3ca3835f816e 155 * RTT "Terminal" API functions
monpetit 0:3ca3835f816e 156 *
monpetit 0:3ca3835f816e 157 **********************************************************************
monpetit 0:3ca3835f816e 158 */
monpetit 0:3ca3835f816e 159 int SEGGER_RTT_SetTerminal (char TerminalId);
monpetit 0:3ca3835f816e 160 int SEGGER_RTT_TerminalOut (char TerminalId, const char* s);
monpetit 0:3ca3835f816e 161
monpetit 0:3ca3835f816e 162 /*********************************************************************
monpetit 0:3ca3835f816e 163 *
monpetit 0:3ca3835f816e 164 * RTT printf functions (require SEGGER_RTT_printf.c)
monpetit 0:3ca3835f816e 165 *
monpetit 0:3ca3835f816e 166 **********************************************************************
monpetit 0:3ca3835f816e 167 */
monpetit 0:3ca3835f816e 168 int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
monpetit 0:3ca3835f816e 169 #ifdef __cplusplus
monpetit 0:3ca3835f816e 170 }
monpetit 0:3ca3835f816e 171 #endif
monpetit 0:3ca3835f816e 172
monpetit 0:3ca3835f816e 173 /*********************************************************************
monpetit 0:3ca3835f816e 174 *
monpetit 0:3ca3835f816e 175 * Defines
monpetit 0:3ca3835f816e 176 *
monpetit 0:3ca3835f816e 177 **********************************************************************
monpetit 0:3ca3835f816e 178 */
monpetit 0:3ca3835f816e 179
monpetit 0:3ca3835f816e 180 //
monpetit 0:3ca3835f816e 181 // Operating modes. Define behavior if buffer is full (not enough space for entire message)
monpetit 0:3ca3835f816e 182 //
monpetit 0:3ca3835f816e 183 #define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0U) // Skip. Do not block, output nothing. (Default)
monpetit 0:3ca3835f816e 184 #define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1U) // Trim: Do not block, output as much as fits.
monpetit 0:3ca3835f816e 185 #define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2U) // Block: Wait until there is space in the buffer.
monpetit 0:3ca3835f816e 186 #define SEGGER_RTT_MODE_MASK (3U)
monpetit 0:3ca3835f816e 187
monpetit 0:3ca3835f816e 188 //
monpetit 0:3ca3835f816e 189 // Control sequences, based on ANSI.
monpetit 0:3ca3835f816e 190 // Can be used to control color, and clear the screen
monpetit 0:3ca3835f816e 191 //
monpetit 0:3ca3835f816e 192 #define RTT_CTRL_RESET "" // Reset to default colors
monpetit 0:3ca3835f816e 193 #define RTT_CTRL_CLEAR "" // Clear screen, reposition cursor to top left
monpetit 0:3ca3835f816e 194
monpetit 0:3ca3835f816e 195 #define RTT_CTRL_TEXT_BLACK ""
monpetit 0:3ca3835f816e 196 #define RTT_CTRL_TEXT_RED ""
monpetit 0:3ca3835f816e 197 #define RTT_CTRL_TEXT_GREEN ""
monpetit 0:3ca3835f816e 198 #define RTT_CTRL_TEXT_YELLOW ""
monpetit 0:3ca3835f816e 199 #define RTT_CTRL_TEXT_BLUE ""
monpetit 0:3ca3835f816e 200 #define RTT_CTRL_TEXT_MAGENTA ""
monpetit 0:3ca3835f816e 201 #define RTT_CTRL_TEXT_CYAN ""
monpetit 0:3ca3835f816e 202 #define RTT_CTRL_TEXT_WHITE ""
monpetit 0:3ca3835f816e 203
monpetit 0:3ca3835f816e 204 #define RTT_CTRL_TEXT_BRIGHT_BLACK ""
monpetit 0:3ca3835f816e 205 #define RTT_CTRL_TEXT_BRIGHT_RED ""
monpetit 0:3ca3835f816e 206 #define RTT_CTRL_TEXT_BRIGHT_GREEN ""
monpetit 0:3ca3835f816e 207 #define RTT_CTRL_TEXT_BRIGHT_YELLOW ""
monpetit 0:3ca3835f816e 208 #define RTT_CTRL_TEXT_BRIGHT_BLUE ""
monpetit 0:3ca3835f816e 209 #define RTT_CTRL_TEXT_BRIGHT_MAGENTA ""
monpetit 0:3ca3835f816e 210 #define RTT_CTRL_TEXT_BRIGHT_CYAN ""
monpetit 0:3ca3835f816e 211 #define RTT_CTRL_TEXT_BRIGHT_WHITE ""
monpetit 0:3ca3835f816e 212
monpetit 0:3ca3835f816e 213 #define RTT_CTRL_BG_BLACK ""
monpetit 0:3ca3835f816e 214 #define RTT_CTRL_BG_RED ""
monpetit 0:3ca3835f816e 215 #define RTT_CTRL_BG_GREEN ""
monpetit 0:3ca3835f816e 216 #define RTT_CTRL_BG_YELLOW ""
monpetit 0:3ca3835f816e 217 #define RTT_CTRL_BG_BLUE ""
monpetit 0:3ca3835f816e 218 #define RTT_CTRL_BG_MAGENTA ""
monpetit 0:3ca3835f816e 219 #define RTT_CTRL_BG_CYAN ""
monpetit 0:3ca3835f816e 220 #define RTT_CTRL_BG_WHITE ""
monpetit 0:3ca3835f816e 221
monpetit 0:3ca3835f816e 222 #define RTT_CTRL_BG_BRIGHT_BLACK ""
monpetit 0:3ca3835f816e 223 #define RTT_CTRL_BG_BRIGHT_RED ""
monpetit 0:3ca3835f816e 224 #define RTT_CTRL_BG_BRIGHT_GREEN ""
monpetit 0:3ca3835f816e 225 #define RTT_CTRL_BG_BRIGHT_YELLOW ""
monpetit 0:3ca3835f816e 226 #define RTT_CTRL_BG_BRIGHT_BLUE ""
monpetit 0:3ca3835f816e 227 #define RTT_CTRL_BG_BRIGHT_MAGENTA ""
monpetit 0:3ca3835f816e 228 #define RTT_CTRL_BG_BRIGHT_CYAN ""
monpetit 0:3ca3835f816e 229 #define RTT_CTRL_BG_BRIGHT_WHITE ""
monpetit 0:3ca3835f816e 230
monpetit 0:3ca3835f816e 231
monpetit 0:3ca3835f816e 232 #endif
monpetit 0:3ca3835f816e 233
monpetit 0:3ca3835f816e 234 /*************************** End of file ****************************/