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 diagnostic APIs. 13 */ 14 15 #ifndef TRC_DIAGNOSTICS_H 16 #define TRC_DIAGNOSTICS_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_DIAGNOSTICS_COUNT 5 29 30 typedef enum TraceDiagnosticsType 31 { 32 TRC_DIAGNOSTICS_ENTRY_SYMBOL_LONGEST_LENGTH = 0x00, 33 TRC_DIAGNOSTICS_ENTRY_SLOTS_NO_ROOM = 0x01, 34 TRC_DIAGNOSTICS_BLOB_MAX_BYTES_TRUNCATED = 0x02, 35 TRC_DIAGNOSTICS_STACK_MONITOR_NO_SLOTS = 0x03, 36 TRC_DIAGNOSTICS_ASSERTS_TRIGGERED = 0x04, 37 } TraceDiagnosticsType_t; 38 39 typedef struct TraceDiagnosticsBuffer 40 { 41 uint8_t buffer[sizeof(TraceBaseType_t) * (TRC_DIAGNOSTICS_COUNT)]; 42 } TraceDiagnosticsBuffer_t; 43 44 /** 45 * @internal Initialize diagnostics 46 * 47 * @param[in] pxBuffer Diagnostics buffer 48 * 49 * @retval TRC_FAIL Failure 50 * @retval TRC_SUCCESS Success 51 */ 52 traceResult xTraceDiagnosticsInitialize(TraceDiagnosticsBuffer_t* pxBuffer); 53 54 /** 55 * @brief Retrieve diagnostics value 56 * 57 * @param[in] xType Diagnostics type 58 * @param[out] pxValue Pointer to value 59 * 60 * @retval TRC_FAIL Failure 61 * @retval TRC_SUCCESS Success 62 */ 63 traceResult xTraceDiagnosticsGet(TraceDiagnosticsType_t xType, TraceBaseType_t* pxValue); 64 65 /** 66 * @brief Set diagnostics value 67 * 68 * @param[in] xType Diagnostics type 69 * @param[in] xValue Value 70 * 71 * @retval TRC_FAIL Failure 72 * @retval TRC_SUCCESS Success 73 */ 74 traceResult xTraceDiagnosticsSet(TraceDiagnosticsType_t xType, TraceBaseType_t xValue); 75 76 /** 77 * @brief Add to diagnostics value 78 * 79 * @param[in] xType Diagnostics type 80 * @param[in] xValue Value 81 * 82 * @retval TRC_FAIL Failure 83 * @retval TRC_SUCCESS Success 84 */ 85 traceResult xTraceDiagnosticsAdd(TraceDiagnosticsType_t xType, TraceBaseType_t xValue); 86 87 /** 88 * @brief Increase diagnostics value 89 * 90 * @param[in] xType Diagnostics type 91 * 92 * @retval TRC_FAIL Failure 93 * @retval TRC_SUCCESS Success 94 */ 95 traceResult xTraceDiagnosticsIncrease(TraceDiagnosticsType_t xType); 96 97 /** 98 * @brief Decrease diagnostics value 99 * 100 * @param[in] xType Diagnostics type 101 * 102 * @retval TRC_FAIL Failure 103 * @retval TRC_SUCCESS Success 104 */ 105 traceResult xTraceDiagnosticsDecrease(TraceDiagnosticsType_t xType); 106 107 /** 108 * @brief Set a new diagnostics value if higher than previous value 109 * 110 * @param[in] xType Dagnostics type 111 * @param[in] xValue Value 112 * 113 * @retval TRC_FAIL Failure 114 * @retval TRC_SUCCESS Success 115 */ 116 traceResult xTraceDiagnosticsSetIfHigher(TraceDiagnosticsType_t xType, TraceBaseType_t xValue); 117 118 /** 119 * @brief Set a new diagnostics value if lower than previous value 120 * 121 * @param[in] xType Dagnostics type 122 * @param[in] xValue Value 123 * 124 * @retval TRC_FAIL Failure 125 * @retval TRC_SUCCESS Success 126 */ 127 traceResult xTraceDiagnosticsSetIfLower(TraceDiagnosticsType_t xType, TraceBaseType_t xValue); 128 129 /** 130 * @brief Check the diagnostics status 131 * 132 * @retval TRC_FAIL Failure 133 * @retval TRC_SUCCESS Success 134 */ 135 traceResult xTraceDiagnosticsCheckStatus(void); 136 137 #ifdef __cplusplus 138 } 139 #endif 140 141 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */ 142 143 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */ 144 145 #endif /* TRC_DIAGNOSTICS_H */ 146