Loading...
Searching...
No Matches
at86rf2xx_internal.h File Reference

Internal interfaces for AT86RF2xx drivers. More...

Detailed Description

#include <stdint.h>
#include "at86rf2xx.h"
#include "at86rf2xx_registers.h"
+ Include dependency graph for at86rf2xx_internal.h:

Go to the source code of this file.

#define AT86RF2XX_TXPOWER_MAX   (20)
 Max.
 
#define AT86RF2XX_TXPOWER_OFF   (17)
 Transmit power offset.
 
#define AT86RF2XX_WAKEUP_DELAY   (306U)
 Transition time from SLEEP to TRX_OFF in us, refer figure 7-4, p.42.
 
#define AT86RF2XX_RESET_PULSE_WIDTH   (62U)
 Minimum reset pulse width, refer p.190.
 
#define AT86RF2XX_RESET_DELAY   (62U)
 The typical transition time to TRX_OFF after reset pulse is 26 us, refer to figure 7-8, p.
 
uint8_t at86rf2xx_reg_read (const at86rf2xx_t *dev, uint8_t addr)
 Read from a register at address addr from device dev.
 
void at86rf2xx_reg_write (const at86rf2xx_t *dev, uint8_t addr, uint8_t value)
 Write to a register at address addr from device dev.
 
void at86rf2xx_sram_read (const at86rf2xx_t *dev, uint8_t offset, uint8_t *data, size_t len)
 Read a chunk of data from the SRAM of the given device.
 
void at86rf2xx_sram_write (const at86rf2xx_t *dev, uint8_t offset, const uint8_t *data, size_t len)
 Write a chunk of data into the SRAM of the given device.
 
void at86rf2xx_fb_start (const at86rf2xx_t *dev)
 Start a read transcation internal frame buffer of the given device.
 
void at86rf2xx_fb_read (const at86rf2xx_t *dev, uint8_t *data, size_t len)
 Read the internal frame buffer of the given device.
 
void at86rf2xx_fb_stop (const at86rf2xx_t *dev)
 Stop a read transcation internal frame buffer of the given device.
 
uint8_t at86rf2xx_get_status (const at86rf2xx_t *dev)
 Convenience function for reading the status of the given device.
 
void at86rf2xx_assert_awake (at86rf2xx_t *dev)
 Make sure that device is not sleeping.
 
void at86rf2xx_hardware_reset (at86rf2xx_t *dev)
 Trigger a hardware reset.
 
void at86rf2xx_configure_phy (at86rf2xx_t *dev, uint8_t chan, uint8_t page, int16_t txpower)
 Set PHY parameters based on channel and page number.
 
void at86rf2xx_get_random (at86rf2xx_t *dev, uint8_t *data, size_t len)
 Read random data from the RNG.
 
void at86rf2xx_spi_init (at86rf2xx_t *dev, void(*irq_handler)(void *arg))
 Initialize AT86RF2XX SPI communication.
 
static uint8_t at86rf2xx_get_rx_len (at86rf2xx_t *dev)
 Get the PSDU length of the received frame.
 
static uint8_t at86rf2xx_get_irq_flags (at86rf2xx_t *dev)
 Get the IRQ flags.
 

Macro Definition Documentation

◆ AT86RF2XX_RESET_DELAY

#define AT86RF2XX_RESET_DELAY   (62U)

The typical transition time to TRX_OFF after reset pulse is 26 us, refer to figure 7-8, p.

  1. We use 62 us so that it is at least one tick on platforms that use a 16384 Hz oscillator or have slow start up times due to parasitic capacitance on the oscillator

Definition at line 80 of file at86rf2xx_internal.h.

◆ AT86RF2XX_RESET_PULSE_WIDTH

#define AT86RF2XX_RESET_PULSE_WIDTH   (62U)

Minimum reset pulse width, refer p.190.

We use 62us so that it is at least one tick on platforms with coarse ztimers

Definition at line 72 of file at86rf2xx_internal.h.

◆ AT86RF2XX_TXPOWER_MAX

#define AT86RF2XX_TXPOWER_MAX   (20)

Max.

allowed transmit power for the transceiver

Definition at line 50 of file at86rf2xx_internal.h.

◆ AT86RF2XX_TXPOWER_OFF

#define AT86RF2XX_TXPOWER_OFF   (17)

Transmit power offset.

Definition at line 59 of file at86rf2xx_internal.h.

◆ AT86RF2XX_WAKEUP_DELAY

#define AT86RF2XX_WAKEUP_DELAY   (306U)

Transition time from SLEEP to TRX_OFF in us, refer figure 7-4, p.42.

For different environments refer figure 13-13, p.201

Definition at line 66 of file at86rf2xx_internal.h.

Function Documentation

◆ at86rf2xx_assert_awake()

void at86rf2xx_assert_awake ( at86rf2xx_t dev)

Make sure that device is not sleeping.

Parameters
[in,out]devdevice to eventually wake up

◆ at86rf2xx_configure_phy()

void at86rf2xx_configure_phy ( at86rf2xx_t dev,
uint8_t  chan,
uint8_t  page,
int16_t  txpower 
)

Set PHY parameters based on channel and page number.

Parameters
[in,out]devdevice to configure
[in]chanchannel number to be set
[in]pagechannel page
[in]txpowerTX power in dBm

◆ at86rf2xx_fb_read()

void at86rf2xx_fb_read ( const at86rf2xx_t dev,
uint8_t *  data,
size_t  len 
)

Read the internal frame buffer of the given device.

Each read advances the position in the buffer by len.

Parameters
[in]devdevice to read from
[out]databuffer to copy the data to
[in]lennumber of bytes to read from the frame buffer

◆ at86rf2xx_fb_start()

void at86rf2xx_fb_start ( const at86rf2xx_t dev)

Start a read transcation internal frame buffer of the given device.

Reading the frame buffer returns some extra bytes that are not accessible through reading the RAM directly. This locks the used SPI.

Parameters
[in]devdevice to start read

◆ at86rf2xx_fb_stop()

void at86rf2xx_fb_stop ( const at86rf2xx_t dev)

Stop a read transcation internal frame buffer of the given device.

Release the SPI device and unlock frame buffer protection.

Parameters
[in]devdevice to stop read

◆ at86rf2xx_get_irq_flags()

static uint8_t at86rf2xx_get_irq_flags ( at86rf2xx_t dev)
inlinestatic

Get the IRQ flags.

This function clears the IRQ flags

Parameters
[in,out]devpointer to the device descriptor
Returns
IRQ flags

Definition at line 285 of file at86rf2xx_internal.h.

◆ at86rf2xx_get_random()

void at86rf2xx_get_random ( at86rf2xx_t dev,
uint8_t *  data,
size_t  len 
)

Read random data from the RNG.

Note
According to the data sheet this function only works properly in Basic Operation Mode. However, sporadic testing has shown that even in Extended Operation Mode this returns random enough data to be used as a seed for Random if no cryptographically secure randomness is required. Any further use-case needs to be evaluated, especially if crypto-relevant randomness is required.
Parameters
[in]devdevice to configure
[out]databuffer to copy the random data to
[in]lennumber of random bytes to store in data

◆ at86rf2xx_get_rx_len()

static uint8_t at86rf2xx_get_rx_len ( at86rf2xx_t dev)
inlinestatic

Get the PSDU length of the received frame.

Parameters
[in]devpointer to the device descriptor
Returns
the PSDU length

Definition at line 265 of file at86rf2xx_internal.h.

◆ at86rf2xx_get_status()

uint8_t at86rf2xx_get_status ( const at86rf2xx_t dev)

Convenience function for reading the status of the given device.

Parameters
[in]devdevice to read the status from
Returns
internal status of the given device

◆ at86rf2xx_hardware_reset()

void at86rf2xx_hardware_reset ( at86rf2xx_t dev)

Trigger a hardware reset.

Parameters
[in,out]devdevice to reset

◆ at86rf2xx_reg_read()

uint8_t at86rf2xx_reg_read ( const at86rf2xx_t dev,
uint8_t  addr 
)

Read from a register at address addr from device dev.

Parameters
[in]devdevice to read from
[in]addraddress of the register to read
Returns
the value of the specified register

◆ at86rf2xx_reg_write()

void at86rf2xx_reg_write ( const at86rf2xx_t dev,
uint8_t  addr,
uint8_t  value 
)

Write to a register at address addr from device dev.

Parameters
[in]devdevice to write to
[in]addraddress of the register to write
[in]valuevalue to write to the given register

◆ at86rf2xx_spi_init()

void at86rf2xx_spi_init ( at86rf2xx_t dev,
void(*)(void *arg)  irq_handler 
)

Initialize AT86RF2XX SPI communication.

Parameters
[in,out]devdevice to initialize
[in]irq_handlerIRQ handler

◆ at86rf2xx_sram_read()

void at86rf2xx_sram_read ( const at86rf2xx_t dev,
uint8_t  offset,
uint8_t *  data,
size_t  len 
)

Read a chunk of data from the SRAM of the given device.

Parameters
[in]devdevice to read from
[in]offsetstarting address to read from [valid 0x00-0x7f]
[out]databuffer to read data into
[in]lennumber of bytes to read from SRAM

◆ at86rf2xx_sram_write()

void at86rf2xx_sram_write ( const at86rf2xx_t dev,
uint8_t  offset,
const uint8_t *  data,
size_t  len 
)

Write a chunk of data into the SRAM of the given device.

Parameters
[in]devdevice to write to
[in]offsetaddress in the SRAM to write to [valid 0x00-0x7f]
[in]datadata to copy into SRAM
[in]lennumber of bytes to write to SRAM