Minimal driver for the NRF51 radio.
More...
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:
- all communicating hosts are little-endian -> we define host byte order := network byte order
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:
- length: length of the packet, including the header -> payload len + 6
- src_addr: 16-bit source address
- dst_addr: 16-bit destination address
- proto: type of data transferred (similar to an Ethertype field)
SUMMARY: This driver / link layer supports:
- 16-bit addressing (16-bit) -> extract default address from CPU ID
- broadcast (broadcast address is ff:ff)
- channels from 0 to 31 [2400MHz to 2524MHz, 4MHz per channel]
- setting of TX power [+4dBm to -20dBm, in ~4dBm steps]
- 8-bit packet type/proto field (to be used as seen fit)
- setting device state (RX, SLEEP)
But so far no support for:
- link layer ACKs
- retransmissions
- 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...
|
file | nrfmin.h |
| Interface definition for the nrfmin NRF51822 radio driver.
|
|
◆ 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] | iid | the 64-bit IID, as array of 4 * 16-bit |
◆ nrfmin_get_state()
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
-
◆ nrfmin_set_channel()
int nrfmin_set_channel |
( |
uint16_t |
chan | ) |
|
Set the active channel.
- Parameters
-
[in] | chan | targeted channel [0-31] |
- Returns
- sizeof(uint16_t) on success
-
-EOVERFLOW if channel is not applicable
◆ nrfmin_set_state()
Put the device into the given state.
- Parameters
-
- 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] | power | targeted power, in [dBm] |