1 /*
2 * Percepio Trace Recorder for Tracealyzer v4.10.3
3 * Copyright 2023 Percepio AB
4 * www.percepio.com
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8 
9 /**
10  * @file
11  *
12  * @brief Public trace error APIs.
13  */
14 
15 #ifndef TRC_ERROR_H
16 #define TRC_ERROR_H
17 
18 #if (TRC_USE_TRACEALYZER_RECORDER == 1) && (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
19 
20 #include <trcTypes.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /**
27  * @defgroup trace_assert_apis Trace Asserts APIs
28  * @ingroup trace_recorder_apis
29  * @{
30  */
31 
32 typedef struct TraceErrorData	/* Aligned */
33 {
34 	uint32_t uiErrorAndWarningFlags;
35 	uint32_t uiErrorCode;
36 	TraceStringHandle_t xWarningChannel;
37 } TraceErrorData_t;
38 
39 /**
40  * @internal Initializes the error system
41  *
42  * @param[in] pxBuffer Pointer to buffer
43  *
44  * @retval TRC_FAIL Failure
45  * @retval TRC_SUCCESS Success
46  */
47 traceResult xTraceErrorInitialize(TraceErrorData_t* pxBuffer);
48 
49 /**
50  * @brief Register a warning
51  *
52  * @param[in] uiErrorCode Label
53  *
54  * @retval TRC_FAIL Failure
55  * @retval TRC_SUCCESS Success
56  */
57 traceResult xTraceWarning(uint32_t uiErrorCode);
58 
59 /**
60  * @brief Register an error
61  *
62  * @param[in] uiErrorCode Error code
63  *
64  * @retval TRC_FAIL Failure
65  * @retval TRC_SUCCESS Success
66  */
67 traceResult xTraceError(uint32_t uiErrorCode);
68 
69 /**
70  * @brief Retrieve the string for the last error
71  *
72  * @param[out] pszError Error string pointer
73  *
74  * @retval TRC_FAIL Failure
75  * @retval TRC_SUCCESS Success
76  */
77 traceResult xTraceErrorGetLast(const char** pszError);
78 
79 /**
80  * @brief Clears any errors
81  *
82  * @retval TRC_FAIL Failure
83  * @retval TRC_SUCCESS Success
84  */
85 traceResult xTraceErrorClear(void);
86 
87 /** @} */
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif
94 
95 #endif