From cd1afb17c303288d8b87450c150bf55d4b1d3b4c Mon Sep 17 00:00:00 2001 From: Jarkko Paso Date: Mon, 18 Feb 2019 12:52:18 +0200 Subject: [PATCH] MAC: Fixed aborting active TX when sending Ack --- source/MAC/IEEE802_15_4/mac_mcps_sap.c | 2 +- source/MAC/IEEE802_15_4/mac_pd_sap.c | 14 ++++++++++++++ source/MAC/IEEE802_15_4/mac_pd_sap.h | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/MAC/IEEE802_15_4/mac_mcps_sap.c b/source/MAC/IEEE802_15_4/mac_mcps_sap.c index b884b2c0f135..5ff3bd488976 100644 --- a/source/MAC/IEEE802_15_4/mac_mcps_sap.c +++ b/source/MAC/IEEE802_15_4/mac_mcps_sap.c @@ -1740,7 +1740,7 @@ int8_t mcps_generic_ack_build(protocol_interface_rf_mac_setup_s *rf_ptr, const m rf_ptr->dev_driver->phy_driver->extension(PHY_EXTENSION_SET_CSMA_PARAMETERS, (uint8_t *) &csma_params); if (rf_ptr->active_pd_data_request) { timer_mac_stop(rf_ptr); - mac_pd_sap_set_phy_tx_time(rf_ptr, 0, false); + mac_pd_abort_active_tx(rf_ptr); } return mcps_pd_data_cca_trig(rf_ptr, buffer); } diff --git a/source/MAC/IEEE802_15_4/mac_pd_sap.c b/source/MAC/IEEE802_15_4/mac_pd_sap.c index 0e1a760b7f44..fb403c4fcf9b 100644 --- a/source/MAC/IEEE802_15_4/mac_pd_sap.c +++ b/source/MAC/IEEE802_15_4/mac_pd_sap.c @@ -199,6 +199,20 @@ int8_t mac_pd_sap_req(protocol_interface_rf_mac_setup_s *rf_mac_setup) } +/** + * Abort active PHY transmission. + * + * \param rf_mac_setup pointer to MAC. + * + */ +void mac_pd_abort_active_tx(protocol_interface_rf_mac_setup_s *rf_mac_setup) +{ + phy_csma_params_t csma_params; + // Set TX time to 0 to abort current transmission + csma_params.backoff_time = 0; + rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_SET_CSMA_PARAMETERS, (uint8_t *) &csma_params); +} + /** * Set PHY TX time. * diff --git a/source/MAC/IEEE802_15_4/mac_pd_sap.h b/source/MAC/IEEE802_15_4/mac_pd_sap.h index d6364ba52749..9df0f4a0e5e1 100644 --- a/source/MAC/IEEE802_15_4/mac_pd_sap.h +++ b/source/MAC/IEEE802_15_4/mac_pd_sap.h @@ -39,6 +39,8 @@ int8_t mac_pd_sap_req(struct protocol_interface_rf_mac_setup *rf_mac_setup); int8_t mac_plme_cca_req(struct protocol_interface_rf_mac_setup *rf_mac_setup); +void mac_pd_abort_active_tx(struct protocol_interface_rf_mac_setup *rf_mac_setup); + void mac_pd_sap_set_phy_tx_time(struct protocol_interface_rf_mac_setup *rf_mac_setup, uint32_t tx_time, bool cca_enabled); void mac_pd_sap_rf_low_level_function_set(void *mac_ptr, void *driver);