]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Labs/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h
Add the Labs projects provided in the V10.2.1_191129 zip file.
[freertos] / FreeRTOS-Labs / Source / FreeRTOS-Plus-Trace / streamports / Jlink_RTT / include / trcStreamingPort.h
diff --git a/FreeRTOS-Labs/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h b/FreeRTOS-Labs/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h
new file mode 100644 (file)
index 0000000..b1074b4
--- /dev/null
@@ -0,0 +1,196 @@
+/*******************************************************************************\r
+ * Trace Recorder Library for Tracealyzer v4.1.5\r
+ * Percepio AB, www.percepio.com\r
+ *\r
+ * trcStreamingPort.h\r
+ *\r
+ * The interface definitions for trace streaming ("stream ports").\r
+ * This "stream port" sets up the recorder to use SEGGER RTT as streaming channel.\r
+ *\r
+ * Note that this stream port is more complex than the typical case, since\r
+ * the J-Link interface uses a separate RAM buffer in SEGGER_RTT.c, instead\r
+ * of the default buffer included in the recorder core. The other stream ports \r
+ * offer more typical examples of how to define a custom streaming interface.\r
+ *\r
+ * Terms of Use\r
+ * This file is part of the trace recorder library (RECORDER), which is the \r
+ * intellectual property of Percepio AB (PERCEPIO) and provided under a\r
+ * license as follows.\r
+ * The RECORDER may be used free of charge for the purpose of recording data\r
+ * intended for analysis in PERCEPIO products. It may not be used or modified\r
+ * for other purposes without explicit permission from PERCEPIO.\r
+ * You may distribute the RECORDER in its original source code form, assuming\r
+ * this text (terms of use, disclaimer, copyright notice) is unchanged. You are\r
+ * allowed to distribute the RECORDER with minor modifications intended for\r
+ * configuration or porting of the RECORDER, e.g., to allow using it on a \r
+ * specific processor, processor family or with a specific communication\r
+ * interface. Any such modifications should be documented directly below\r
+ * this comment block.  \r
+ *\r
+ * Disclaimer\r
+ * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty\r
+ * as to its use or performance. PERCEPIO does not and cannot warrant the \r
+ * performance or results you may obtain by using the RECORDER or documentation.\r
+ * PERCEPIO make no warranties, express or implied, as to noninfringement of\r
+ * third party rights, merchantability, or fitness for any particular purpose.\r
+ * In no event will PERCEPIO, its technology partners, or distributors be liable\r
+ * to you for any consequential, incidental or special damages, including any\r
+ * lost profits or lost savings, even if a representative of PERCEPIO has been\r
+ * advised of the possibility of such damages, or for any claim by any third\r
+ * party. Some jurisdictions do not allow the exclusion or limitation of\r
+ * incidental, consequential or special damages, or the exclusion of implied\r
+ * warranties or limitations on how long an implied warranty may last, so the\r
+ * above limitations may not apply to you.\r
+ *\r
+ * Tabs are used for indent in this file (1 tab = 4 spaces)\r
+ *\r
+ * Copyright Percepio AB, 2018.\r
+ * www.percepio.com\r
+ ******************************************************************************/\r
+\r
+#ifndef TRC_STREAMING_PORT_H\r
+#define TRC_STREAMING_PORT_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+\r
+/*******************************************************************************\r
+ * Configuration Macro: TRC_CFG_RTT_BUFFER_SIZE_UP\r
+ *\r
+ * Defines the size of the "up" RTT buffer (target -> host) to use for writing\r
+ * the trace data, for RTT buffer 1 or higher.\r
+ *\r
+ * This setting is ignored for RTT buffer 0, which can't be reconfigured\r
+ * in runtime and therefore hard-coded to use the defines in SEGGER_RTT_Conf.h.\r
+ *\r
+ * Default buffer size for Tracealyzer is 5000 bytes. \r
+ *\r
+ * If you have a stand-alone J-Link probe, the can be decreased to around 1 KB.\r
+ * But integrated J-Link OB interfaces are slower and needs about 5-10 KB, \r
+ * depending on the amount of data produced.\r
+ ******************************************************************************/\r
+#define TRC_CFG_RTT_BUFFER_SIZE_UP 5000\r
+\r
+/*******************************************************************************\r
+ * Configuration Macro: TRC_CFG_RTT_BUFFER_SIZE_DOWN\r
+ *\r
+ * Defines the size of the "down" RTT buffer (host -> target) to use for reading\r
+ * commands from Tracealyzer, for RTT buffer 1 or higher.\r
+ *\r
+ * Default buffer size for Tracealyzer is 32 bytes.\r
+ *\r
+ * This setting is ignored for RTT buffer 0, which can't be reconfigured\r
+ * in runtime and therefore hard-coded to use the defines in SEGGER_RTT_Conf.h.\r
+ ******************************************************************************/\r
+#define TRC_CFG_RTT_BUFFER_SIZE_DOWN 32\r
+\r
+/*******************************************************************************\r
+ * Configuration Macro: TRC_CFG_RTT_UP_BUFFER_INDEX\r
+ *\r
+ * Defines the RTT buffer to use for writing the trace data. Make sure that\r
+ * the PC application has the same setting (File->Settings).\r
+ *\r
+ * Default: 1\r
+ *\r
+ * We don't recommend using RTT buffer 0, since mainly intended for terminals.\r
+ * If you prefer to use buffer 0, it must be configured in SEGGER_RTT_Conf.h. \r
+ ******************************************************************************/\r
+#define TRC_CFG_RTT_UP_BUFFER_INDEX 1\r
+\r
+/*******************************************************************************\r
+ * Configuration Macro: TRC_CFG_RTT_DOWN_BUFFER_INDEX\r
+ *\r
+ * Defines the RTT buffer to use for reading the trace data. Make sure that\r
+ * the PC application has the same setting (File->Settings).\r
+ *\r
+ * Default: 1\r
+ *\r
+ * We don't recommend using RTT buffer 0, since mainly intended for terminals.\r
+ * If you prefer to use buffer 0, it must be configured in SEGGER_RTT_Conf.h. \r
+ ******************************************************************************/\r
+#define TRC_CFG_RTT_DOWN_BUFFER_INDEX 1\r
+\r
+/*******************************************************************************\r
+ * TRC_CFG_RTT_MODE\r
+ * This stream port for J-Link streaming relies on SEGGER RTT, that contains an\r
+ * internal RAM buffer read by the J-Link probes during execution.\r
+ *\r
+ * Possible values:\r
+ * - SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL \r
+ * - SEGGER_RTT_MODE_NO_BLOCK_SKIP (default)\r
+ *\r
+ * Using SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL ensure that you get a\r
+ * complete and valid trace. This may however cause blocking if your streaming\r
+ * interface isn't fast enough, which may disturb the real-time behavior.\r
+ * \r
+ * We therefore recommend SEGGER_RTT_MODE_NO_BLOCK_SKIP. In this mode, \r
+ * Tracealyzer will report lost events if the transfer is not\r
+ * fast enough. In that case, try increasing the size of the "up buffer".\r
+ ******************************************************************************/\r
+#define TRC_CFG_RTT_MODE SEGGER_RTT_MODE_NO_BLOCK_SKIP\r
+\r
+#include "SEGGER_RTT_Conf.h"\r
+#include "SEGGER_RTT.h"\r
+\r
+#if (TRC_CFG_RTT_UP_BUFFER_INDEX >= SEGGER_RTT_MAX_NUM_UP_BUFFERS)\r
+#error "TRC_CFG_RTT_UP_BUFFER_INDEX must be smaller than SEGGER_RTT_MAX_NUM_UP_BUFFERS"\r
+#endif\r
+\r
+#if (TRC_CFG_RTT_DOWN_BUFFER_INDEX >= SEGGER_RTT_MAX_NUM_DOWN_BUFFERS)\r
+#error "TRC_CFG_RTT_DOWN_BUFFER_INDEX must be smaller than SEGGER_RTT_MAX_NUM_DOWN_BUFFERS"\r
+#endif\r
+\r
+/* If index is defined as 0, the internal RTT buffers will be used instead of this. */\r
+#if TRC_CFG_RTT_UP_BUFFER_INDEX == 0\r
+#define TRC_RTT_ALLOC_UP() static char* _TzTraceData = NULL;    /* Not actually used. Ignore allocation method. */\r
+#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */\r
+#else\r
+#if TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC\r
+#define TRC_RTT_ALLOC_UP() char _TzTraceData[TRC_CFG_RTT_BUFFER_SIZE_UP];    /* Static allocation */\r
+#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */\r
+#endif\r
+#if TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC\r
+#define TRC_RTT_ALLOC_UP() char* _TzTraceData = NULL;    /* Dynamic allocation */\r
+#define TRC_STREAM_PORT_MALLOC() _TzTraceData = TRC_PORT_MALLOC(TRC_CFG_RTT_BUFFER_SIZE_UP);\r
+#endif\r
+#if TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM\r
+#define TRC_RTT_ALLOC_UP() char* _TzTraceData = NULL;                                  /* Custom allocation, user needs to call vTraceSetRecorderDataBuffer before vTraceEnable, to assign this */ \r
+#define TRC_STREAM_PORT_MALLOC()                                                                               /* Not used in custom mode */\r
+#endif\r
+#endif\r
+\r
+/* Down-buffer. If index is defined as 0, the internal RTT buffers will be used instead of this. */ \\r
+#if TRC_CFG_RTT_DOWN_BUFFER_INDEX == 0\r
+#define TRC_RTT_ALLOC_DOWN() static char* _TzCtrlData = NULL;           /* Not actually used. Ignore allocation method. */\r
+#else\r
+#define TRC_RTT_ALLOC_DOWN() static char _TzCtrlData[TRC_CFG_RTT_BUFFER_SIZE_DOWN]; /* Always static allocation, since usually small. */\r
+#endif\r
+  \r
+#define TRC_STREAM_PORT_ALLOCATE_FIELDS() \\r
+       TRC_RTT_ALLOC_UP() /* Macro that will result in proper UP buffer allocation */ \\r
+       TRC_RTT_ALLOC_DOWN() /* Macro that will result in proper DOWN buffer allocation */\r
+\r
+int32_t readFromRTT(void* ptrData, uint32_t size, int32_t* ptrBytesRead);\r
+\r
+int32_t writeToRTT(void* ptrData, uint32_t size, int32_t* ptrBytesWritten);\r
+\r
+\r
+#define TRC_STREAM_PORT_INIT() \\r
+       TRC_STREAM_PORT_MALLOC(); /*Dynamic allocation or empty if static */ \\r
+       SEGGER_RTT_ConfigUpBuffer(TRC_CFG_RTT_UP_BUFFER_INDEX, "TzData", _TzTraceData, TRC_CFG_RTT_BUFFER_SIZE_UP, TRC_CFG_RTT_MODE ); \\r
+       SEGGER_RTT_ConfigDownBuffer(TRC_CFG_RTT_DOWN_BUFFER_INDEX, "TzCtrl", _TzCtrlData, TRC_CFG_RTT_BUFFER_SIZE_DOWN, TRC_CFG_RTT_MODE);\r
+\r
+/* Important for the J-Link port, in most other ports this can be skipped (default is 1) */\r
+#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 0\r
+  \r
+#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesWritten) writeToRTT(_ptrData, _size, _ptrBytesWritten)\r
+\r
+#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) readFromRTT(_ptrData, _size, _ptrBytesRead)\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* TRC_STREAMING_PORT_H */\r