Percepio Trace Recorder v4.8.0.hotfix1
Loading...
Searching...
No Matches
trcTimestamp.h
Go to the documentation of this file.
1/*
2* Percepio Trace Recorder for Tracealyzer v4.8.0.hotfix1
3* Copyright 2023 Percepio AB
4* www.percepio.com
5*
6* SPDX-License-Identifier: Apache-2.0
7*/
8
15#ifndef TRC_TIMESTAMP_H
16#define TRC_TIMESTAMP_H
17
18#if (TRC_USE_TRACEALYZER_RECORDER == 1)
19
20#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
21
22#include <trcTypes.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
37typedef struct TraceTimestampData /* Aligned */
38{
39 uint32_t type;
40 uint32_t period;
41 TraceUnsignedBaseType_t frequency;
42 uint32_t wraparounds;
43 uint32_t osTickHz;
44 uint32_t latestTimestamp;
45 uint32_t osTickCount;
47
48extern TraceTimestampData_t* pxTraceTimestamp;
49
59traceResult xTraceTimestampInitialize(TraceTimestampData_t *pxBuffer);
60
61#if ((TRC_CFG_USE_TRACE_ASSERT) == 1)
62
71traceResult xTraceTimestampGet(uint32_t* puiTimestamp);
72
81traceResult xTraceTimestampGetWraparounds(uint32_t* puiTimerWraparounds);
82
91traceResult xTraceTimestampSetFrequency(TraceUnsignedBaseType_t uxFrequency);
92
101traceResult xTraceTimestampGetFrequency(TraceUnsignedBaseType_t* puxFrequency);
102
111traceResult xTraceTimestampSetPeriod(uint32_t uiPeriod);
112
121traceResult xTraceTimestampGetPeriod(uint32_t* puiPeriod);
122
131traceResult xTraceTimestampSetOsTickCount(uint32_t uiOsTickCount);
132
141traceResult xTraceTimestampGetOsTickCount(uint32_t *puiOsTickCount);
142
143#else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
144
153#if ((TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_INCR) || (TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_INCR))
154#define xTraceTimestampGet(puiTimestamp) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4(*(puiTimestamp) = TRC_HWTC_COUNT, (*(puiTimestamp) < pxTraceTimestamp->latestTimestamp) ? pxTraceTimestamp->wraparounds++ : 0, pxTraceTimestamp->latestTimestamp = *(puiTimestamp), TRC_SUCCESS)
155#elif ((TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_DECR) || (TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_DECR))
156#define xTraceTimestampGet(puiTimestamp) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4(*(puiTimestamp) = TRC_HWTC_COUNT, (*(puiTimestamp) > pxTraceTimestamp->latestTimestamp) ? pxTraceTimestamp->wraparounds++ : 0, pxTraceTimestamp->latestTimestamp = *(puiTimestamp), TRC_SUCCESS)
157#elif ((TRC_HWTC_TYPE == TRC_OS_TIMER_INCR) || (TRC_HWTC_TYPE == TRC_OS_TIMER_DECR))
158#define xTraceTimestampGet(puiTimestamp) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4(*(puiTimestamp) = ((TRC_HWTC_COUNT) & 0x00FFFFFFU) + ((pxTraceTimestamp->osTickCount & 0x000000FFU) << 24), pxTraceTimestamp->wraparounds = pxTraceTimestamp->osTickCount, pxTraceTimestamp->latestTimestamp = *(puiTimestamp), TRC_SUCCESS)
159#endif
160
169#define xTraceTimestampGetWraparounds(puiTimerWraparounds) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puiTimerWraparounds) = pxTraceTimestamp->wraparounds, TRC_SUCCESS)
170
179#define xTraceTimestampSetFrequency(uxFrequency) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(pxTraceTimestamp->frequency = uxFrequency, TRC_SUCCESS)
180
189#define xTraceTimestampSetPeriod(uiPeriod) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(pxTraceTimestamp->period = uiPeriod, TRC_SUCCESS)
190
199#define xTraceTimestampSetOsTickCount(uiOsTickCount) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(pxTraceTimestamp->osTickCount = uiOsTickCount, TRC_SUCCESS)
200
209#define xTraceTimestampGetFrequency(puxFrequency) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puxFrequency) = pxTraceTimestamp->frequency, TRC_SUCCESS)
210
219#define xTraceTimestampGetPeriod(puiPeriod) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puiPeriod) = pxTraceTimestamp->period, TRC_SUCCESS)
220
229#define xTraceTimestampGetOsTickCount(puiOsTickCount) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puiOsTickCount) = pxTraceTimestamp->osTickCount, TRC_SUCCESS)
230
231#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
232
235#ifdef __cplusplus
236}
237#endif
238
239#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
240
241#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
242
243#endif /* TRC_TIMESTAMP_H */
#define xTraceTimestampSetOsTickCount(uiOsTickCount)
Sets trace timestamp OS tick count.
Definition: trcTimestamp.h:199
#define xTraceTimestampGetOsTickCount(puiOsTickCount)
Gets trace timestamp OS tick count.
Definition: trcTimestamp.h:229
#define xTraceTimestampSetFrequency(uxFrequency)
Sets trace timestamp frequency.
Definition: trcTimestamp.h:179
struct TraceTimestampData TraceTimestampData_t
Trace Timestamp Structure.
#define xTraceTimestampGetFrequency(puxFrequency)
Gets trace timestamp frequency.
Definition: trcTimestamp.h:209
#define xTraceTimestampGetPeriod(puiPeriod)
Gets trace timestamp period.
Definition: trcTimestamp.h:219
#define xTraceTimestampSetPeriod(uiPeriod)
Sets trace timestamp period.
Definition: trcTimestamp.h:189
#define xTraceTimestampGetWraparounds(puiTimerWraparounds)
Gets trace timestamp wraparounds.
Definition: trcTimestamp.h:169
#define xTraceTimestampGet(puiTimestamp)
Gets current trace timestamp.
Definition: trcTimestamp.h:154
Trace Timestamp Structure.
Definition: trcTimestamp.h:38
uint32_t latestTimestamp
Definition: trcTimestamp.h:44
uint32_t type
Definition: trcTimestamp.h:39
uint32_t osTickHz
Definition: trcTimestamp.h:43
uint32_t osTickCount
Definition: trcTimestamp.h:45
TraceUnsignedBaseType_t frequency
Definition: trcTimestamp.h:41
uint32_t wraparounds
Definition: trcTimestamp.h:42
uint32_t period
Definition: trcTimestamp.h:40