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 error APIs. 13 */ 14 15 #ifndef TRC_ERROR_H 16 #define TRC_ERROR_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 /** 29 * @defgroup trace_assert_apis Trace Asserts APIs 30 * @ingroup trace_recorder_apis 31 * @{ 32 */ 33 34 #define TRC_ERROR_BUFFER_SIZE (sizeof(uint32_t) + sizeof(uint32_t) + sizeof(TraceStringHandle_t)) 35 36 typedef struct TraceErrorBuffer 37 { 38 uint32_t buffer[(TRC_ERROR_BUFFER_SIZE) / sizeof(uint32_t)]; 39 } TraceErrorBuffer_t; 40 41 /** 42 * @internal Initializes the error system 43 * 44 * @param[in] pxBuffer Pointer to buffer 45 * 46 * @retval TRC_FAIL Failure 47 * @retval TRC_SUCCESS Success 48 */ 49 traceResult xTraceErrorInitialize(TraceErrorBuffer_t* pxBuffer); 50 51 /** 52 * @brief Register a warning 53 * 54 * @param[in] uiErrorCode Label 55 * 56 * @retval TRC_FAIL Failure 57 * @retval TRC_SUCCESS Success 58 */ 59 traceResult xTraceWarning(uint32_t uiErrorCode); 60 61 /** 62 * @brief Register an error 63 * 64 * @param[in] uiErrorCode Error code 65 * 66 * @retval TRC_FAIL Failure 67 * @retval TRC_SUCCESS Success 68 */ 69 traceResult xTraceError(uint32_t uiErrorCode); 70 71 /** 72 * @brief Retrieve the string for the last error 73 * 74 * @param[out] pszError Error string pointer 75 * 76 * @retval TRC_FAIL Failure 77 * @retval TRC_SUCCESS Success 78 */ 79 traceResult xTraceErrorGetLast(const char** pszError); 80 81 /** 82 * @brief Clears any errors 83 * 84 * @retval TRC_FAIL Failure 85 * @retval TRC_SUCCESS Success 86 */ 87 traceResult xTraceErrorClear(void); 88 89 /** @} */ 90 91 #ifdef __cplusplus 92 } 93 #endif 94 95 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */ 96 97 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */ 98 99 #endif /* TRC_ERROR_H*/ 100