Percepio Trace Recorder v4.11.0
Loading...
Searching...
No Matches
trcStreamPort.h
1/*
2 * Trace Recorder for Tracealyzer v4.11.0
3 * Copyright 2025 Percepio AB
4 * www.percepio.com
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * The interface definitions for trace streaming ("stream ports").
9 * This "stream port" sets up the recorder to use SEGGER RTT as streaming channel.
10 *
11 * Note that this stream port is more complex than the typical case, since
12 * the J-Link interface uses a separate RAM buffer in SEGGER_RTT.c, instead
13 * of the default buffer included in the recorder core. The other stream ports
14 * offer more typical examples of how to define a custom streaming interface.
15 */
16
17#ifndef TRC_STREAM_PORT_H
18#define TRC_STREAM_PORT_H
19
20#if (TRC_USE_TRACEALYZER_RECORDER == 1)
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <trcDefines.h>
27#include <trcTypes.h>
28#include <trcStreamPortConfig.h>
29
30#include <SEGGER_RTT_Conf.h>
31#include <SEGGER_RTT.h>
32
33/* For now we disable multistream support for this streamport.
34#define TRC_STREAM_PORT_MULTISTREAM_SUPPORT
35*/
36
37/* Aligned */
38#define TRC_STREAM_PORT_RTT_UP_BUFFER_SIZE ((((TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_SIZE) + sizeof(TraceUnsignedBaseType_t) - 1) / sizeof(TraceUnsignedBaseType_t)) * sizeof(TraceUnsignedBaseType_t))
39
40/* Aligned */
41#define TRC_STREAM_PORT_RTT_DOWN_BUFFER_SIZE ((((TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_SIZE) + sizeof(TraceUnsignedBaseType_t) - 1) / sizeof(TraceUnsignedBaseType_t)) * sizeof(TraceUnsignedBaseType_t))
42
43#if (defined(TRC_CFG_STREAM_PORT_RTT_NO_LOCK_WRITE) && TRC_CFG_STREAM_PORT_RTT_NO_LOCK_WRITE == 1)
44#define TRC_STREAM_PORT_SEGGER_RTT_WRITE SEGGER_RTT_WriteNoLock
45#else
46#define TRC_STREAM_PORT_SEGGER_RTT_WRITE SEGGER_RTT_Write
47#endif
48
49#ifndef TRC_STREAM_PORT_MULTISTREAM_SUPPORT
50/* Multistream support is disabled */
51#define TRC_STREAM_PORT_MULTISTREAM_GET_CHANNEL(uiChannel) 0
52#else
53#define TRC_STREAM_PORT_MULTISTREAM_GET_CHANNEL(uiChannel) uiChannel
54#endif
55
59typedef struct TraceStreamPortBuffer /* Aligned */
60{
61 uint8_t bufferUp[TRC_CFG_CORE_COUNT][TRC_STREAM_PORT_RTT_UP_BUFFER_SIZE];
62 uint8_t bufferDown[TRC_STREAM_PORT_RTT_DOWN_BUFFER_SIZE];
63} TraceStreamPortBuffer_t;
64
75traceResult xTraceStreamPortInitialize(TraceStreamPortBuffer_t* pxBuffer);
76
88#define xTraceStreamPortWriteData(pvData, uiSize, uiChannel, piBytesWritten) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(piBytesWritten) = (int32_t)TRC_STREAM_PORT_SEGGER_RTT_WRITE((TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_INDEX) + TRC_STREAM_PORT_MULTISTREAM_GET_CHANNEL(uiChannel), (const char*)pvData, uiSize), TRC_SUCCESS)
89
100#define xTraceStreamPortReadData(pvData, uiSize, piBytesRead) ((SEGGER_RTT_HASDATA(TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_INDEX)) ? (*(piBytesRead) = (int32_t)SEGGER_RTT_Read((TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_INDEX), (char*)(pvData), uiSize), TRC_SUCCESS) : TRC_SUCCESS)
101
102traceResult xTraceStreamPortOnEnable(uint32_t uiStartOption);
103
104#define xTraceStreamPortOnDisable() (void)(TRC_SUCCESS)
105
106#define xTraceStreamPortOnTraceBegin() (void)(TRC_SUCCESS)
107
108#define xTraceStreamPortOnTraceEnd() (void)(TRC_SUCCESS)
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
115
116#endif /* TRC_STREAM_PORT_H */
A structure representing the trace stream port buffer.
Definition trcStreamPort.h:71