1 /*
2 * Trace Recorder for Tracealyzer v4.9.2
3 * Copyright 2023 Percepio AB
4 * www.percepio.com
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * The implementation of intervals.
9 */
10
11 #include <trcRecorder.h>
12
13 #if (TRC_USE_TRACEALYZER_RECORDER == 1) && (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
14
15 /*cstat !MISRAC2004-6.3 !MISRAC2012-Dir-4.6_a Suppress basic char type usage*/
xTraceIntervalChannelSetCreate(const char * szName,TraceIntervalChannelSetHandle_t * pxIntervalChannelSetHandle)16 traceResult xTraceIntervalChannelSetCreate(const char* szName, TraceIntervalChannelSetHandle_t* pxIntervalChannelSetHandle)
17 {
18 TraceObjectHandle_t xObjectHandle;
19
20 /* This should never fail */
21 TRC_ASSERT(pxIntervalChannelSetHandle != (void*)0);
22
23 /* We need to check this */
24 if (xTraceObjectRegister(PSF_EVENT_INTERVAL_CHANNEL_SET_CREATE, (void*)0, szName, 0u, &xObjectHandle) == TRC_FAIL)
25 {
26 return TRC_FAIL;
27 }
28
29 /* This should never fail */
30 TRC_ASSERT_ALWAYS_EVALUATE(xTraceEntrySetOptions((TraceEntryHandle_t)xObjectHandle, TRC_ENTRY_OPTION_INTERVAL_CHANNEL_SET) == TRC_SUCCESS);
31
32 *pxIntervalChannelSetHandle = (TraceIntervalChannelSetHandle_t)xObjectHandle;
33
34 return TRC_SUCCESS;
35 }
36
37 /*cstat !MISRAC2004-6.3 !MISRAC2012-Dir-4.6_a Suppress basic char type usage*/
xTraceIntervalChannelCreate(const char * szName,TraceIntervalChannelSetHandle_t xIntervalChannelSetHandle,TraceIntervalChannelHandle_t * pxIntervalChannelHandle)38 traceResult xTraceIntervalChannelCreate(const char *szName, TraceIntervalChannelSetHandle_t xIntervalChannelSetHandle, TraceIntervalChannelHandle_t *pxIntervalChannelHandle)
39 {
40 TraceObjectHandle_t xObjectHandle;
41
42 /* This should never fail */
43 TRC_ASSERT(pxIntervalChannelHandle != (void*)0);
44
45 /* This should never fail */
46 TRC_ASSERT(xIntervalChannelSetHandle != 0);
47
48 /* We need to check this */
49 if (xTraceObjectRegister(PSF_EVENT_INTERVAL_CHANNEL_CREATE, (void*)0, szName, (TraceUnsignedBaseType_t)xIntervalChannelSetHandle, &xObjectHandle) == TRC_FAIL) /*cstat !MISRAC2004-11.3 !MISRAC2012-Rule-11.4 Suppress conversion from pointer to integer check*/
50 {
51 return TRC_FAIL;
52 }
53
54 /* This should never fail */
55 TRC_ASSERT_ALWAYS_EVALUATE(xTraceEntrySetOptions((TraceEntryHandle_t)xObjectHandle, TRC_ENTRY_OPTION_INTERVAL_CHANNEL) == TRC_SUCCESS);
56
57 *pxIntervalChannelHandle = (TraceIntervalChannelHandle_t)xObjectHandle;
58
59 return TRC_SUCCESS;
60 }
61
xTraceIntervalStart(TraceIntervalChannelHandle_t xIntervalChannelHandle,TraceUnsignedBaseType_t uxValue,TraceIntervalInstanceHandle_t * pxIntervalInstanceHandle)62 traceResult xTraceIntervalStart(TraceIntervalChannelHandle_t xIntervalChannelHandle, TraceUnsignedBaseType_t uxValue, TraceIntervalInstanceHandle_t *pxIntervalInstanceHandle)
63 {
64 TRC_ASSERT(xIntervalChannelHandle != 0);
65
66 TRC_ASSERT(pxIntervalInstanceHandle != (void*)0);
67
68 /* We null all of it first in case it's 64-bit and we only write 32-bit */
69 *pxIntervalInstanceHandle = 0;
70
71 TRC_ASSERT_ALWAYS_EVALUATE(xTraceTimestampGet((uint32_t*)pxIntervalInstanceHandle) == TRC_SUCCESS); /*cstat !MISRAC2004-11.4 !MISRAC2012-Rule-11.3 Suppress conversion between pointer types checks*/
72
73 (void)xTraceEventCreate3(PSF_EVENT_INTERVAL_START, (TraceUnsignedBaseType_t)xIntervalChannelHandle, (TraceUnsignedBaseType_t)*pxIntervalInstanceHandle, uxValue); /*cstat !MISRAC2004-11.3 !MISRAC2012-Rule-11.4 Suppress conversion from pointer to integer check*/
74
75 return TRC_SUCCESS;
76 }
77
xTraceIntervalStop(TraceIntervalChannelHandle_t xIntervalChannelHandle,TraceIntervalInstanceHandle_t xIntervalInstanceHandle)78 traceResult xTraceIntervalStop(TraceIntervalChannelHandle_t xIntervalChannelHandle, TraceIntervalInstanceHandle_t xIntervalInstanceHandle)
79 {
80 TRC_ASSERT(xIntervalChannelHandle != 0);
81
82 (void)xTraceEventCreate2(PSF_EVENT_INTERVAL_STOP, (TraceUnsignedBaseType_t)xIntervalChannelHandle, (TraceUnsignedBaseType_t)xIntervalInstanceHandle); /*cstat !MISRAC2004-11.3 !MISRAC2012-Rule-11.4 Suppress conversion from pointer to integer check*/
83
84 return TRC_SUCCESS;
85 }
86
87 #endif
88