From 3c56cdf0c076ffcb4da0235565018515618f08f1 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Fri, 8 Jan 2021 11:38:02 +0100 Subject: [PATCH] cc2538_rf/radio_hal: fix transmit function This commit sets the correct value to the MCU_CTRL bit for the cc2538_rf. This variable is used to detect when the radio is doing transmission with CCA. Since this was not set to 1 when sending without CCA, the `confirm_transmit` function returned -EAGAIN after the TX_DONE event (which violates the HAL API). This error was discovered using some Radio HAL riotctrl scripts by @LarsKowoll. --- cpu/cc2538/radio/cc2538_rf_radio_ops.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpu/cc2538/radio/cc2538_rf_radio_ops.c b/cpu/cc2538/radio/cc2538_rf_radio_ops.c index dcb400567f13..66f32fe85970 100644 --- a/cpu/cc2538/radio/cc2538_rf_radio_ops.c +++ b/cpu/cc2538/radio/cc2538_rf_radio_ops.c @@ -93,6 +93,13 @@ static int _request_transmit(ieee802154_dev_t *dev) if (cc2538_csma_ca_retries < 0) { RFCORE_SFR_RFST = ISTXON; + /* The CPU Ctrl mask is used here to indicate whether the radio is being + * controlled by the CPU or the CSP Strobe Processor. + * We set this to 1 in order to indicate that the CSP is not used and + * thus, that the @ref ieee802154_radio_ops::confirm_transmit should + * return 0 immediately after the TXDONE event + */ + RFCORE_XREG_CSPCTRL |= CC2538_CSP_MCU_CTRL_MASK; } else { cc2538_cca = false;