1 /*
2 * Percepio Trace Recorder for Tracealyzer v4.6.6
3 * Copyright 2021 Percepio AB
4 * www.percepio.com
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8 
9 /**
10  * @file
11  *
12  * @brief Public trace extension APIs.
13  */
14 
15 #ifndef TRC_EXTENSION_H
16 #define TRC_EXTENSION_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
25 extern "C" {
26 #endif
27 
28 #define TRC_EXTENSION_STATE_INDEX_VERSION 0
29 #define TRC_EXTENSION_STATE_INDEX_BASE_EVENT_ID 1
30 #define TRC_EXTENSION_STATE_INDEX_EVENT_COUNT 2
31 
32 /**
33  * @defgroup trace_extension_apis Trace Extension APIs
34  * @ingroup trace_recorder_apis
35  * @{
36  */
37 
38 /**
39  * @brief Creates trace extension.
40  *
41  * @param[in] szName Name.
42  * @param[in] uiMajor Major version.
43  * @param[in] uiMinor Minor version.
44  * @param[in] uiPatch Patch version.
45  * @param[in] uiEventCount Event count.
46  * @param[out] pxExtensionHandle Pointer to uninitialized extension handle.
47  *
48  * @retval TRC_FAIL Failure
49  * @retval TRC_SUCCESS Success
50  */
51 traceResult xTraceExtensionCreate(const char *szName, uint8_t uiMajor, uint8_t uiMinor, uint16_t uiPatch, uint32_t uiEventCount, TraceExtensionHandle_t *pxExtensionHandle);
52 
53 /**
54  * @brief Gets extension base event id.
55  *
56  * @param[in] xExtensionHandle Pointer to initialized extension handle.
57  * @param[out] puiBaseEventId Base event id.
58  *
59  * @retval TRC_FAIL Failure
60  * @retval TRC_SUCCESS Success
61  */
62 traceResult xTraceExtensionGetBaseEventId(TraceExtensionHandle_t xExtensionHandle, uint32_t *puiBaseEventId);
63 
64 /**
65  * @brief Gets extension configuration name.
66  *
67  * @param[in] xExtensionHandle Pointer to initialized extension handle.
68  * @param[out] pszName Name.
69  *
70  * @retval TRC_FAIL Failure
71  * @retval TRC_SUCCESS Success
72  */
73 traceResult xTraceExtensionGetConfigName(TraceExtensionHandle_t xExtensionHandle, const char** pszName);
74 
75 /**
76  * @brief Returns extension event id.
77  *
78  * @param[in] xExtensionHandle Pointer to initialized extension handle.
79  * @param[in] uiLocalEventId Local event id.
80  *
81  * @returns Extension event id
82  */
83 #define xTraceExtensionGetEventId(xExtensionHandle, uiLocalEventId) ((uint32_t)xTraceEntryGetStateReturn((TraceEntryHandle_t)(xExtensionHandle), TRC_EXTENSION_STATE_INDEX_BASE_EVENT_ID) + (uiLocalEventId))
84 
85 /** @} */
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
92 
93 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
94 
95 #endif /* TRC_EXTENSION_H */
96