NRF minimal radio driver

Minimal driver for the NRF51 radio. More...

Detailed Description

Minimal driver for the NRF51 radio.

This driver uses the nRF5x radio in a proprietary/custom way, defining our own custom link layer. This custom link layer resembles some characteristics of the IEEE802.15.4 link layer, but is not at all compatible to it.

One key point is, that this custom link layer is only meant to operate between nRF5x devices, which let's us make some very nice assumptions:

The driver is using a Nordic proprietary physical layer, configured to a bitrate of 1 Mbit/s. The maximum payload length can be freely configured, but the maximal supported value is 250 byte (default is 200 byte).

We define the nrfmin link layer to use 16-bit addresses. On the physical layer we encode these addresses by putting these addresses into the 2 least significant bytes of the supported 5-byte addresses, while setting the other 3 bytes to 0xe7.

For out custom link layer, we define our own proprietary link layer format (all fields are in host byte order (little endian)):

byte0 byte1 - byte2 byte3 - byte4 byte5 byte7 - byteN
length src_addr dst_addr proto payload...

With:

SUMMARY: This driver / link layer supports:

But so far no support for:

Todo:
So far the driver uses only a single RX buffer that is locked until the data was read/discarded. This can potentially lead to a lot of packet loss -> using more than one buffer would help here...

Modules

 GNRC adapter for nrfmin
 Minimal driver for the NRF51 radio.
 

Files

file  nrfmin.h
 Interface definition for the nrfmin NRF51822 radio driver.
 

Data Structures

struct  nrfmin_hdr_t
 Header format used for our custom nrfmin link layer. More...
 
union  nrfmin_pkt_t
 In-memory structure of a nrfmin radio packet. More...
 

Macros

#define NRFMIN_TXPOWER_DEFAULT   (0) /* 0dBm */
 Default transmission power used.
 
#define NRFMIN_ADDR_BCAST   (0xffff)
 Export the default nrfmin broadcast address.
 
#define NRFMIN_PAYLOAD_MAX   (200U)
 Default maximum payload length (must be <= 250)
 

Functions

void nrfmin_setup (void)
 Setup the device driver's data structures.
 
uint16_t nrfmin_get_addr (void)
 Get the currently active address. More...
 
void nrfmin_set_addr (uint16_t addr)
 Set the 16-bit radio address. More...
 
void nrfmin_get_iid (uint16_t *iid)
 Get the IID build from the 16-bit node address. More...
 
uint16_t nrfmin_get_channel (void)
 Get the current channel. More...
 
int nrfmin_set_channel (uint16_t chan)
 Set the active channel. More...
 
netopt_state_t nrfmin_get_state (void)
 Get the current radio state. More...
 
int nrfmin_set_state (netopt_state_t val)
 Put the device into the given state. More...
 
int16_t nrfmin_get_txpower (void)
 Get the current transmit power. More...
 
void nrfmin_set_txpower (int16_t power)
 Set the used transmission power. More...
 

Variables

netdev_t nrfmin_dev
 Export the netdev device descriptor.
 
const netdev_driver_t nrfmin_netdev
 Reference to the netdev driver interface.
 
#define NRFMIN_CHAN_MIN   (0U)
 nrfmin channel configuration
 
#define NRFMIN_CHAN_DEFAULT   (0U) /* 2400MHz */
 
#define NRFMIN_CHAN_MAX   (32)
 
#define NRFMIN_HDR_LEN   (sizeof(nrfmin_hdr_t))
 Export some information on header and packet lengths.
 
#define NRFMIN_PKT_MAX   (NRFMIN_HDR_LEN + NRFMIN_PAYLOAD_MAX)
 

Function Documentation

◆ nrfmin_get_addr()

uint16_t nrfmin_get_addr ( void  )

Get the currently active address.

Returns
the 16-bit node address

◆ nrfmin_get_channel()

uint16_t nrfmin_get_channel ( void  )

Get the current channel.

Returns
currently active channel

◆ nrfmin_get_iid()

void nrfmin_get_iid ( uint16_t *  iid)

Get the IID build from the 16-bit node address.

Parameters
[out]iidthe 64-bit IID, as array of 4 * 16-bit

◆ nrfmin_get_state()

netopt_state_t nrfmin_get_state ( void  )

Get the current radio state.

Returns
state the radio is currently in

◆ nrfmin_get_txpower()

int16_t nrfmin_get_txpower ( void  )

Get the current transmit power.

Returns
transmission power in [dBm]

◆ nrfmin_set_addr()

void nrfmin_set_addr ( uint16_t  addr)

Set the 16-bit radio address.

Parameters
[in]addraddress to set

◆ nrfmin_set_channel()

int nrfmin_set_channel ( uint16_t  chan)

Set the active channel.

Parameters
[in]chantargeted channel [0-31]
Returns
sizeof(uint16_t) on success
-EOVERFLOW if channel is not applicable

◆ nrfmin_set_state()

int nrfmin_set_state ( netopt_state_t  val)

Put the device into the given state.

Parameters
[in]valtarget state
Returns
sizeof(netopt_state_t) on success
-ENOTSUP if target state is not applicable

◆ nrfmin_set_txpower()

void nrfmin_set_txpower ( int16_t  power)

Set the used transmission power.

Parameters
[in]powertargeted power, in [dBm]