1 #ifndef DBG_TRC_INT_H_ 2 #define DBG_TRC_INT_H_ 3 4 /** 5 **************************************************************************************** 6 * @addtogroup TRACER 7 * @{ 8 **************************************************************************************** 9 */ 10 11 #include "rwip_config.h" 12 13 #if (TRACER_PRESENT) 14 #include <stdint.h> // standard definitions 15 #include <stdbool.h> // boolean 16 17 /* 18 * DEFINES 19 **************************************************************************************** 20 */ 21 22 ///Channel index length 23 #define CHANNEL_ID_LEN 1 24 25 ///lengths of trace packet fields 26 #define SEQ_NUM_LEN 2 27 #define TIMESTAMP_LEN 4 28 #define TRC_CODE_LEN 1 29 30 #define TRC_FIX_LEN \ 31 CHANNEL_ID_LEN +\ 32 TRC_MSG_HDR_LEN +\ 33 SEQ_NUM_LEN +\ 34 TIMESTAMP_LEN +\ 35 TRC_CODE_LEN 36 37 /** 38 **************************************************************************************** 39 * @brief Convenient wrapper to trc_mem_alloc() 40 * 41 * This macro calls trc_mem_alloc() passing as parameter the length of the trace packet 42 * 43 * @param[in] trace_pay Trace payload length 44 * 45 * @return Pointer to trace code field(or NULL if the trace cannot be written) 46 **************************************************************************************** 47 */ 48 #define TRC_MEM_ALLOC(trace_pay) \ 49 dbg_trc_mem_alloc(TRC_FIX_LEN + trace_pay) 50 51 typedef uint8_t trc_id_t; 52 typedef uint8_t trc_opcode_t; 53 54 /* 55 * STRUCTURES DEFINITIONS 56 **************************************************************************************** 57 */ 58 ///Tracer Environment context structure 59 struct dbg_trc_env_tag 60 { 61 /// Current tracer configuration word 62 uint32_t curr_cw; 63 64 /// Compiled tracer configuration word 65 uint32_t compiled_cw; 66 }; 67 68 /* 69 * GLOBAL VARIABLE DEFINITIONS 70 **************************************************************************************** 71 */ 72 ///Tracer environment context 73 extern struct dbg_trc_env_tag dbg_trc_env; 74 75 /* 76 * TRANSPORT LAYER FUNCTION DECLARATIONS 77 **************************************************************************************** 78 */ 79 /** 80 **************************************************************************************** 81 * @brief initialize tracer TL 82 **************************************************************************************** 83 */ 84 void dbg_trc_tl_init(); 85 86 /** 87 **************************************************************************************** 88 * @brief trigger the transmission of tracer packets 89 **************************************************************************************** 90 */ 91 void dbg_trc_tx_trigger(void); 92 93 /* 94 * MEMORY FUNCTION DECLARATIONS 95 **************************************************************************************** 96 */ 97 /** 98 **************************************************************************************** 99 * @brief Initialize tracer memory 100 **************************************************************************************** 101 */ 102 void dbg_trc_mem_init(); 103 104 /** 105 **************************************************************************************** 106 * @brief Try to write a trace in memory. 107 * @param[in] trace_len Trace packet length (expressed in bytes) 108 * 109 * @return Pointer to trace code field(or NULL if the trace cannot be written) 110 **************************************************************************************** 111 */ 112 uint8_t *dbg_trc_mem_alloc(uint16_t const trace_len); 113 114 /** 115 **************************************************************************************** 116 * @brief Try to read a trace from the memory. 117 * 118 * @return Pointer to the total size of the trace (or NULL if the trace cannot be read) 119 **************************************************************************************** 120 */ 121 uint8_t *dbg_trc_mem_read(); 122 123 /** 124 **************************************************************************************** 125 * @brief Deallocate a trace from the memory. 126 * 127 * This function marks the trace block pointed by the reading pointer as invalid and moves 128 * it to the next trace block 129 * 130 **************************************************************************************** 131 */ 132 void dbg_trc_mem_dealloc(); 133 134 /** 135 **************************************************************************************** 136 * @brief Initialization of the tracer 137 * 138 * This function initializes the tracer 139 * 140 **************************************************************************************** 141 */ 142 void dbg_trc_init(bool reset); 143 144 #endif /* TRACER_PRESENT */ 145 /// @} TRACER 146 #endif /* DBG_TRC_INT_H_ */ 147