Jurica Resetar / aconno_SEGGER_RTT

Dependents:   acnSensa_LIS acd52832_Indoor_Posit_Peripheral acd52832_Indoor_Posit_Central iBeacon acnsensa ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SEGGER_RTT.h Source File

SEGGER_RTT.h

00001 /*********************************************************************
00002 *               SEGGER MICROCONTROLLER GmbH & Co. KG                 *
00003 *       Solutions for real time microcontroller applications         *
00004 **********************************************************************
00005 *                                                                    *
00006 *       (c) 2015 - 2016  SEGGER Microcontroller GmbH & Co. KG        *
00007 *                                                                    *
00008 *       www.segger.com     Support: support@segger.com               *
00009 *                                                                    *
00010 **********************************************************************
00011 *                                                                    *
00012 * All rights reserved.                                               *
00013 *                                                                    *
00014 * * This software may in its unmodified form be freely redistributed *
00015 *   in source form.                                                  *
00016 * * The source code may be modified, provided the source code        *
00017 *   retains the above copyright notice, this list of conditions and  *
00018 *   the following disclaimer.                                        *
00019 * * Modified versions of this software in source or linkable form    *
00020 *   may not be distributed without prior consent of SEGGER.          *
00021 * * This software may only be used for communication with SEGGER     *
00022 *   J-Link debug probes.                                             *
00023 *                                                                    *
00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
00025 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
00026 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
00027 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
00028 * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
00029 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           *
00030 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  *
00031 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    *
00032 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      *
00033 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          *
00034 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  *
00035 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
00036 * DAMAGE.                                                            *
00037 *                                                                    *
00038 **********************************************************************
00039 ---------------------------END-OF-HEADER------------------------------
00040 File    : SEGGER_RTT.h
00041 Purpose : Implementation of SEGGER real-time transfer which allows
00042           real-time communication on targets which support debugger 
00043           memory accesses while the CPU is running.
00044 ----------------------------------------------------------------------
00045 */
00046 
00047 #ifndef SEGGER_RTT_H
00048 #define SEGGER_RTT_H
00049 
00050 #include "SEGGER_RTT_Conf.h"
00051 
00052 /*********************************************************************
00053 *
00054 *       Defines, fixed
00055 *
00056 **********************************************************************
00057 */
00058 
00059 /*********************************************************************
00060 *
00061 *       Types
00062 *
00063 **********************************************************************
00064 */
00065 
00066 //
00067 // Description for a circular buffer (also called "ring buffer")
00068 // which is used as up-buffer (T->H)
00069 //
00070 typedef struct {
00071   const     char*    sName;         // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
00072             char*    pBuffer;       // Pointer to start of buffer
00073             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.
00074             unsigned WrOff;         // Position of next item to be written by either target.
00075   volatile  unsigned RdOff;         // Position of next item to be read by host. Must be volatile since it may be modified by host.
00076             unsigned Flags;         // Contains configuration flags
00077 } SEGGER_RTT_BUFFER_UP;
00078 
00079 //
00080 // Description for a circular buffer (also called "ring buffer")
00081 // which is used as down-buffer (H->T)
00082 //
00083 typedef struct {
00084   const     char*    sName;         // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
00085             char*    pBuffer;       // Pointer to start of buffer
00086             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.
00087   volatile  unsigned WrOff;         // Position of next item to be written by host. Must be volatile since it may be modified by host.
00088             unsigned RdOff;         // Position of next item to be read by target (down-buffer).
00089             unsigned Flags;         // Contains configuration flags
00090 } SEGGER_RTT_BUFFER_DOWN;
00091 
00092 //
00093 // RTT control block which describes the number of buffers available
00094 // as well as the configuration for each buffer
00095 //
00096 //
00097 typedef struct {
00098   char                    acID[16];                                 // Initialized to "SEGGER RTT"
00099   int                     MaxNumUpBuffers;                          // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
00100   int                     MaxNumDownBuffers;                        // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
00101   SEGGER_RTT_BUFFER_UP    aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS];       // Up buffers, transferring information up from target via debug probe to host
00102   SEGGER_RTT_BUFFER_DOWN  aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS];   // Down buffers, transferring information down from host via debug probe to target
00103 } SEGGER_RTT_CB;
00104 
00105 /*********************************************************************
00106 *
00107 *       Global data
00108 *
00109 **********************************************************************
00110 */
00111 extern SEGGER_RTT_CB _SEGGER_RTT;
00112 
00113 /*********************************************************************
00114 *
00115 *       RTT API functions
00116 *
00117 **********************************************************************
00118 */
00119 #ifdef __cplusplus
00120   extern "C" {
00121 #endif
00122 int          SEGGER_RTT_AllocDownBuffer  (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
00123 int          SEGGER_RTT_AllocUpBuffer    (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
00124 int          SEGGER_RTT_ConfigUpBuffer   (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
00125 int          SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
00126 int          SEGGER_RTT_GetKey           (void);
00127 unsigned     SEGGER_RTT_HasData          (unsigned BufferIndex);
00128 int          SEGGER_RTT_HasKey           (void);
00129 void         SEGGER_RTT_Init             (void);
00130 unsigned     SEGGER_RTT_Read             (unsigned BufferIndex,       void* pBuffer, unsigned BufferSize);
00131 unsigned     SEGGER_RTT_ReadNoLock       (unsigned BufferIndex,       void* pData,   unsigned BufferSize);
00132 int          SEGGER_RTT_SetNameDownBuffer(unsigned BufferIndex, const char* sName);
00133 int          SEGGER_RTT_SetNameUpBuffer  (unsigned BufferIndex, const char* sName);
00134 int          SEGGER_RTT_WaitKey          (void);
00135 unsigned     SEGGER_RTT_Write            (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
00136 unsigned     SEGGER_RTT_WriteNoLock      (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
00137 unsigned     SEGGER_RTT_WriteSkipNoLock  (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
00138 unsigned     SEGGER_RTT_WriteString      (unsigned BufferIndex, const char* s);
00139 void         SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
00140 //
00141 // Function macro for performance optimization
00142 //
00143 #define      SEGGER_RTT_HASDATA(n)       (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)
00144 
00145 /*********************************************************************
00146 *
00147 *       RTT "Terminal" API functions
00148 *
00149 **********************************************************************
00150 */
00151 int     SEGGER_RTT_SetTerminal        (char TerminalId);
00152 int     SEGGER_RTT_TerminalOut        (char TerminalId, const char* s);
00153 
00154 /*********************************************************************
00155 *
00156 *       RTT printf functions (require SEGGER_RTT_printf.c)
00157 *
00158 **********************************************************************
00159 */
00160 int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
00161 #ifdef __cplusplus
00162   }
00163 #endif
00164 
00165 /*********************************************************************
00166 *
00167 *       Defines
00168 *
00169 **********************************************************************
00170 */
00171 
00172 //
00173 // Operating modes. Define behavior if buffer is full (not enough space for entire message)
00174 //
00175 #define SEGGER_RTT_MODE_NO_BLOCK_SKIP         (0U)     // Skip. Do not block, output nothing. (Default)
00176 #define SEGGER_RTT_MODE_NO_BLOCK_TRIM         (1U)     // Trim: Do not block, output as much as fits.
00177 #define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL    (2U)     // Block: Wait until there is space in the buffer.
00178 #define SEGGER_RTT_MODE_MASK                  (3U)
00179 
00180 //
00181 // Control sequences, based on ANSI.
00182 // Can be used to control color, and clear the screen
00183 //
00184 #define RTT_CTRL_RESET                ""         // Reset to default colors
00185 #define RTT_CTRL_CLEAR                ""         // Clear screen, reposition cursor to top left
00186 
00187 #define RTT_CTRL_TEXT_BLACK           ""
00188 #define RTT_CTRL_TEXT_RED             ""
00189 #define RTT_CTRL_TEXT_GREEN           ""
00190 #define RTT_CTRL_TEXT_YELLOW          ""
00191 #define RTT_CTRL_TEXT_BLUE            ""
00192 #define RTT_CTRL_TEXT_MAGENTA         ""
00193 #define RTT_CTRL_TEXT_CYAN            ""
00194 #define RTT_CTRL_TEXT_WHITE           ""
00195 
00196 #define RTT_CTRL_TEXT_BRIGHT_BLACK    ""
00197 #define RTT_CTRL_TEXT_BRIGHT_RED      ""
00198 #define RTT_CTRL_TEXT_BRIGHT_GREEN    ""
00199 #define RTT_CTRL_TEXT_BRIGHT_YELLOW   ""
00200 #define RTT_CTRL_TEXT_BRIGHT_BLUE     ""
00201 #define RTT_CTRL_TEXT_BRIGHT_MAGENTA  ""
00202 #define RTT_CTRL_TEXT_BRIGHT_CYAN     ""
00203 #define RTT_CTRL_TEXT_BRIGHT_WHITE    ""
00204 
00205 #define RTT_CTRL_BG_BLACK             ""
00206 #define RTT_CTRL_BG_RED               ""
00207 #define RTT_CTRL_BG_GREEN             ""
00208 #define RTT_CTRL_BG_YELLOW            ""
00209 #define RTT_CTRL_BG_BLUE              ""
00210 #define RTT_CTRL_BG_MAGENTA           ""
00211 #define RTT_CTRL_BG_CYAN              ""
00212 #define RTT_CTRL_BG_WHITE             ""
00213 
00214 #define RTT_CTRL_BG_BRIGHT_BLACK      ""
00215 #define RTT_CTRL_BG_BRIGHT_RED        ""
00216 #define RTT_CTRL_BG_BRIGHT_GREEN      ""
00217 #define RTT_CTRL_BG_BRIGHT_YELLOW     ""
00218 #define RTT_CTRL_BG_BRIGHT_BLUE       ""
00219 #define RTT_CTRL_BG_BRIGHT_MAGENTA    ""
00220 #define RTT_CTRL_BG_BRIGHT_CYAN       ""
00221 #define RTT_CTRL_BG_BRIGHT_WHITE      ""
00222 
00223 
00224 #endif
00225 
00226 /*************************** End of file ****************************/
00227