Percepio Trace Recorder v4.11.0
Loading...
Searching...
No Matches
trcTimestamp.h
Go to the documentation of this file.
1/*
2* Percepio 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
14
15#ifndef TRC_TIMESTAMP_H
16#define TRC_TIMESTAMP_H
17
18#if (TRC_USE_TRACEALYZER_RECORDER == 1)
19
20#include <trcTypes.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
31
35typedef struct TraceTimestampData /* Aligned */
36{
37 uint32_t type;
38 uint32_t period;
39 TraceUnsignedBaseType_t frequency;
40 uint32_t wraparounds;
41 uint32_t osTickHz;
42 uint32_t latestTimestamp;
43 uint32_t osTickCount;
45
46extern TraceTimestampData_t* pxTraceTimestamp;
47
57traceResult xTraceTimestampInitialize(TraceTimestampData_t *pxBuffer);
58
59#if ((TRC_CFG_USE_TRACE_ASSERT) == 1)
60
69traceResult xTraceTimestampGet(uint32_t* puiTimestamp);
70
79traceResult xTraceTimestampGetWraparounds(uint32_t* puiTimerWraparounds);
80
89traceResult xTraceTimestampSetFrequency(TraceUnsignedBaseType_t uxFrequency);
90
99traceResult xTraceTimestampGetFrequency(TraceUnsignedBaseType_t* puxFrequency);
100
109traceResult xTraceTimestampSetPeriod(uint32_t uiPeriod);
110
119traceResult xTraceTimestampGetPeriod(uint32_t* puiPeriod);
120
129traceResult xTraceTimestampSetOsTickCount(uint32_t uiOsTickCount);
130
139traceResult xTraceTimestampGetOsTickCount(uint32_t *puiOsTickCount);
140
141#else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
142
151#if ((TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_INCR) || (TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_INCR))
152#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)
153#elif ((TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_DECR) || (TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_DECR))
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_OS_TIMER_INCR) || (TRC_HWTC_TYPE == TRC_OS_TIMER_DECR))
156#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)
157#endif
158
167#define xTraceTimestampGetWraparounds(puiTimerWraparounds) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puiTimerWraparounds) = pxTraceTimestamp->wraparounds, TRC_SUCCESS)
168
177#define xTraceTimestampSetFrequency(uxFrequency) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(pxTraceTimestamp->frequency = uxFrequency, TRC_SUCCESS)
178
187#define xTraceTimestampSetPeriod(uiPeriod) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(pxTraceTimestamp->period = uiPeriod, TRC_SUCCESS)
188
197#define xTraceTimestampSetOsTickCount(uiOsTickCount) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(pxTraceTimestamp->osTickCount = uiOsTickCount, TRC_SUCCESS)
198
207#define xTraceTimestampGetFrequency(puxFrequency) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puxFrequency) = pxTraceTimestamp->frequency, TRC_SUCCESS)
208
217#define xTraceTimestampGetPeriod(puiPeriod) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puiPeriod) = pxTraceTimestamp->period, TRC_SUCCESS)
218
227#define xTraceTimestampGetOsTickCount(puiOsTickCount) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puiOsTickCount) = pxTraceTimestamp->osTickCount, TRC_SUCCESS)
228
229#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
230
232
233#ifdef __cplusplus
234}
235#endif
236
237#else
238
239#define xTraceTimestampGet(puiTimestamp) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2((void)(puiTimestamp), TRC_SUCCESS)
240#define xTraceTimestampGetWraparounds(puiTimerWraparounds) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2((void)(puiTimerWraparounds), TRC_SUCCESS)
241#define xTraceTimestampSetFrequency(uxFrequency) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2((void)(uxFrequency), TRC_SUCCESS)
242#define xTraceTimestampSetPeriod(uiPeriod) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2((void)(uiPeriod), TRC_SUCCESS)
243#define xTraceTimestampSetOsTickCount(uiOsTickCount) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2((void)(uiOsTickCount), TRC_SUCCESS)
244#define xTraceTimestampGetFrequency(puxFrequency) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2((void)(puxFrequency), TRC_SUCCESS)
245#define xTraceTimestampGetPeriod(puiPeriod) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2((void)(puiPeriod), TRC_SUCCESS)
246#define xTraceTimestampGetOsTickCount(puiOsTickCount) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2((void)(puiOsTickCount), TRC_SUCCESS)
247
248#endif
249
250#endif
#define xTraceTimestampSetOsTickCount(uiOsTickCount)
Sets trace timestamp OS tick count.
Definition trcTimestamp.h:197
#define xTraceTimestampGetOsTickCount(puiOsTickCount)
Gets trace timestamp OS tick count.
Definition trcTimestamp.h:227
#define xTraceTimestampSetFrequency(uxFrequency)
Sets trace timestamp frequency.
Definition trcTimestamp.h:177
struct TraceTimestampData TraceTimestampData_t
Trace Timestamp Structure.
#define xTraceTimestampGetFrequency(puxFrequency)
Gets trace timestamp frequency.
Definition trcTimestamp.h:207
#define xTraceTimestampGetPeriod(puiPeriod)
Gets trace timestamp period.
Definition trcTimestamp.h:217
#define xTraceTimestampSetPeriod(uiPeriod)
Sets trace timestamp period.
Definition trcTimestamp.h:187
#define xTraceTimestampGetWraparounds(puiTimerWraparounds)
Gets trace timestamp wraparounds.
Definition trcTimestamp.h:167
#define xTraceTimestampGet(puiTimestamp)
Gets current trace timestamp.
Definition trcTimestamp.h:156
Trace Timestamp Structure.
Definition trcTimestamp.h:36
uint32_t latestTimestamp
Definition trcTimestamp.h:42
uint32_t type
Definition trcTimestamp.h:37
uint32_t osTickHz
Definition trcTimestamp.h:41
uint32_t osTickCount
Definition trcTimestamp.h:43
TraceUnsignedBaseType_t frequency
Definition trcTimestamp.h:39
uint32_t wraparounds
Definition trcTimestamp.h:40
uint32_t period
Definition trcTimestamp.h:38