3636#include "MAC/IEEE802_15_4/mac_mcps_sap.h"
3737#include "MAC/IEEE802_15_4/mac_cca_threshold.h"
3838#include "MAC/rf_driver_storage.h"
39+ #include "ns_trace.h"
40+
41+ #define TRACE_GROUP "mPDs"
3942
4043/* Define TX Timeot Period */
4144// Hardcoded to 1200ms. Should be changed dynamic: (FHSS) channel retries needs longer timeout
@@ -373,6 +376,9 @@ static void mac_sap_cca_fail_cb(protocol_interface_rf_mac_setup_s *rf_ptr, uint
373376
374377static void mac_sap_no_ack_cb (protocol_interface_rf_mac_setup_s * rf_ptr )
375378{
379+ #ifdef TIMING_TOOL_TRACES
380+ tr_info ("%u no_ack" , mac_mcps_sap_get_phy_timestamp (rf_ptr ));
381+ #endif
376382 rf_ptr -> macRfRadioTxActive = false;
377383 if (rf_ptr -> mac_tx_retry < rf_ptr -> mac_mlme_retry_max ) {
378384 rf_ptr -> mac_cca_retry = 0 ;
@@ -438,6 +444,9 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
438444 if (rf_ptr -> mac_ack_tx_active ) {
439445 //Accept direct non crypted acks and crypted only if neighbor is at list
440446 if (rf_ptr -> ack_tx_possible ) {
447+ #ifdef TIMING_TOOL_TRACES
448+ tr_info ("%u TX_start %u" , mac_mcps_sap_get_phy_timestamp (rf_ptr ), rf_ptr -> mac_channel );
449+ #endif
441450 return PHY_TX_ALLOWED ;
442451 }
443452
@@ -454,6 +463,9 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
454463 }
455464
456465 if (mac_data_asynch_channel_switch (rf_ptr , rf_ptr -> active_pd_data_request )) {
466+ #ifdef TIMING_TOOL_TRACES
467+ tr_info ("%u TX_start %u" , mac_mcps_sap_get_phy_timestamp (rf_ptr ), rf_ptr -> mac_channel );
468+ #endif
457469 rf_ptr -> active_pd_data_request -> initial_tx_channel = rf_ptr -> mac_channel ;
458470 int8_t channel_cca_threshold = mac_cca_thr_get_dbm (rf_ptr , rf_ptr -> mac_channel );
459471 if (CCA_FAILED_DBM != channel_cca_threshold ) {
@@ -501,12 +513,17 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
501513 return PHY_RESTART_CSMA ;
502514 }
503515 }
504-
516+ #ifdef TIMING_TOOL_TRACES
517+ tr_info ("%u TX_start %u" , mac_mcps_sap_get_phy_timestamp (rf_ptr ), rf_ptr -> mac_channel );
518+ #endif
505519 return 0 ;
506520 }
507521
508522 if (rf_ptr -> mac_ack_tx_active ) {
509523 mac_data_ack_tx_finish (rf_ptr );
524+ #ifdef TIMING_TOOL_TRACES
525+ tr_info ("%u TX_done" , mac_mcps_sap_get_phy_timestamp (rf_ptr ));
526+ #endif
510527 return 0 ;
511528 } else {
512529
@@ -531,6 +548,11 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
531548 * PHY_LINK_TX_FAIL either happened during transmission or when waiting Ack -> we must use the CCA count given by PHY.
532549 */
533550 if ((cca_retry == 0 ) && (status != PHY_LINK_TX_FAIL )) {
551+ #ifdef TIMING_TOOL_TRACES
552+ if (status != PHY_LINK_CCA_FAIL ) {
553+ tr_info ("%u TX_done" , mac_mcps_sap_get_phy_timestamp (rf_ptr ));
554+ }
555+ #endif
534556 cca_retry = 1 ;
535557 }
536558 rf_ptr -> mac_tx_status .cca_cnt += cca_retry ;
@@ -970,6 +992,10 @@ int8_t mac_pd_sap_data_cb(void *identifier, arm_phy_sap_msg_t *message)
970992 if (pd_data_ind -> data_len < 3 ) {
971993 return -1 ;
972994 }
995+ #ifdef TIMING_TOOL_TRACES
996+ tr_info ("%u RX_start" , mac_pd_sap_get_phy_rx_time (rf_ptr ));
997+ tr_info ("%u RX_done" , mac_mcps_sap_get_phy_timestamp (rf_ptr ));
998+ #endif
973999 mac_cca_threshold_event_send (rf_ptr , rf_ptr -> mac_channel , pd_data_ind -> dbm );
9741000 mac_fcf_sequence_t fcf_read ;
9751001 const uint8_t * ptr = mac_header_parse_fcf_dsn (& fcf_read , pd_data_ind -> data_ptr );
0 commit comments