drivers: ieee802154: nrf5: Add support for tx in the future

Add support for transmission modes that send a packet
at a specific time in the future.
Remove TXTIME, TXTIME_CCA, CSMA_CA capabilities and their calls when
they are not supported by selected drivers. Add TXTIME flag in
get_capabilites function.

Signed-off-by: Maciej Fabia <maciej.fabia@nordicsemi.no>
Signed-off-by: Pawel Kwiek <pawel.kwiek@nordicsemi.no>
This commit is contained in:
Maciej Fabia 2020-09-28 12:01:30 +02:00 committed by Jukka Rissanen
commit 1ca9b38946
2 changed files with 40 additions and 0 deletions

View file

@ -43,4 +43,13 @@ config IEEE802154_NRF5_EXT_IRQ_MGMT
the system. One example of external radio IRQ provider could be
a radio arbiter used in dynamic multiprotocol applications.
config IEEE802154_NRF5_PKT_TXTIME
bool "Driver's TX time support"
depends on !NRF_802154_SL_OPENSOURCE && !NRF_802154_SER_HOST
depends on NET_PKT_TXTIME
default y
help
Enable TX time support. This is needed when upper layers want
to set the exact time when the packet should be sent.
endif

View file

@ -56,6 +56,7 @@ static struct nrf5_802154_data nrf5_data;
#define ACK_REQUEST_BIT (1 << 5)
#define FRAME_PENDING_BYTE 1
#define FRAME_PENDING_BIT (1 << 4)
#define TXTIME_OFFSET_US (5 * USEC_PER_MSEC)
#if defined(CONFIG_SOC_NRF5340_CPUAPP) || defined(CONFIG_SOC_NRF5340_CPUNET)
#define EUI64_ADDR (NRF_FICR->INFO.DEVICEID)
@ -193,6 +194,9 @@ static enum ieee802154_hw_caps nrf5_get_capabilities(const struct device *dev)
#if !defined(CONFIG_NRF_802154_SL_OPENSOURCE) && \
!defined(CONFIG_NRF_802154_SER_HOST)
IEEE802154_HW_CSMA |
#ifdef CONFIG_IEEE802154_NRF5_PKT_TXTIME
IEEE802154_HW_TXTIME |
#endif /* CONFIG_IEEE802154_NRF5_PKT_TXTIME */
#endif
IEEE802154_HW_2_4_GHZ |
IEEE802154_HW_TX_RX_ACK |
@ -385,6 +389,24 @@ static void nrf5_tx_started(const struct device *dev,
}
}
#ifdef CONFIG_IEEE802154_NRF5_PKT_TXTIME
static bool nrf5_tx_at(struct net_pkt *pkt, bool cca)
{
uint32_t tx_at = net_pkt_txtime(pkt) / NSEC_PER_USEC;
bool ret;
ret = nrf_802154_transmit_raw_at(nrf5_data.tx_psdu,
cca,
tx_at - TXTIME_OFFSET_US,
TXTIME_OFFSET_US,
nrf_802154_channel_get());
if (nrf5_data.event_handler) {
LOG_WRN("TX_STARTED event will be triggered without delay");
}
return ret;
}
#endif /* CONFIG_IEEE802154_NRF5_PKT_TXTIME */
static int nrf5_tx(const struct device *dev,
enum ieee802154_tx_mode mode,
struct net_pkt *pkt,
@ -410,11 +432,20 @@ static int nrf5_tx(const struct device *dev,
case IEEE802154_TX_MODE_CCA:
ret = nrf_802154_transmit_raw(nrf5_radio->tx_psdu, true);
break;
#if !defined(CONFIG_NRF_802154_SL_OPENSOURCE) && \
!defined(CONFIG_NRF_802154_SER_HOST)
case IEEE802154_TX_MODE_CSMA_CA:
nrf_802154_transmit_csma_ca_raw(nrf5_radio->tx_psdu);
break;
#ifdef CONFIG_IEEE802154_NRF5_PKT_TXTIME
case IEEE802154_TX_MODE_TXTIME:
case IEEE802154_TX_MODE_TXTIME_CCA:
__ASSERT_NO_MSG(pkt);
ret = nrf5_tx_at(pkt,
mode == IEEE802154_TX_MODE_TXTIME_CCA);
break;
#endif /* CONFIG_IEEE802154_NRF5_PKT_TXTIME */
#endif
default:
NET_ERR("TX mode %d not supported", mode);
return -ENOTSUP;