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...


SUMMARY: This driver / link layer supports:

But so far no support for:

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...


 GNRC adapter for nrfmin
 Minimal driver for the NRF51 radio.


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...


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


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...


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 More...
#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. More...

Macro Definition Documentation


#define NRFMIN_ADDR_BCAST   (0xffff)

Export the default nrfmin broadcast address.

Definition at line 98 of file nrfmin.h.


#define NRFMIN_CHAN_DEFAULT   (0U) /* 2400MHz */

Definition at line 86 of file nrfmin.h.


#define NRFMIN_CHAN_MAX   (32)

Definition at line 87 of file nrfmin.h.


#define NRFMIN_CHAN_MIN   (0U)

nrfmin channel configuration

Definition at line 85 of file nrfmin.h.


#define NRFMIN_HDR_LEN   (sizeof(nrfmin_hdr_t))

Export some information on header and packet lengths.

Definition at line 111 of file nrfmin.h.


#define NRFMIN_PAYLOAD_MAX   (200U)

Default maximum payload length (must be <= 250)

Definition at line 104 of file nrfmin.h.



Definition at line 112 of file nrfmin.h.


#define NRFMIN_TXPOWER_DEFAULT   (0) /* 0dBm */

Default transmission power used.

Definition at line 93 of file nrfmin.h.

Function Documentation

◆ nrfmin_get_addr()

uint16_t nrfmin_get_addr ( void  )

Get the currently active address.

the 16-bit node address

◆ nrfmin_get_channel()

uint16_t nrfmin_get_channel ( void  )

Get the current channel.

currently active channel

◆ nrfmin_get_iid()

void nrfmin_get_iid ( uint16_t *  iid)

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

[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.

state the radio is currently in

◆ nrfmin_get_txpower()

int16_t nrfmin_get_txpower ( void  )

Get the current transmit power.

transmission power in [dBm]

◆ nrfmin_set_addr()

void nrfmin_set_addr ( uint16_t  addr)

Set the 16-bit radio address.

[in]addraddress to set

◆ nrfmin_set_channel()

int nrfmin_set_channel ( uint16_t  chan)

Set the active channel.

[in]chantargeted channel [0-31]
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.

[in]valtarget state
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.

[in]powertargeted power, in [dBm]