drivers: ieee802154_nrf5: Add CSMA CA transmit capability

Add CSMA CA capability for the `ieee802154_nrf5` radio driver along with
appropriate implementation in the `nrf5_tx` function.

Introduce 802.15.4 radio driver with CSMA/CA support enabled. Add help
text, mentioning a list of peripherals occupied by the radio driver.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2020-03-13 09:21:55 +01:00 committed by Jukka Rissanen
commit d657c6bf57
3 changed files with 35 additions and 12 deletions

View file

@ -48,7 +48,12 @@ struct nrf5_802154_config {
static struct nrf5_802154_data nrf5_data;
#define ACK_TIMEOUT K_MSEC(10)
/* Increase ACK timeout to cover the maximum CSMA CA time in default
* configuration. 40ms is enough time to cover worst-case CSMA/CA scenario in
* default configuration (CSMA/CA + transmit + ACK delay).
* TODO Switch to ACK timeout at driver level.
*/
#define ACK_TIMEOUT K_MSEC(40)
/* Convenience defines for RADIO */
#define NRF5_802154_DATA(dev) \
@ -143,12 +148,11 @@ drop:
static enum ieee802154_hw_caps nrf5_get_capabilities(struct device *dev)
{
return IEEE802154_HW_FCS | IEEE802154_HW_2_4_GHZ |
IEEE802154_HW_TX_RX_ACK | IEEE802154_HW_FILTER |
IEEE802154_HW_ENERGY_SCAN;
return IEEE802154_HW_FCS | IEEE802154_HW_FILTER |
IEEE802154_HW_CSMA | IEEE802154_HW_2_4_GHZ |
IEEE802154_HW_TX_RX_ACK | IEEE802154_HW_ENERGY_SCAN;
}
static int nrf5_cca(struct device *dev)
{
struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev);
@ -329,11 +333,7 @@ static int nrf5_tx(struct device *dev,
struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev);
u8_t payload_len = frag->len;
u8_t *payload = frag->data;
if (mode != IEEE802154_TX_MODE_DIRECT) {
NET_ERR("TX mode %d not supported", mode);
return -ENOTSUP;
}
bool ret = true;
LOG_DBG("%p (%u)", payload, payload_len);
@ -343,7 +343,24 @@ static int nrf5_tx(struct device *dev,
/* Reset semaphore in case ACK was received after timeout */
k_sem_reset(&nrf5_radio->tx_wait);
if (!nrf_802154_transmit_raw(nrf5_radio->tx_psdu, false)) {
switch (mode) {
case IEEE802154_TX_MODE_DIRECT:
ret = nrf_802154_transmit_raw(nrf5_radio->tx_psdu, false);
break;
case IEEE802154_TX_MODE_CCA:
ret = nrf_802154_transmit_raw(nrf5_radio->tx_psdu, true);
break;
case IEEE802154_TX_MODE_CSMA_CA:
nrf_802154_transmit_csma_ca_raw(nrf5_radio->tx_psdu);
break;
case IEEE802154_TX_MODE_TXTIME:
case IEEE802154_TX_MODE_TXTIME_CCA:
default:
NET_ERR("TX mode %d not supported", mode);
return -ENOTSUP;
}
if (!ret) {
LOG_ERR("Cannot send frame");
return -EIO;
}

View file

@ -11,6 +11,12 @@ menu "Nordic drivers"
menuconfig NRF_802154_RADIO_DRIVER
bool "Enable nRF IEEE 802.15.4 radio driver"
depends on HAS_HW_NRF_RADIO_IEEE802154
help
This option enables nRF IEEE 802.15.4 radio driver in Zephyr. Note,
that beside the radio peripheral itself, this drivers occupies several
other peripherals. A complete list can be found in the hal_nordic
repository, within drivers/nrf_radio_802154/nrf_802154_peripherals.h
file.
if NRF_802154_RADIO_DRIVER

View file

@ -53,7 +53,7 @@ manifest:
revision: a12d92816a53a521d79cefcf5c38b9dc8a4fed6e
path: modules/hal/cypress
- name: hal_nordic
revision: 59d33bc1dd59df14feb26f0010d527c1ea7a89e8
revision: 0774efffa3d095025a55611719020fa23278eeda
path: modules/hal/nordic
- name: hal_openisa
revision: 3b54187649cc9b37161d49918f1ad28ff7c7f830