1 #ifndef DBG_TRC_H_ 2 #define DBG_TRC_H_ 3 4 /** 5 **************************************************************************************** 6 * @addtogroup TRACER 7 * @ingroup TRACER 8 * @brief Tracer module sends traces to the PC through UART 9 * @{ 10 **************************************************************************************** 11 */ 12 13 #include "rwip_config.h" 14 #if (TRACER_PRESENT) 15 16 /* 17 * INCLUDE FILES 18 **************************************************************************************** 19 */ 20 21 #include <stdint.h> 22 23 #if (TRC_KE_MSG || TRC_KE_TMR) 24 #include "ke_msg.h" 25 #endif /*(TRC_KE_MSG || TRC_KE_TMR)*/ 26 27 #if (TRC_EA) 28 #include "ea.h" 29 #endif /*(TRC_EA) */ 30 31 /* 32 * DEFINES 33 **************************************************************************************** 34 */ 35 #define TRC_GRP_B(__t) (__t##_BIT) 36 #define TRC_GRP_P(__t) (__t##_POS) 37 38 #define TRC_MSG_TYPE 0x06 39 40 #define TRC_OPCODE_LEN (1) 41 #define TRC_PDULEN_LEN (2) 42 #define TRC_MSG_HDR_LEN (TRC_OPCODE_LEN + TRC_PDULEN_LEN) 43 44 #define TRC_CFG_WORD_LEN (4) 45 46 /* 47 * ENUMERATION DEFINITION 48 **************************************************************************************** 49 */ 50 /// Possible types of trace 51 enum trace_types 52 { 53 KE_MSG_SEND_QUEUE = 0x00, 54 KE_MSG_HANDLED = 0x01, 55 KE_TMR_SET = 0x02, 56 KE_TMR_CLR = 0x03, 57 KE_TMR_EXP = 0x04, 58 KE_EVT_SET = 0x05, 59 KE_EVT_HANDLED = 0x06, 60 MEM_ALLOC = 0x07, 61 MEM_FREE = 0x08, 62 SLEEP_ENTER = 0x09, 63 SLEEP_WAKEUP = 0x0A, 64 ASSERT_WARNING = 0x0B, 65 ASSERT_ERROR = 0x0C, 66 ET_PROG = 0x0D, 67 CONN_EVT_CNT = 0x0E, 68 FRM_CMP_BT = 0x0F, 69 FRM_CMP_BLE = 0x10, 70 CS_BLE = 0x11, 71 CS_BT = 0x12, 72 RX_DESC = 0x13, 73 LLCP_TX = 0x14, 74 LLCP_RX = 0x15, 75 LLCP_ACK = 0x16, 76 LMP_TX = 0x17, 77 LMP_RX = 0x18, 78 LMP_ACK = 0x19, 79 L2CAP_TX = 0x1A, 80 L2CAP_RX = 0x1B, 81 L2CAP_ACK = 0x1C, 82 EA_REQ = 0x1D, 83 EA_CANC = 0x1E, 84 EA_REM = 0x1F, 85 EA_START = 0x20, 86 EA_SHIFT = 0x21, 87 LC_ST = 0x22, 88 LLC_ST = 0x23, 89 HCI_CMD = 0x24, 90 HCI_EVT = 0x25, 91 CUSTOM = 0x26, 92 }; 93 94 /// Configuration word bit field 95 /// 96 /// 7 6 5 4 3 2 1 0 97 /// +-------+-------+-------+-------+-------+-------+-------+-------+ 98 /// |CS_BLE | PROG |SW_ASS | SLEEP | MEM |KE_EVT |KE_TMR |KE_MSG | 99 /// +-------+-------+-------+-------+-------+-------+-------+-------+ 100 /// 101 /// 15 14 13 12 11 10 9 8 102 /// +-------+-------+-------+-------+-------+-------+-------+-------+ 103 /// | LC_ST |LLC_ST | EA | L2CAP | LMP | LLCP |RX_DESC| CS_BT | 104 /// +-------+-------+-------+-------+-------+-------+-------+-------+ 105 /// 106 /// 23 22 21 20 19 18 17 16 107 /// +-------+-------+-------+-------+-------+-------+-------+-------+ 108 /// | | | | | | |CUSTOM | HCI | 109 /// +-------+-------+-------+-------+-------+-------+-------+-------+ 110 /// 111 /// 31 30 29 28 27 26 25 24 112 /// +-------+-------+-------+-------+-------+-------+-------+-------+ 113 /// | | | | | | | | | 114 /// +-------+-------+-------+-------+-------+-------+-------+-------+ 115 /// 116 enum dbg_trc_cfg_fields 117 { 118 /// Kernel message 119 TRC_KE_MSG_POS = 0, 120 TRC_KE_MSG_BIT = 0x00000001, 121 122 /// Kernel timer 123 TRC_KE_TMR_POS = 1, 124 TRC_KE_TMR_BIT = 0x00000002, 125 126 /// Kernel event 127 TRC_KE_EVT_POS = 2, 128 TRC_KE_EVT_BIT = 0x00000004, 129 130 /// Memory allocation and deallocation 131 TRC_MEM_POS = 3, 132 TRC_MEM_BIT = 0x00000008, 133 134 /// Sleep mode 135 TRC_SLEEP_POS = 4, 136 TRC_SLEEP_BIT = 0x00000010, 137 138 /// Software Assert 139 TRC_SW_ASS_POS = 5, 140 TRC_SW_ASS_BIT = 0x00000020, 141 142 /// Programming of the exchange table, updating of the event counter and handling of "End of Event" interrupt 143 TRC_PROG_POS = 6, 144 TRC_PROG_BIT = 0x00000040, 145 146 /// BLE Control structure 147 TRC_CS_BLE_POS = 7, 148 TRC_CS_BLE_BIT = 0x00000080, 149 150 /// BT Control structure 151 TRC_CS_BT_POS = 8, 152 TRC_CS_BT_BIT = 0x00000100, 153 154 /// Processing of RX descriptors at each LLD driver 155 TRC_RX_DESC_POS = 9, 156 TRC_RX_DESC_BIT = 0x00000200, 157 158 /// LLCP transmission, reception and acknowledgment 159 TRC_LLCP_POS = 10, 160 TRC_LLCP_BIT = 0x00000400, 161 162 /// LMP transmission, reception and acknowledgment 163 TRC_LMP_POS = 11, 164 TRC_LMP_BIT = 0x00000800, 165 166 /// L2CAP transmission, reception and acknowledgment 167 TRC_L2CAP_POS = 12, 168 TRC_L2CAP_BIT = 0x00001000, 169 170 /// Scheduling request, cancellation, shift and remove 171 TRC_EA_POS = 13, 172 TRC_EA_BIT = 0x00002000, 173 174 /// LLC state transition 175 TRC_LLC_STATE_TRANS_POS = 14, 176 TRC_LLC_STATE_TRANS_BIT = 0x00004000, 177 178 /// LC state transition 179 TRC_LC_STATE_TRANS_POS = 15, 180 TRC_LC_STATE_TRANS_BIT = 0x00008000, 181 182 /// HCI messages (in Full embedded mode) 183 TRC_HCI_POS = 16, 184 TRC_HCI_BIT = 0x00010000, 185 186 /// Custom trace 187 TRC_CUSTOM_POS = 17, 188 TRC_CUSTOM_BIT = 0x00020000, 189 }; 190 191 /// Tracer packet types 192 enum dbg_trc_pkt_types 193 { 194 /// Trace message 195 TRACE = 0x01, 196 /// Configuration message 197 TRACER_CFG = 0x02, 198 /// Acknowledgment message 199 TRACER_ACK = 0x03 200 }; 201 202 #if (TRC_RX_DESC) 203 /// LLD driver types 204 enum driver_types 205 { 206 LLD_SCAN = 0x01, 207 LLD_INIT = 0x02, 208 LLD_ADV = 0x03, 209 LLD_CON = 0x04 210 }; 211 #endif /*(TRC_RX_DESC)*/ 212 213 #if (TRC_CUSTOM) 214 /// Custom trace types 215 enum custom_trace_types 216 { 217 UINT8_T = 0x01, 218 UINT16_T = 0x02, 219 UINT32_T = 0x03, 220 VOID = 0x04 221 }; 222 #endif /*(TRC_CUSTOM)*/ 223 #endif /*(TRACER_PRESENT)*/ 224 225 /* 226 * TYPE DEFINITIONS 227 **************************************************************************************** 228 */ 229 230 /* 231 * GLOBAL VARIABLE DECLARATIONS 232 **************************************************************************************** 233 */ 234 235 236 /* 237 * FUNCTION DECLARATION 238 **************************************************************************************** 239 */ 240 /** 241 **************************************************************************************** 242 * @brief Request a new trace 243 * 244 * This function checks the current configuration of the tracer 245 * 246 **************************************************************************************** 247 */ 248 #if (TRACER_PRESENT && TRC_KE_MSG) 249 /** 250 **************************************************************************************** 251 * @brief Trace request API for kernel message pushed in the send queue 252 * 253 * This function is called when a kernel message is pushed in the send queue. 254 * 255 * It checks the current tracer configuration and writes the trace in memory if the trace 256 * group "kernel message" (@see enum tracer_cfg_fields) is enabled. 257 * 258 * @param[in] msg Kernel message 259 **************************************************************************************** 260 */ 261 void dbg_trc_req_ke_msg_send(struct ke_msg const *msg); 262 263 /// Macro used to send trace request API for kernel message send 264 #define TRC_REQ_KE_MSG_SEND(msg) \ 265 dbg_trc_req_ke_msg_send(msg); 266 267 /** 268 **************************************************************************************** 269 * @brief Trace request API for kernel message handled 270 * 271 * This function is called when a task handles a message 272 * 273 * It checks the current tracer configuration and writes the trace in memory if the trace 274 * group "kernel message" (@see enum tracer_cfg_fields) is enabled. 275 * 276 * @param[in] id Kernel message id 277 * @param[in] dest_id Destination kernel identifier 278 * @param[in] src_id Source kernel identifier 279 * @param[in] msg_status Status returned by the kernel message handler 280 **************************************************************************************** 281 */ 282 void dbg_trc_req_ke_msg_handled(ke_msg_id_t const id, ke_task_id_t const dest_id, ke_task_id_t const src_id, uint8_t const msg_status); 283 284 /// Macro used to send trace request API for kernel message handled 285 #define TRC_REQ_KE_MSG_HANDLED(id, dest_id, src_id, msg_status) \ 286 dbg_trc_req_ke_msg_handled(id, dest_id, src_id, msg_status); 287 #else /*TRACER_PRESENT && TRC_KE_MSG*/ 288 #define TRC_REQ_KE_MSG_SEND(msg) 289 #define TRC_REQ_KE_MSG_HANDLED(id, dest_id, src_id, msg_status) 290 #endif /*TRACER_PRESENT && TRC_KE_MSG*/ 291 292 #if (TRACER_PRESENT && TRC_KE_TMR) 293 /** 294 **************************************************************************************** 295 * @brief Trace request API for kernel timer 296 * 297 * This function is called when a kernel timer is set, cleared or expired. 298 * 299 * It checks the current tracer configuration and writes the trace in memory if the trace 300 * group "kernel timer" (@see enum tracer_cfg_fields) is enabled. 301 * 302 * @param[in] tmr_trc_type Trace type for kernel timer (timer set, cleared and expired of @see enum trace_types) 303 * @param[in] target_time Timer time value 304 * @param[in] task_id Timer task identifier 305 * @param[in] msg_id Timer message identifier 306 **************************************************************************************** 307 */ 308 void dbg_trc_req_ke_tmr(uint8_t const tmr_trc_type, uint32_t const target_time, ke_task_id_t const task_id, ke_msg_id_t const msg_id); 309 310 /// Macro used to send trace request API for kernel timer set 311 #define TRC_REQ_KE_TMR_SET(target_time, task_id, msg_id) \ 312 dbg_trc_req_ke_tmr(KE_TMR_SET, target_time, task_id, msg_id); 313 314 /// Macro used to send trace request API for kernel timer cleared 315 #define TRC_REQ_KE_TMR_CLR(target_time, task_id, msg_id) \ 316 dbg_trc_req_ke_tmr(KE_TMR_CLR,target_time, task_id, msg_id); 317 318 /// Macro used to send trace request API for kernel timer expired 319 #define TRC_REQ_KE_TMR_EXP(target_time, task_id, msg_id) \ 320 dbg_trc_req_ke_tmr(KE_TMR_EXP,target_time, task_id, msg_id); 321 #else /*(TRACER_PRESENT && TRC_KE_TMR)*/ 322 #define TRC_REQ_KE_TMR_SET(target_time, task_id, msg_id) 323 #define TRC_REQ_KE_TMR_CLR(target_time, task_id, msg_id) 324 #define TRC_REQ_KE_TMR_EXP(target_time, task_id, msg_id) 325 #endif /*(TRACER_PRESENT && TRC_KE_TMR)*/ 326 327 #if (TRACER_PRESENT && TRC_KE_EVT) 328 /** 329 **************************************************************************************** 330 * @brief Trace request API for kernel event 331 * 332 * This function is called when a kernel event is set or handled. 333 * 334 * It checks the current tracer configuration and writes the trace in memory if the trace 335 * group "kernel event" (@see enum tracer_cfg_fields) is enabled. 336 * 337 * @param[in] evt_req_type Trace type for kernel event (event set and handled of @see enum trace_types) 338 * @param[in] event_type Type of event 339 **************************************************************************************** 340 */ 341 void dbg_trc_req_ke_evt(uint8_t const evt_trc_type, uint8_t const event_type); 342 343 /// Macro used to send trace request API for kernel event set 344 #define TRC_REQ_KE_EVT_SET(evt_type) \ 345 dbg_trc_req_ke_evt(KE_EVT_SET, evt_type); 346 347 /// Macro used to send trace request API for kernel event handled 348 #define TRC_REQ_KE_EVT_HANDLED(evt_type) \ 349 dbg_trc_req_ke_evt(KE_EVT_HANDLED, evt_type); 350 #else /*(TRACER_PRESENT && TRC_KE_EVT)*/ 351 #define TRC_REQ_KE_EVT_SET(evt_type) 352 #define TRC_REQ_KE_EVT_HANDLED(evt_type) 353 #endif /*(TRACER_PRESENT && TRC_KE_EVT)*/ 354 355 #if (TRACER_PRESENT && TRC_MEM) 356 /** 357 **************************************************************************************** 358 * @brief Trace request API for memory management 359 * 360 * This function is called when the memory is allocated or freed. 361 * 362 * It checks the current tracer configuration and writes the trace in memory if the trace 363 * group "memory" (@see enum tracer_cfg_fields) is enabled. 364 * 365 * @param[in] mem_trc_type Trace type for memory management (memory alloc and free of @see enum trace_types) 366 * @param[in] heap_id Heap identifier 367 * @param[in] blk_address Address of the used memory block 368 * @param[in] size Size of the memory area that has been allocated or freed. 369 **************************************************************************************** 370 */ 371 void dbg_trc_req_mem(uint8_t const mem_trc_type, uint8_t const heap_id, void const *blk_address, uint32_t const size); 372 373 /// Macro used to send trace request API for memory allocation 374 #define TRC_REQ_MEM_ALLOC(heap_id, blk_address, size) \ 375 dbg_trc_req_mem(MEM_ALLOC, heap_id, blk_address, size); 376 377 /// Macro used to send trace request API for memory deallocation 378 #define TRC_REQ_MEM_FREE(heap_id, blk_address, size) \ 379 dbg_trc_req_mem(MEM_FREE, heap_id, blk_address, size); 380 381 #else /*(TRACER_PRESENT && TRC_MEM)*/ 382 #define TRC_REQ_MEM_ALLOC(heap_id, blk_address, size) 383 #define TRC_REQ_MEM_FREE(heap_id, blk_address, size) 384 #endif/*(TRACER_PRESENT && TRC_MEM)*/ 385 386 #if (TRACER_PRESENT && TRC_SLEEP) 387 /** 388 **************************************************************************************** 389 * @brief Trace request API for sleep mode 390 * 391 * This function is called when the IP enter in deep sleep and when it wakes up. 392 * 393 * It checks the current tracer configuration and writes the trace in memory if the trace 394 * group "sleep" (@see enum tracer_cfg_fields) is enabled. 395 * 396 * @param[in] sleep_trc_type Trace type for sleep mode (sleep enter and wakeup of @see enum trace_types) 397 **************************************************************************************** 398 */ 399 void dbg_trc_req_deep_sleep(uint8_t const sleep_trc_type); 400 401 /// Macro used to send trace request API when the IP enters in deep sleep 402 #define TRC_REQ_SLEEP() \ 403 dbg_trc_req_deep_sleep(SLEEP_ENTER); 404 405 /// Macro used to send trace request API when the IP wakes up from deep sleep 406 #define TRC_REQ_WAKEUP() \ 407 dbg_trc_req_deep_sleep(SLEEP_WAKEUP); 408 409 #else /*(TRACER_PRESENT && TRC_SLEEP)*/ 410 #define TRC_REQ_SLEEP() 411 #define TRC_REQ_WAKEUP() 412 #endif /*(TRACER_PRESENT && TRC_SLEEP)*/ 413 414 #if (TRACER_PRESENT && TRC_SW_ASS) 415 /** 416 **************************************************************************************** 417 * @brief Trace request API for software asserts 418 * 419 * This function is called when an assertion statement is evaluated as true. 420 * 421 * It checks the current tracer configuration and writes the trace in memory if the trace 422 * group "sw assertions" (@see enum tracer_cfg_fields) is enabled. 423 * 424 * @param[in] ass_trc_type Trace type for assertions (assert warning and assert error of @see enum trace_types) 425 * @param[in] filename Name of the file that triggered the assertion 426 * @param[in] code_line Line of code where the assertion was triggered 427 * @param[in] param0 Parameter value 0 428 * @param[in] param1 Parameter value 1 429 **************************************************************************************** 430 */ 431 void dbg_trc_req_sw_ass(uint8_t const ass_trc_type, char const *filename, uint16_t const code_line, uint32_t const param0, uint32_t const param1); 432 433 /// Macro used to send trace request API when an assert warning is evaluated as true 434 #define TRC_REQ_SW_ASS_WARN(filename, code_line, param0, param1) \ 435 dbg_trc_req_sw_ass(ASSERT_WARNING, filename, code_line, param0, param1); 436 437 /// Macro used to send trace request API when an assert warning is evaluated as true 438 #define TRC_REQ_SW_ASS_ERR(filename, code_line, param0, param1) \ 439 dbg_trc_req_sw_ass(ASSERT_ERROR, filename, code_line, param0, param1); 440 441 #else /*(TRACER_PRESENT && TRC_SW_ASS)*/ 442 #define TRC_REQ_SW_ASS_WARN(filename, code_line, param0, param1) 443 #define TRC_REQ_SW_ASS_ERR(filename, code_line, param0, param1) 444 #endif /*(TRACER_PRESENT && TRC_SW_ASS)*/ 445 446 #if (TRACER_PRESENT && TRC_PROG) 447 /** 448 **************************************************************************************** 449 * @brief Trace request API for exchange table programming 450 * 451 * This function is called when the exchange table is programmed. 452 * 453 * It checks the current tracer configuration and writes the trace in memory if the trace 454 * group "programming" (@see enum tracer_cfg_fields) is enabled. 455 * 456 * @param[in] elt_idx Index of the programmed entry in the ET 457 **************************************************************************************** 458 */ 459 void dbg_trc_req_et_prog(uint8_t const elt_idx); 460 461 #define TRC_REQ_ET_PROG(elt_idx) \ 462 dbg_trc_req_et_prog(elt_idx); 463 464 /** 465 **************************************************************************************** 466 * @brief Trace request API for connection event counter programming 467 * 468 * This function is called when the connection event counter is set. 469 * 470 * It checks the current tracer configuration and writes the trace in memory if the trace 471 * group "programming" (@see enum tracer_cfg_fields) is enabled. 472 * 473 * @param[in] conhdl Connection handle 474 * @param[in] value Value of connection event counter 475 **************************************************************************************** 476 */ 477 void dbg_trc_req_evt_cnt(uint16_t const conhdl, uint16_t const value); 478 #define TRC_REQ_EVT_CNT(conhdl, value) \ 479 dbg_trc_req_evt_cnt(conhdl, value); 480 /** 481 **************************************************************************************** 482 * @brief Trace request API for frame completion 483 * 484 * This function is called when a frame is completed. 485 * 486 * It checks the current tracer configuration and writes the trace in memory if the trace 487 * group "programming" (@see enum tracer_cfg_fields) is enabled. 488 * 489 * @param[in] timestamp Timestamp of the programmed frame (in BLE slots, based on local clock) 490 * @param[in] frm_id Frame identifier 491 * @param[in] frm_cbk Callback for handling interrupts related to the frame 492 **************************************************************************************** 493 */ 494 void dbg_trc_req_frm_cmp(uint32_t const timestamp, uint8_t const frm_id, uint32_t const frm_cbk); 495 496 #define TRC_REQ_FRM_CMP(timestamp, frm_id, frm_cbk) \ 497 dbg_trc_req_frm_cmp(timestamp, frm_id, frm_cbk); 498 499 #else /*(TRACER_PRESENT && TRC_PROG)*/ 500 #define TRC_REQ_ET_PROG(elt_idx) 501 #define TRC_REQ_EVT_CNT(conhdl, value) 502 #define TRC_REQ_FRM_CMP(timestamp, frm_id, frm_cbk) 503 #endif /*(TRACER_PRESENT && TRC_PROG)*/ 504 505 #if (TRACER_PRESENT && TRC_CS_BLE) 506 /** 507 **************************************************************************************** 508 * @brief Trace request API for control structure programming in BLE 509 * 510 * This function is called when a control structure is modified. 511 * 512 * It checks the current tracer configuration and writes the trace in memory if the trace 513 * group "BLE control structure" (@see enum tracer_cfg_fields) is enabled. 514 * 515 * @param[in] cs_addr Address of the control structure in the exchange memory 516 **************************************************************************************** 517 */ 518 void dbg_trc_req_cs_ble(uint16_t const cs_addr); 519 520 #define TRC_REQ_CS_BLE(cs_addr) \ 521 dbg_trc_req_cs_ble(cs_addr); 522 523 #else /*(TRACER_PRESENT && TRC_CS_BLE)*/ 524 #define TRC_REQ_CS_BLE(cs_addr) 525 #endif /*(TRACER_PRESENT && TRC_CS_BLE)*/ 526 527 #if (TRACER_PRESENT && TRC_CS_BT) 528 /** 529 **************************************************************************************** 530 * @brief Trace request API for control structure programming in BT 531 * 532 * This function is called when a control structure is modified. 533 * 534 * It checks the current tracer configuration and writes the trace in memory if the trace 535 * group "BT control structure" (@see enum tracer_cfg_fields) is enabled. 536 * 537 * @param[in] cs_addr Address of the control structure in the exchange memory 538 **************************************************************************************** 539 */ 540 void dbg_trc_req_cs_bt(uint16_t const cs_addr); 541 542 #define TRC_REQ_CS_BT(cs_addr) \ 543 dbg_trc_req_cs_bt(cs_addr); 544 #else /*(TRACER_PRESENT && TRC_CS_BT)*/ 545 #define TRC_REQ_CS_BT(cs_addr) 546 #endif /*(TRACER_PRESENT && TRC_CS_BT)*/ 547 548 #if (TRACER_PRESENT && TRC_RX_DESC) 549 /** 550 **************************************************************************************** 551 * @brief Trace request API for processing of rx descriptors 552 * 553 * This function is called when a packet is received and a driver processes a rx descriptor. 554 * 555 * It checks the current tracer configuration and writes the trace in memory if the trace 556 * group "Rx descriptor" (@see enum tracer_cfg_fields) is enabled. 557 * 558 * @param[in] drv_type LLD driver (@see enum driver_type) 559 * @param[in] act_id Activity identifier 560 * @param[in] rx_desc_add Address of the rx descriptor in the exchange memory 561 **************************************************************************************** 562 */ 563 void dbg_trc_req_rx_desc(uint8_t const drv_type, uint8_t const act_id, uint16_t const rx_desc_add); 564 565 #define TRC_REQ_RX_DESC(drv_type, act_id, rx_desc_add) \ 566 dbg_trc_req_rx_desc(drv_type, act_id, rx_desc_add); 567 568 #else /*(TRACER_PRESENT && TRC_RX_DESC)*/ 569 #define TRC_REQ_RX_DESC(drv_type, act_id, rx_desc_add) 570 #endif /*(TRACER_PRESENT && TRC_RX_DESC) */ 571 572 #if (TRACER_PRESENT && TRC_LLCP) 573 /** 574 **************************************************************************************** 575 * @brief Trace request API for llcp packets transmission, reception and acknowledgment 576 * 577 * This function is called when a llcp packet is transmitted, received or acknowledged. 578 * 579 * It checks the current tracer configuration and writes the trace in memory if the trace 580 * group "LLCP" (@see enum tracer_cfg_fields) is enabled. 581 * 582 * @param[in] llcp_trc_type Trace type for llcp (llcp tx, llcp rx and llcp ack of @see enum trace_types) 583 * @param[in] conhdl Connection handle 584 * @param[in] data_len Data length (in bytes) 585 * @param[in] pdu_data PDU Data 586 **************************************************************************************** 587 */ 588 void dbg_trc_req_llcp(uint8_t const llcp_trc_type, uint16_t const conhdl, uint8_t const data_len, uint8_t const *pdu_data); 589 590 /// Macro used to send trace request API when an llcp packet is transmitted 591 #define TRC_REQ_LLCP_TX(conhdl, data_len, pdu_data) \ 592 dbg_trc_req_llcp(LLCP_TX, conhdl, data_len, pdu_data); 593 594 /// Macro used to send trace request API when an llcp packet is received 595 #define TRC_REQ_LLCP_RX(conhdl, data_len, pdu_data) \ 596 dbg_trc_req_llcp(LLCP_RX, conhdl, data_len, pdu_data); 597 598 /// Macro used to send trace request API when an llcp packet is acknowledged 599 #define TRC_REQ_LLCP_ACK(conhdl, data_len, pdu_data) \ 600 dbg_trc_req_llcp(LLCP_ACK, conhdl, data_len, pdu_data); 601 #else /*(TRACER_PRESENT && TRC_LLCP)*/ 602 #define TRC_REQ_LLCP_TX(conhdl, data_len, pdu_data) 603 #define TRC_REQ_LLCP_RX(conhdl, data_len, pdu_data) 604 #define TRC_REQ_LLCP_ACK(conhdl, data_len, pdu_data) 605 #endif /*(TRACER_PRESENT && TRC_LLCP) */ 606 607 #if (TRACER_PRESENT && TRC_LMP) 608 /** 609 **************************************************************************************** 610 * @brief Trace request API for lmp packets transmission, reception and acknowledgment 611 * 612 * This function is called when a lmp packet is transmitted, received or acknowledged. 613 * 614 * It checks the current tracer configuration and writes the trace in memory if the trace 615 * group "LMP" (@see enum tracer_cfg_fields) is enabled. 616 * 617 * @param[in] llcp_trc_type Trace type for lmp (lmp tx, lmp rx and lmp ack of @see enum trace_types) 618 * @param[in] conhdl Connection handle 619 * @param[in] data_len Data length (in bytes) 620 * @param[in] pdu_data PDU Data 621 **************************************************************************************** 622 */ 623 void dbg_trc_req_lmp(uint8_t const lmp_trc_type, uint16_t const conhdl, uint8_t const data_len, uint8_t const *pdu_data); 624 625 /// Macro used to send trace request API when an lmp packet is transmitted 626 #define TRC_REQ_LMP_TX(conhdl, data_len, pdu_data) \ 627 dbg_trc_req_lmp(LMP_TX, conhdl, data_len, pdu_data); 628 629 /// Macro used to send trace request API when an lmp packet is received 630 #define TRC_REQ_LMP_RX(conhdl, data_len, pdu_data) \ 631 dbg_trc_req_lmp(LMP_RX, conhdl, data_len, pdu_data); 632 633 /// Macro used to send trace request API when an lmp packet is acknowledged 634 #define TRC_REQ_LMP_ACK(conhdl, data_len, pdu_data) \ 635 dbg_trc_req_lmp(LMP_ACK, conhdl, data_len, pdu_data); 636 637 #else /*(TRACER_PRESENT && TRC_LMP)*/ 638 #define TRC_REQ_LMP_TX(conhdl, data_len, pdu_data) 639 #define TRC_REQ_LMP_RX(conhdl, data_len, pdu_data) 640 #define TRC_REQ_LMP_ACK(conhdl, data_len, pdu_data) 641 #endif /*(TRACER_PRESENT && TRC_LMP)*/ 642 643 #if (TRACER_PRESENT && TRC_L2CAP) 644 /** 645 **************************************************************************************** 646 * @brief Trace request API for l2cap packets transmission and reception 647 * 648 * This function is called when a l2cap packet is transmitted or received. 649 * 650 * It checks the current tracer configuration and writes the trace in memory if the trace 651 * group "L2CAP" (@see enum tracer_cfg_fields) is enabled. 652 * 653 * @param[in] l2cap_trc_type Trace type for l2cap (l2cap tx and l2cap rx of @see enum trace_types) 654 * @param[in] conhdl Connection handle 655 * @param[in] data_len Data length (in bytes) 656 * @param[in] buf_ptr Memory pointer address 657 **************************************************************************************** 658 */ 659 void dbg_trc_req_l2cap(uint8_t const l2cap_trc_type, uint16_t const conhdl, uint16_t const data_len, uint32_t const buf_ptr); 660 661 /// Macro used to send trace request API when an l2cap packet is transmitted 662 #define TRC_REQ_L2CAP_TX(conhdl, tx_len, buf_ptr) \ 663 dbg_trc_req_l2cap(L2CAP_TX, conhdl, tx_len, buf_ptr); 664 665 /// Macro used to send trace request API when an l2cap packet is received 666 #define TRC_REQ_L2CAP_RX(conhdl, tx_len, buf_ptr) \ 667 dbg_trc_req_l2cap(L2CAP_RX, conhdl, tx_len, buf_ptr); 668 669 /** 670 **************************************************************************************** 671 * @brief Trace request API for l2cap packet acknowledgment 672 * 673 * This function is called when l2cap packets are acknowledged. 674 * 675 * It checks the current tracer configuration and writes the trace in memory if the trace 676 * group "L2CAP" (@see enum tracer_cfg_fields) is enabled. 677 * 678 * @param[in] conhdl Connection handle 679 * @param[in] num_ack_pkts Number of acknowledged l2cap packets 680 **************************************************************************************** 681 */ 682 void dbg_trc_req_l2cap_ack(uint16_t const conhdl, uint16_t const num_ack_pkts); 683 684 #define TRC_REQ_L2CAP_ACK(conhdl, num_ack_pkts) \ 685 dbg_trc_req_l2cap_ack(conhdl, num_ack_pkts); 686 687 #else /*(TRACER_PRESENT && TRC_L2CAP)*/ 688 #define TRC_REQ_L2CAP_TX(conhdl, tx_len, buf_ptr) 689 #define TRC_REQ_L2CAP_RX(conhdl, tx_len, buf_ptr) 690 #define TRC_REQ_L2CAP_ACK(conhdl, num_ack_pkts) 691 #endif/*(TRACER_PRESENT && TRC_L2CAP) */ 692 693 #if (TRACER_PRESENT && TRC_EA) 694 /** 695 **************************************************************************************** 696 * @brief Trace request API for cancellation, removal and starting of events 697 * 698 * This function is called when an event starts, is removed or is cancelled. 699 * 700 * It checks the current tracer configuration and writes the trace in memory if the trace 701 * group "EA" (@see enum tracer_cfg_fields) is enabled. 702 * 703 * @param[in] ea_trc_type Trace type for event arbiter (cancel, remove and start of @see enum trace_types) 704 * @param[in] ea_elt Pointer to the event arbiter element 705 **************************************************************************************** 706 */ 707 void dbg_trc_req_ea(uint8_t const ea_trc_type,const struct ea_elt_tag *ea_elt); 708 709 /// Macro used to send trace request API when an event is cancelled 710 #define TRC_REQ_EA_CANC(ea_elt) \ 711 dbg_trc_req_ea(EA_CANC, ea_elt); 712 713 /// Macro used to send trace request API when an event is removed 714 #define TRC_REQ_EA_REM(ea_elt) \ 715 dbg_trc_req_ea(EA_REM, ea_elt); 716 717 /// Macro used to send trace request API when an event starts 718 #define TRC_REQ_EA_START(ea_elt) \ 719 dbg_trc_req_ea(EA_START, ea_elt); 720 721 /** 722 **************************************************************************************** 723 * @brief Trace request API for shifting of events 724 * 725 * This function is called when an event is shifted. 726 * 727 * It checks the current tracer configuration and writes the trace in memory if the trace 728 * group "EA" (@see enum tracer_cfg_fields) is enabled. 729 * 730 * @param[in] ea_elt Pointer to the event arbiter element 731 **************************************************************************************** 732 */ 733 void dbg_trc_req_ea_shift(const struct ea_elt_tag *ea_elt); 734 735 #define TRC_REQ_EA_SHIFT(ea_elt) \ 736 dbg_trc_req_ea_shift(ea_elt); 737 /** 738 **************************************************************************************** 739 * @brief Trace request API for pushing of event in the waiting queue 740 * 741 * This function is called when an event is pushed in the waiting queue. 742 * 743 * It checks the current tracer configuration and writes the trace in memory if the trace 744 * group "EA" (@see enum tracer_cfg_fields) is enabled. 745 * 746 * @param[in] ea_elt Pointer to the event arbiter element 747 **************************************************************************************** 748 */ 749 void dbg_trc_req_ea_insert(uint32_t const target_time, uint8_t const status, const struct ea_elt_tag *ea_elt); 750 751 #define TRC_REQ_EA_INSERT(target_time, status, ea_elt) \ 752 dbg_trc_req_ea_insert(target_time, status, ea_elt); 753 754 #else /*(TRACER_PRESENT && TRC_EA)*/ 755 #define TRC_REQ_EA_CANC(ea_elt) 756 #define TRC_REQ_EA_REM(ea_elt) 757 #define TRC_REQ_EA_START(ea_elt) 758 #define TRC_REQ_EA_SHIFT(ea_elt) 759 #define TRC_REQ_EA_INSERT(target_time, status, ea_elt) 760 #endif /*(TRACER_PRESENT && TRC_EA)*/ 761 762 #if (TRACER_PRESENT && TRC_LC_STATE_TRANS) 763 /** 764 **************************************************************************************** 765 * @brief Trace request API for lc procedure state transition 766 * 767 * This function is called when an lc procedure changes its state. 768 * 769 * It checks the current tracer configuration and writes the trace in memory if the trace 770 * group "LC state transition" (@see enum tracer_cfg_fields) is enabled. 771 * 772 * @param[in] conhdl Connection handle 773 * @param[in] proc_type LC procedure 774 * @param[in] prev_state Previous procedure state 775 * @param[in] curr_state Current procedure state 776 **************************************************************************************** 777 */ 778 void dbg_trc_req_lc_state_trans(uint16_t const conhdl, uint8_t const proc_type, uint8_t const prev_state, uint8_t const curr_state); 779 780 #define TRC_REQ_LC_STATE_TRANS(conhdl, proc_type, prev_state, curr_state) \ 781 dbg_trc_req_lc_state_trans(conhdl, proc_type, prev_state, curr_state); 782 783 #else /*(TRACER_PRESENT && TRC_LC_STATE_TRANS)*/ 784 #define TRC_REQ_LC_STATE_TRANS(conhdl, proc_type, prev_state, curr_state) 785 #endif /*(TRACER_PRESENT && TRC_LC_STATE_TRANS)*/ 786 787 #if (TRACER_PRESENT && TRC_LLC_STATE_TRANS) 788 /** 789 **************************************************************************************** 790 * @brief Trace request API for llc procedure state transition 791 * 792 * This function is called when an llcp procedure changes its state. 793 * 794 * It checks the current tracer configuration and writes the trace in memory if the trace 795 * group "LLC state transition" (@see enum tracer_cfg_fields) is enabled. 796 * 797 * @param[in] conhdl Connection handle 798 * @param[in] proc_type LLC procedure 799 * @param[in] prev_state Previous procedure state 800 * @param[in] curr_state Current procedure state 801 **************************************************************************************** 802 */ 803 void dbg_trc_req_llc_state_trans(uint16_t const conhdl, uint8_t const proc_type, uint8_t const prev_state, uint8_t const curr_state); 804 805 #define TRC_REQ_LLC_STATE_TRANS(conhdl, proc_type, prev_state, curr_state) \ 806 dbg_trc_req_llc_state_trans(conhdl, proc_type, prev_state, curr_state); 807 808 #else /*(TRACER_PRESENT && TRC_LLC_STATE_TRANS)*/ 809 #define TRC_REQ_LLC_STATE_TRANS(conhdl, proc_type, prev_state, curr_state) 810 #endif /*(TRACER_PRESENT && TRC_LLC_STATE_TRANS)*/ 811 812 #if (TRACER_PRESENT && TRC_HCI) 813 /** 814 **************************************************************************************** 815 * @brief Trace request API for HCI messages (in FE mode) 816 * 817 * This function is called when a HCI command is received or a HCI event is sent. 818 * 819 * It checks the current tracer configuration and writes the trace in memory if the trace 820 * group "HCI" (@see enum tracer_cfg_fields) is enabled. 821 * 822 * @param[in] hci_msg_type Type of hci message (HCI command and event of @see enum trace_types) 823 * @param[in] opcode HCI opcode 824 * @param[in] par_len HCI parameter length 825 * @param[in] params unpacked HCI parameters 826 **************************************************************************************** 827 */ 828 void dbg_trc_req_hci(uint8_t const hci_msg_type, uint16_t const opcode, uint16_t const par_len, uint32_t const *params); 829 830 /// Macro used to send trace request API when an HCI command is received 831 #define TRC_REQ_HCI_CMD(opcode, par_len, params) \ 832 dbg_trc_req_hci(HCI_CMD, opcode, par_len, params); 833 834 /// Macro used to send trace request API when an HCI event is sent 835 #define TRC_REQ_HCI_EVT(opcode, par_len, params) \ 836 dbg_trc_req_hci(HCI_EVT, opcode, par_len, params); 837 838 #else /*(TRACER_PRESENT && TRC_HCI)*/ 839 #define TRC_REQ_HCI_CMD(opcode, par_len, params) 840 #define TRC_REQ_HCI_EVT(opcode, par_len, params) 841 #endif /*(TRACER_PRESENT && TRC_HCI)*/ 842 843 #if (TRACER_PRESENT && TRC_CUSTOM) 844 /** 845 **************************************************************************************** 846 * @brief Trace request API for custom traces 847 * 848 * This function is called to send a custom trace. 849 * 850 * It checks the current tracer configuration and writes the trace in memory if the trace 851 * group "custom" (@see enum tracer_cfg_fields) is enabled. 852 * 853 * @param[in] trc_id Trace request identifier (progressive number that identifies the caller) 854 * @param[in] data_type Type of data (@see enum custom_trace_type) 855 * @param[in] data Pointer to the data to send 856 **************************************************************************************** 857 */ 858 void dbg_trc_req_custom(const uint8_t trc_id, const uint8_t data_type, void const *data); 859 #define TRC_REQ_CUSTOM(trc_id, data_type, data) \ 860 dbg_trc_req_custom(trc_id, data_type, data); 861 #else /*(TRACER_PRESENT && TRC_CUSTOM)*/ 862 #define TRC_REQ_CUSTOM(trc_id, data_type, data) 863 #endif /*(TRACER_PRESENT && TRC_CUSTOM)*/ 864 865 #if (TRACER_PRESENT) 866 /** 867 **************************************************************************************** 868 * @brief Configuration received 869 * 870 * This function checks if the received configuration can be adopted and acknowledges it 871 * 872 **************************************************************************************** 873 */ 874 void dbg_trc_cfg_received(); 875 876 /** 877 **************************************************************************************** 878 * @brief Get the reception buffer for configuration word 879 * 880 * @return Buffer for payload reception of tracer configuration packets 881 **************************************************************************************** 882 */ 883 uint8_t* dbg_trc_pay_buff_get(); 884 #endif /*(TRACER_PRESENT)*/ 885 ///@} TRACER 886 #endif // DBG_TRC_H_ 887