AT86RF2xx based drivers

This module contains drivers for radio devices in Atmel's AT86RF2xx series. More...

Detailed Description

This module contains drivers for radio devices in Atmel's AT86RF2xx series.

The driver is aimed to work with all devices of this series.

Files

file  at86rf2xx_internal.h
 Internal interfaces for AT86RF2xx drivers.
 
file  at86rf2xx_netdev.h
 Netdev interface to AT86RF2xx drivers.
 
file  at86rf2xx_registers.h
 Register and command definitions for AT86RF2xx devices.
 
file  at86rf2xx.h
 Interface definition for AT86RF2xx based drivers.
 

Data Structures

struct  at86rf2xx_params
 struct holding all params needed for device initialization More...
 
struct  at86rf2xx_t
 Device descriptor for AT86RF2XX radio devices. More...
 

Macros

#define AT86RF2XX_MAX_PKT_LENGTH   (IEEE802154_FRAME_LEN_MAX)
 Maximum possible packet size in byte.
 
#define AT86RF2XX_DEFAULT_PANID   (IEEE802154_DEFAULT_PANID)
 Default PAN ID. More...
 
#define AT86RF2XX_DEFAULT_TXPOWER   (IEEE802154_DEFAULT_TXPOWER)
 Default TX power (0dBm)
 
#define RSSI_BASE_VAL   (-91)
 Base (minimal) RSSI value in dBm.
 

Typedefs

typedef struct at86rf2xx_params at86rf2xx_params_t
 struct holding all params needed for device initialization
 

Functions

void at86rf2xx_setup (at86rf2xx_t *dev, const at86rf2xx_params_t *params)
 Setup an AT86RF2xx based device state. More...
 
void at86rf2xx_reset (at86rf2xx_t *dev)
 Trigger a hardware reset and configure radio with default values. More...
 
uint16_t at86rf2xx_get_addr_short (at86rf2xx_t *dev)
 Get the short address of the given device. More...
 
void at86rf2xx_set_addr_short (at86rf2xx_t *dev, uint16_t addr)
 Set the short address of the given device. More...
 
uint64_t at86rf2xx_get_addr_long (at86rf2xx_t *dev)
 Get the configured long address of the given device. More...
 
void at86rf2xx_set_addr_long (at86rf2xx_t *dev, uint64_t addr)
 Set the long address of the given device. More...
 
uint8_t at86rf2xx_get_chan (at86rf2xx_t *dev)
 Get the configured channel number of the given device. More...
 
void at86rf2xx_set_chan (at86rf2xx_t *dev, uint8_t chan)
 Set the channel number of the given device. More...
 
uint8_t at86rf2xx_get_page (at86rf2xx_t *dev)
 Get the configured channel page of the given device. More...
 
void at86rf2xx_set_page (at86rf2xx_t *dev, uint8_t page)
 Set the channel page of the given device. More...
 
uint16_t at86rf2xx_get_pan (at86rf2xx_t *dev)
 Get the configured PAN ID of the given device. More...
 
void at86rf2xx_set_pan (at86rf2xx_t *dev, uint16_t pan)
 Set the PAN ID of the given device. More...
 
int16_t at86rf2xx_get_txpower (at86rf2xx_t *dev)
 Get the configured transmission power of the given device [in dBm]. More...
 
void at86rf2xx_set_txpower (at86rf2xx_t *dev, int16_t txpower)
 Set the transmission power of the given device [in dBm]. More...
 
uint8_t at86rf2xx_get_max_retries (at86rf2xx_t *dev)
 Get the maximum number of retransmissions. More...
 
void at86rf2xx_set_max_retries (at86rf2xx_t *dev, uint8_t max)
 Set the maximum number of retransmissions. More...
 
uint8_t at86rf2xx_get_csma_max_retries (at86rf2xx_t *dev)
 Get the maximum number of channel access attempts per frame (CSMA) More...
 
void at86rf2xx_set_csma_max_retries (at86rf2xx_t *dev, int8_t retries)
 Set the maximum number of channel access attempts per frame (CSMA) More...
 
void at86rf2xx_set_csma_backoff_exp (at86rf2xx_t *dev, uint8_t min, uint8_t max)
 Set the min and max backoff exponent for CSMA/CA. More...
 
void at86rf2xx_set_csma_seed (at86rf2xx_t *dev, uint8_t entropy[2])
 Set seed for CSMA random backoff. More...
 
int8_t at86rf2xx_get_cca_threshold (at86rf2xx_t *dev)
 Get the CCA threshold value. More...
 
void at86rf2xx_set_cca_threshold (at86rf2xx_t *dev, int8_t value)
 Set the CCA threshold value. More...
 
int8_t at86rf2xx_get_ed_level (at86rf2xx_t *dev)
 Get the latest ED level measurement. More...
 
void at86rf2xx_set_option (at86rf2xx_t *dev, uint16_t option, bool state)
 Enable or disable driver specific options. More...
 
uint8_t at86rf2xx_set_state (at86rf2xx_t *dev, uint8_t state)
 Set the state of the given device (trigger a state change) More...
 
size_t at86rf2xx_send (at86rf2xx_t *dev, uint8_t *data, size_t len)
 Convenience function for simply sending data. More...
 
void at86rf2xx_tx_prepare (at86rf2xx_t *dev)
 Prepare for sending of data. More...
 
size_t at86rf2xx_tx_load (at86rf2xx_t *dev, uint8_t *data, size_t len, size_t offset)
 Load chunks of data into the transmit buffer of the given device. More...
 
void at86rf2xx_tx_exec (at86rf2xx_t *dev)
 Trigger sending of data previously loaded into transmit buffer. More...
 
bool at86rf2xx_cca (at86rf2xx_t *dev)
 Perform one manual channel clear assessment (CCA) More...
 

Channel configuration

#define AT86RF2XX_MIN_CHANNEL   (IEEE802154_CHANNEL_MIN)
 
#define AT86RF2XX_MAX_CHANNEL   (IEEE802154_CHANNEL_MAX)
 
#define AT86RF2XX_DEFAULT_CHANNEL   (IEEE802154_DEFAULT_CHANNEL)
 

Flags for device internal states (see datasheet)

#define AT86RF2XX_STATE_P_ON   (0x00)
 initial power on
 
#define AT86RF2XX_STATE_BUSY_RX   (0x01)
 busy receiving data (basic mode)
 
#define AT86RF2XX_STATE_BUSY_TX   (0x02)
 busy transmitting data (basic mode)
 
#define AT86RF2XX_STATE_FORCE_TRX_OFF   (0x03)
 force transition to idle
 
#define AT86RF2XX_STATE_RX_ON   (0x06)
 listen mode (basic mode)
 
#define AT86RF2XX_STATE_TRX_OFF   (0x08)
 idle
 
#define AT86RF2XX_STATE_PLL_ON   (0x09)
 ready to transmit
 
#define AT86RF2XX_STATE_SLEEP   (0x0f)
 sleep mode
 
#define AT86RF2XX_STATE_BUSY_RX_AACK   (0x11)
 busy receiving data (extended mode)
 
#define AT86RF2XX_STATE_BUSY_TX_ARET   (0x12)
 busy transmitting data (extended mode)
 
#define AT86RF2XX_STATE_RX_AACK_ON   (0x16)
 wait for incoming data
 
#define AT86RF2XX_STATE_TX_ARET_ON   (0x19)
 ready for sending data
 
#define AT86RF2XX_STATE_IN_PROGRESS   (0x1f)
 ongoing state conversion
 

Internal device option flags

0x00ff is reserved for general IEEE 802.15.4 flags (see netdev_ieee802154_t)

#define AT86RF2XX_OPT_SRC_ADDR_LONG   (NETDEV_IEEE802154_SRC_MODE_LONG)
 legacy define
 
#define AT86RF2XX_OPT_RAWDUMP   (NETDEV_IEEE802154_RAW)
 legacy define
 
#define AT86RF2XX_OPT_AUTOACK   (NETDEV_IEEE802154_ACK_REQ)
 legacy define
 
#define AT86RF2XX_OPT_CSMA   (0x0100)
 CSMA active.
 
#define AT86RF2XX_OPT_PROMISCUOUS   (0x0200)
 promiscuous mode active
 
#define AT86RF2XX_OPT_PRELOADING   (0x0400)
 preloading enabled
 
#define AT86RF2XX_OPT_TELL_TX_START   (0x0800)
 notify MAC layer on TX start
 
#define AT86RF2XX_OPT_TELL_TX_END   (0x1000)
 notify MAC layer on TX finished
 
#define AT86RF2XX_OPT_TELL_RX_START   (0x2000)
 notify MAC layer on RX start
 
#define AT86RF2XX_OPT_TELL_RX_END   (0x4000)
 notify MAC layer on RX finished
 

Macro Definition Documentation

◆ AT86RF2XX_DEFAULT_PANID

#define AT86RF2XX_DEFAULT_PANID   (IEEE802154_DEFAULT_PANID)

Default PAN ID.

Todo:
Read some global network stack specific configuration value

Definition at line 72 of file at86rf2xx.h.

Function Documentation

◆ at86rf2xx_cca()

bool at86rf2xx_cca ( at86rf2xx_t dev)

Perform one manual channel clear assessment (CCA)

The CCA mode and threshold level depends on the current transceiver settings.

Parameters
[in]devdevice to use
Returns
true if channel is determined clear
false if channel is determined busy

◆ at86rf2xx_get_addr_long()

uint64_t at86rf2xx_get_addr_long ( at86rf2xx_t dev)

Get the configured long address of the given device.

Parameters
[in]devdevice to read from
Returns
the currently set (8-byte) long address

◆ at86rf2xx_get_addr_short()

uint16_t at86rf2xx_get_addr_short ( at86rf2xx_t dev)

Get the short address of the given device.

Parameters
[in]devdevice to read from
Returns
the currently set (2-byte) short address

◆ at86rf2xx_get_cca_threshold()

int8_t at86rf2xx_get_cca_threshold ( at86rf2xx_t dev)

Get the CCA threshold value.

Parameters
[in]devdevice to read value from
Returns
the current CCA threshold value

◆ at86rf2xx_get_chan()

uint8_t at86rf2xx_get_chan ( at86rf2xx_t dev)

Get the configured channel number of the given device.

Parameters
[in]devdevice to read from
Returns
the currently set channel number

◆ at86rf2xx_get_csma_max_retries()

uint8_t at86rf2xx_get_csma_max_retries ( at86rf2xx_t dev)

Get the maximum number of channel access attempts per frame (CSMA)

Parameters
[in]devdevice to read from
Returns
configured number of retries

◆ at86rf2xx_get_ed_level()

int8_t at86rf2xx_get_ed_level ( at86rf2xx_t dev)

Get the latest ED level measurement.

Parameters
[in]devdevice to read value from
Returns
the last ED level

◆ at86rf2xx_get_max_retries()

uint8_t at86rf2xx_get_max_retries ( at86rf2xx_t dev)

Get the maximum number of retransmissions.

Parameters
[in]devdevice to read from
Returns
configured number of retransmissions

◆ at86rf2xx_get_page()

uint8_t at86rf2xx_get_page ( at86rf2xx_t dev)

Get the configured channel page of the given device.

Parameters
[in]devdevice to read from
Returns
the currently set channel page

◆ at86rf2xx_get_pan()

uint16_t at86rf2xx_get_pan ( at86rf2xx_t dev)

Get the configured PAN ID of the given device.

Parameters
[in]devdevice to read from
Returns
the currently set PAN ID

◆ at86rf2xx_get_txpower()

int16_t at86rf2xx_get_txpower ( at86rf2xx_t dev)

Get the configured transmission power of the given device [in dBm].

Parameters
[in]devdevice to read from
Returns
configured transmission power in dBm

◆ at86rf2xx_reset()

void at86rf2xx_reset ( at86rf2xx_t dev)

Trigger a hardware reset and configure radio with default values.

Parameters
[in]devdevice to reset

◆ at86rf2xx_send()

size_t at86rf2xx_send ( at86rf2xx_t dev,
uint8_t *  data,
size_t  len 
)

Convenience function for simply sending data.

Note
This function ignores the PRELOADING option
Parameters
[in]devdevice to use for sending
[in]datadata to send (must include IEEE802.15.4 header)
[in]lenlength of data
Returns
number of bytes that were actually send
0 on error

◆ at86rf2xx_set_addr_long()

void at86rf2xx_set_addr_long ( at86rf2xx_t dev,
uint64_t  addr 
)

Set the long address of the given device.

Parameters
[in]devdevice to write to
[in]addr(8-byte) long address to set

◆ at86rf2xx_set_addr_short()

void at86rf2xx_set_addr_short ( at86rf2xx_t dev,
uint16_t  addr 
)

Set the short address of the given device.

Parameters
[in]devdevice to write to
[in]addr(2-byte) short address to set

◆ at86rf2xx_set_cca_threshold()

void at86rf2xx_set_cca_threshold ( at86rf2xx_t dev,
int8_t  value 
)

Set the CCA threshold value.

Parameters
[in]devdevice to write to
[in]valuethe new CCA threshold value

◆ at86rf2xx_set_chan()

void at86rf2xx_set_chan ( at86rf2xx_t dev,
uint8_t  chan 
)

Set the channel number of the given device.

Parameters
[in]devdevice to write to
[in]chanchannel number to set

◆ at86rf2xx_set_csma_backoff_exp()

void at86rf2xx_set_csma_backoff_exp ( at86rf2xx_t dev,
uint8_t  min,
uint8_t  max 
)

Set the min and max backoff exponent for CSMA/CA.

  • Maximum BE: 0 - 8
  • Minimum BE: 0 - [max]
Parameters
[in]devdevice to write to
[in]minthe minimum BE
[in]maxthe maximum BE

◆ at86rf2xx_set_csma_max_retries()

void at86rf2xx_set_csma_max_retries ( at86rf2xx_t dev,
int8_t  retries 
)

Set the maximum number of channel access attempts per frame (CSMA)

This setting specifies the number of attempts to access the channel to transmit a frame. If the channel is busy retries times, then frame transmission fails. Valid values: 0 to 5, -1 means CSMA disabled

Parameters
[in]devdevice to write to
[in]retriesthe maximum number of retries

◆ at86rf2xx_set_csma_seed()

void at86rf2xx_set_csma_seed ( at86rf2xx_t dev,
uint8_t  entropy[2] 
)

Set seed for CSMA random backoff.

Parameters
[in]devdevice to write to
[in]entropy11 bit of entropy as seed for random backoff

◆ at86rf2xx_set_max_retries()

void at86rf2xx_set_max_retries ( at86rf2xx_t dev,
uint8_t  max 
)

Set the maximum number of retransmissions.

This setting specifies the number of attempts to retransmit a frame, when it was not acknowledged by the recipient, before the transaction gets cancelled. The maximum value is 7.

Parameters
[in]devdevice to write to
[in]maxthe maximum number of retransmissions

◆ at86rf2xx_set_option()

void at86rf2xx_set_option ( at86rf2xx_t dev,
uint16_t  option,
bool  state 
)

Enable or disable driver specific options.

Parameters
[in]devdevice to set/clear option flag for
[in]optionoption to enable/disable
[in]statetrue for enable, false for disable

◆ at86rf2xx_set_page()

void at86rf2xx_set_page ( at86rf2xx_t dev,
uint8_t  page 
)

Set the channel page of the given device.

Parameters
[in]devdevice to write to
[in]pagechannel page to set

◆ at86rf2xx_set_pan()

void at86rf2xx_set_pan ( at86rf2xx_t dev,
uint16_t  pan 
)

Set the PAN ID of the given device.

Parameters
[in]devdevice to write to
[in]panPAN ID to set

◆ at86rf2xx_set_state()

uint8_t at86rf2xx_set_state ( at86rf2xx_t dev,
uint8_t  state 
)

Set the state of the given device (trigger a state change)

Parameters
[in]devdevice to change state of
[in]statethe targeted new state
Returns
the previous state before the new state was set

◆ at86rf2xx_set_txpower()

void at86rf2xx_set_txpower ( at86rf2xx_t dev,
int16_t  txpower 
)

Set the transmission power of the given device [in dBm].

If the device does not support the exact dBm value given, it will set a value as close as possible to the given value. If the given value is larger or lower then the maximal or minimal possible value, the min or max value is set, respectively.

Parameters
[in]devdevice to write to
[in]txpowertransmission power in dBm

◆ at86rf2xx_setup()

void at86rf2xx_setup ( at86rf2xx_t dev,
const at86rf2xx_params_t params 
)

Setup an AT86RF2xx based device state.

Parameters
[out]devdevice descriptor
[in]paramsparameters for device initialization

◆ at86rf2xx_tx_exec()

void at86rf2xx_tx_exec ( at86rf2xx_t dev)

Trigger sending of data previously loaded into transmit buffer.

Parameters
[in]devdevice to trigger

◆ at86rf2xx_tx_load()

size_t at86rf2xx_tx_load ( at86rf2xx_t dev,
uint8_t *  data,
size_t  len,
size_t  offset 
)

Load chunks of data into the transmit buffer of the given device.

Parameters
[in]devdevice to write data to
[in]databuffer containing the data to load
[in]lennumber of bytes in buffer
[in]offsetoffset used when writing data to internal buffer
Returns
offset + number of bytes written

◆ at86rf2xx_tx_prepare()

void at86rf2xx_tx_prepare ( at86rf2xx_t dev)

Prepare for sending of data.

This function puts the given device into the TX state, so no receiving of data is possible after it was called.

Parameters
[in]devdevice to prepare for sending