Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netdev_ieee802154: add radio capabilities #11473

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cpu/nrf52/radio/nrf802154/nrf802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ static void _timer_cb(void *arg, int chan)
static int _init(netdev_t *dev)
{
(void)dev;
/* fill transceiver capabilities */
netdev_ieee802154_t *ieee802154_dev = (netdev_ieee802154_t*) dev;
ieee802154_dev->caps = NETDEV_IEEE802154_CAPS_TX_CHECKSUM;

int result = timer_init(NRF802154_TIMER, TIMER_FREQ, _timer_cb, NULL);
assert(result >= 0);
Expand Down
9 changes: 9 additions & 0 deletions drivers/at86rf2xx/at86rf2xx_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ static int _init(netdev_t *netdev)
{
at86rf2xx_t *dev = (at86rf2xx_t *)netdev;

/* fill transceiver capabilities */
netdev_ieee802154_t *ieee802154_dev = (netdev_ieee802154_t*) netdev;
ieee802154_dev->caps = NETDEV_IEEE802154_CAPS_TX_CHECKSUM |
NETDEV_IEEE802154_CAPS_CSMA |
NETDEV_IEEE802154_CAPS_FRAME_RETRIES |
NETDEV_IEEE802154_CAPS_ADDRESS_FILTER |
NETDEV_IEEE802154_CAPS_AUTO_ACK |
NETDEV_IEEE802154_CAPS_PROMISCUOUS;

/* initialize GPIOs */
spi_init_cs(dev->params.spi, dev->params.cs_pin);
gpio_init(dev->params.sleep_pin, GPIO_OUT);
Expand Down
7 changes: 7 additions & 0 deletions drivers/cc2420/cc2420_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ static int _init(netdev_t *netdev)
{
cc2420_t *dev = (cc2420_t *)netdev;

/* fill transceiver capabilities */
netdev_ieee802154_t *ieee802154_dev = (netdev_ieee802154_t*) netdev;
ieee802154_dev->caps = NETDEV_IEEE802154_CAPS_TX_CHECKSUM |
NETDEV_IEEE802154_CAPS_CSMA |
NETDEV_IEEE802154_CAPS_ADDRESS_FILTER |
NETDEV_IEEE802154_CAPS_AUTO_ACK |
NETDEV_IEEE802154_CAPS_PROMISCUOUS;
uint16_t reg;

/* initialize power and reset pins -> put the device into reset state */
Expand Down
76 changes: 76 additions & 0 deletions drivers/include/net/netdev/ieee802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef NET_NETDEV_IEEE802154_H
#define NET_NETDEV_IEEE802154_H

#include <stdbool.h>
#include "net/ieee802154.h"
#include "net/gnrc/nettype.h"
#include "net/netopt.h"
Expand Down Expand Up @@ -78,6 +79,66 @@ typedef enum {
* with the multiplexed preamble */
} netdev_ieee802154_cca_mode_t;

/**
* @name IEEE 802.15.4 radio caps
* @brief Flags that indicate IEEE 802.15.4 capabilities on transceivers
*
* @{
*/

/**
* @brief Transceiver calculates FCS on transmission
*/
#define NETDEV_IEEE802154_CAPS_TX_CHECKSUM (1<<0)

/**
* @brief Transceiver supports CSMA
*/
#define NETDEV_IEEE802154_CAPS_CSMA (1<<1)

/**
* @brief Transceiver supports energy scan
*/
#define NETDEV_IEEE802154_CAPS_ENERGY_SCAN (1<<2)

/**
* @brief Transceiver supports automatic retransmission of frames (with CSMA)
*/
#define NETDEV_IEEE802154_CAPS_FRAME_RETRIES (1<<3)

/**
* @brief Transceiver handles ACK automatically
*/
#define NETDEV_IEEE802154_CAPS_AUTO_ACK (1<<4)

/**
* @brief Transceiver removes FCS on received packet
*/
#define NETDEV_IEEE802154_CAPS_RX_OMIT_CHECKSUM (1<<5)

/**
* @brief Transceiver drops packet on bad checksum
*/
#define NETDEV_IEEE802154_CAPS_RX_DROP_BAD_CHECKSUM (1<<6)

/**
* @brief Transceiver supports address filtering
*/
#define NETDEV_IEEE802154_CAPS_ADDRESS_FILTER (1<<7)

/**
* @brief Transceiver supports promiscuous mode
*/
#define NETDEV_IEEE802154_CAPS_PROMISCUOUS (1<<8)
/**
* @}
*/

/**
* @brief IEEE 802.15.4 transceiver capabilites type definition
*/
typedef uint16_t netdev_ieee802154_trx_caps_t;

/**
* @brief Extended structure to hold IEEE 802.15.4 driver state
*
Expand Down Expand Up @@ -115,6 +176,7 @@ typedef struct {
uint8_t page; /**< channel page */
uint16_t flags; /**< flags as defined above */
int16_t txpower; /**< tx power in dBm */
netdev_ieee802154_trx_caps_t caps; /**< radio capabilities flags */
/** @} */
} netdev_ieee802154_t;

Expand All @@ -133,6 +195,20 @@ typedef struct netdev_radio_rx_info netdev_ieee802154_rx_info_t;
*/
void netdev_ieee802154_reset(netdev_ieee802154_t *dev);

/**
* @brief Check if the IEEE802.15.4 radio supports a given capability
*
* @param[in] netdev IEEE802.15.4 device descriptor
* @param[in] cap Capability to be checked
*
* @return true if the radio supports the given cap.
* @return false otherwise
*/
static inline bool netdev_ieee802154_has_cap(netdev_ieee802154_t *netdev,
netdev_ieee802154_trx_caps_t cap)
{
return netdev->caps & cap;
}

/**
* @brief Fallback function for netdev IEEE 802.15.4 devices' _get function
Expand Down
8 changes: 8 additions & 0 deletions drivers/kw2xrf/kw2xrf_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ static int _init(netdev_t *netdev)
{
kw2xrf_t *dev = (kw2xrf_t *)netdev;

/* fill transceiver capabilities */
netdev_ieee802154_t *ieee802154_dev = (netdev_ieee802154_t*) netdev;
ieee802154_dev->caps = NETDEV_IEEE802154_CAPS_TX_CHECKSUM |
NETDEV_IEEE802154_CAPS_CSMA |
NETDEV_IEEE802154_CAPS_ADDRESS_FILTER |
NETDEV_IEEE802154_CAPS_AUTO_ACK |
NETDEV_IEEE802154_CAPS_PROMISCUOUS;

dev->thread = (thread_t *)thread_get(thread_getpid());

/* initialize SPI and GPIOs */
Expand Down
9 changes: 9 additions & 0 deletions drivers/mrf24j40/mrf24j40_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ static int _init(netdev_t *netdev)
{
mrf24j40_t *dev = (mrf24j40_t *)netdev;

/* fill transceiver capabilities */
netdev_ieee802154_t *ieee802154_dev = (netdev_ieee802154_t*) netdev;
ieee802154_dev->caps = NETDEV_IEEE802154_CAPS_TX_CHECKSUM |
NETDEV_IEEE802154_CAPS_CSMA |
NETDEV_IEEE802154_CAPS_FRAME_RETRIES |
NETDEV_IEEE802154_CAPS_ADDRESS_FILTER |
NETDEV_IEEE802154_CAPS_AUTO_ACK |
NETDEV_IEEE802154_CAPS_PROMISCUOUS;

/* initialize GPIOs */
spi_init_cs(dev->params.spi, dev->params.cs_pin);
gpio_init(dev->params.reset_pin, GPIO_OUT);
Expand Down