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 state machine APIs.
13  */
14 
15 #ifndef TRC_STATE_MACHINE_H
16 #define TRC_STATE_MACHINE_H
17 
18 #include <trcTypes.h>
19 
20 #if (TRC_USE_TRACEALYZER_RECORDER == 1)
21 
22 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * @defgroup trace_state_machine_apis Trace State Machine APIs
30  * @ingroup trace_recorder_apis
31  * @{
32  */
33 
34 /**
35  * @brief Creates trace state machine.
36  *
37  * @param[in] szName Name.
38  * @param[out] pxStateMachineHandle Pointer to uninitialized trace state machine.
39  *
40  * @retval TRC_FAIL Failure
41  * @retval TRC_SUCCESS Success
42  */
43 traceResult xTraceStateMachineCreate(const char *szName, TraceStateMachineHandle_t *pxStateMachineHandle);
44 
45 /**
46  * @brief Creates trace state machine state.
47  *
48  * @param[in] xStateMachineHandle Pointer to initialized trace state machine.
49  * @param[in] szName Name.
50  * @param[out] pxStateHandle Pointer to uninitialized trace state machine state.
51  *
52  * @retval TRC_FAIL Failure
53  * @retval TRC_SUCCESS Success
54  */
55 traceResult xTraceStateMachineStateCreate(TraceStateMachineHandle_t xStateMachineHandle, const char *szName, TraceStateMachineStateHandle_t *pxStateHandle);
56 
57 /**
58  * @brief Sets trace state machine state.
59  *
60  * @param[in] xStateMachineHandle Pointer to initialized trace state machine.
61  * @param[in] xStateHandle Pointer to initialized trace state machine state.
62  *
63  * @retval TRC_FAIL Failure
64  * @retval TRC_SUCCESS Success
65  */
66 traceResult xTraceStateMachineSetState(TraceStateMachineHandle_t xStateMachineHandle, TraceStateMachineStateHandle_t xStateHandle);
67 
68 /** @} */
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #else
75 
76 /**
77  * @brief Disabled by TRC_CFG_RECORDER_MODE
78  */
79 #define xTraceStateMachineCreate(__szName, __pxStateMachineHandle) ((void)(__szName), *(__pxStateMachineHandle) = 0, TRC_SUCCESS)
80 
81 /**
82  * @brief Disabled by TRC_CFG_RECORDER_MODE
83  */
84 #define xTraceStateMachineStateCreate(__xStateMachineHandle, __szName, __pxStateHandle) ((void)(__xStateMachineHandle), (void)(__szName), *(__pxStateHandle) = 0, TRC_SUCCESS)
85 
86 /**
87  * @brief Disabled by TRC_CFG_RECORDER_MODE
88  */
89 #define xTraceStateMachineSetState(__xStateMachineHandle, __xStateHandle) ((void)(__xStateMachineHandle), (void)(__xStateHandle), TRC_SUCCESS)
90 
91 #endif
92 
93 #endif
94 
95 #endif
96