COSA
An Object-Oriented Platform for Arduino Programming
NRF24L01P Class Reference

#include <NRF24L01P.hh>

Inheritance diagram for NRF24L01P:
Inheritance graph
Collaboration diagram for NRF24L01P:
Collaboration graph

Classes

union  fifo_status_t
 
class  IRQPin
 
union  observe_tx_t
 
union  status_t
 

Public Member Functions

 NRF24L01P (uint16_t net, uint8_t dev, Board::DigitalPin csn=Board::D10, Board::DigitalPin ce=Board::D9, Board::ExternalInterruptPin irq=Board::EXT0)
 
void powerup ()
 
void standby ()
 
virtual void powerdown ()
 
virtual bool begin (const void *config=NULL)
 
virtual bool end ()
 
virtual bool available ()
 
virtual int send (uint8_t dest, uint8_t port, const iovec_t *vec)
 
virtual int send (uint8_t dest, uint8_t port, const void *buf, size_t len)
 
virtual int recv (uint8_t &src, uint8_t &port, void *buf, size_t count, uint32_t ms=0L)
 
virtual void output_power_level (int8_t dBm)
 
uint16_t trans () const
 
uint16_t retrans () const
 
uint16_t drops () const
 
uint8_t channel () const
 
void channel (uint8_t channel)
 
int16_t network_address () const
 
uint8_t device_address () const
 
void address (int16_t net, uint8_t dev)
 
virtual void wakeup_on_radio ()
 
virtual bool room ()
 
virtual int broadcast (uint8_t port, const iovec_t *vec)
 
virtual int broadcast (uint8_t port, const void *buf, size_t len)
 
virtual bool is_broadcast ()
 
virtual int input_power_level ()
 
virtual int link_quality_indicator ()
 

Static Public Attributes

static const size_t DEVICE_PAYLOAD_MAX = 32
 
static const size_t PAYLOAD_MAX = DEVICE_PAYLOAD_MAX - 2
 
static const uint8_t BROADCAST = 0x00
 

Protected Types

enum  State { POWER_DOWN_STATE = 0, STANDBY_STATE, RX_STATE, TX_STATE }
 
enum  Command {
  R_REGISTER = 0x00, W_REGISTER = 0x20, REG_MASK = 0x1f, R_RX_PAYLOAD = 0x61,
  W_TX_PAYLOAD = 0xa0, FLUSH_TX = 0xe1, FLUSH_RX = 0xe2, REUSE_TX_PL = 0xe3,
  R_RX_PL_WID = 0x60, W_ACK_PAYLOAD = 0xa8, PIPE_MASK = 0x07, W_TX_PAYLOAD_NO_ACK = 0xb0,
  NOP = 0xff
}
 
enum  Register {
  CONFIG = 0x00, EN_AA = 0x01, EN_RXADDR = 0x02, SETUP_AW = 0x03,
  SETUP_RETR = 0x04, RF_CH = 0x05, RF_SETUP = 0x06, STATUS = 0x07,
  OBSERVE_TX = 0x08, RPD = 0x09, RX_ADDR_P0 = 0x0a, RX_ADDR_P1 = 0x0b,
  RX_ADDR_P2 = 0x0c, RX_ADDR_P3 = 0x0d, RX_ADDR_P4 = 0x0e, RX_ADDR_P5 = 0x0f,
  TX_ADDR = 0x10, RX_PW_P0 = 0x11, RX_PW_P1 = 0x12, RX_PW_P2 = 0x13,
  RX_PW_P3 = 0x14, RX_PW_P4 = 0x15, RX_PW_P5 = 0x16, FIFO_STATUS = 0x17,
  DYNPD = 0x1c, FEATURE = 0x1d
}
 
enum  {
  MASK_RX_DR = 6, MASK_TX_DS = 5, MASK_MAX_RT = 4, EN_CRC = 3,
  CRCO = 2, PWR_UP = 1, PRIM_RX = 0
}
 
enum  { POWER_DOWN = 0, POWER_UP = _BV(PWR_UP) }
 
enum  {
  ENAA_P5 = 5, ENAA_P4 = 4, ENAA_P3 = 3, ENAA_P2 = 2,
  ENAA_P1 = 1, ENAA_P0 = 0, ENAA_PA = 0x3f
}
 
enum  {
  ERX_P5 = 5, ERX_P4 = 4, ERX_P3 = 3, ERX_P2 = 2,
  ERX_P1 = 1, ERX_P0 = 0, ERX_PA = 0x3f
}
 
enum  { AW = 0, AW_3BYTES = 1, AW_4BYTES = 2, AW_5BYTES = 3 }
 
enum  { ARD = 4, DEFAULT_ARD = 2, ARC = 0, DEFAULT_ARC = 15 }
 
enum  {
  CONT_WAVE = 7, RF_DR_LOW = 5, PLL_LOCK_SIGNAL = 4, RF_DR_HIGH = 3,
  RF_PWR = 1
}
 
enum  { RF_DR_1MBPS = 0, RF_DR_2MBPS = _BV(RF_DR_HIGH), RF_DR_250KBPS = _BV(RF_DR_LOW) }
 
enum  { RF_PWR_18DBM = 0, RF_PWR_12DBM = 2, RF_PWR_6DBM = 4, RF_PWR_0DBM = 6 }
 
enum  {
  RX_DR = 6, TX_DS = 5, MAX_RT = 4, RX_P_NO = 1,
  RX_P_NO_MASK = 0x0e, RX_P_NO_NONE = 0x07, TX_FIFO_FULL = 0
}
 
enum  { PLOS_CNT = 4, ARC_CNT = 0 }
 
enum  {
  TX_REUSE = 6, TX_FULL = 5, TX_EMPTY = 4, RX_FULL = 1,
  RX_EMPTY = 0
}
 
enum  {
  DPL_P5 = 5, DPL_P4 = 4, DPL_P3 = 3, DPL_P2 = 2,
  DPL_P1 = 1, DPL_P0 = 0, DPL_PA = 0x3f
}
 
enum  { EN_DPL = 2, EN_ACK_PAY = 1, EN_DYN_ACK = 0 }
 
enum  { AW_MAX = 5, PIPE_MAX = 6 }
 

Protected Member Functions

uint8_t read (Command cmd)
 
void read (Command cmd, void *buf, size_t size)
 
void write (Command cmd)
 
void write (Command cmd, uint8_t data)
 
void write (Command cmd, const void *buf, size_t size)
 
uint8_t read (Register reg)
 
void read (Register reg, void *buf, size_t size)
 
void write (Register reg, uint8_t data)
 
void write (Register reg, const void *buf, size_t size)
 
status_t read_status ()
 
fifo_status_t read_fifo_status ()
 
observe_tx_t read_observe_tx ()
 
void transmit_mode (uint8_t dest)
 
void receiver_mode ()
 
void set_clock (Clock rate)
 
void set_clock (uint32_t freq)
 

Static Protected Member Functions

static Clock clock (uint32_t freq)
 
static Clock cycle (uint16_t ns)
 

Protected Attributes

OutputPin m_ce
 Chip enable activity RX/TX select pin. More...
 
IRQPin m_irq
 Chip interrupt pin and handler. More...
 
status_t m_status
 Latest status. More...
 
State m_state
 Transceiver state. More...
 
uint16_t m_trans
 Send count. More...
 
uint16_t m_retrans
 Retransmittion count. More...
 
uint16_t m_drops
 Dropped messages. More...
 
Driverm_next
 List of drivers. More...
 
OutputPin m_cs
 Device chip select pin. More...
 
Pulse m_pulse
 Chip select pulse width. More...
 
uint8_t m_spcr
 SPI/SPCR hardware control register setting. More...
 
uint8_t m_spsr
 SPI/SPSR hardware status register. More...
 
uint8_t m_channel
 Current channel (device dependent. More...
 
addr_t m_addr
 Current network and device address. More...
 
volatile bool m_avail
 Message available. May be set by ISR. More...
 
uint8_t m_dest
 Latest message destination device address. More...
 

Static Protected Attributes

static const uint16_t Tpd2stby_ms = 3
 
static const uint16_t Tstby2a_us = 130
 
static const uint16_t Thce_us = 10
 

Friends

IOStreamoperator<< (IOStream &outs, status_t status)
 
IOStreamoperator<< (IOStream &outs, fifo_status_t status)
 
IOStreamoperator<< (IOStream &outs, observe_tx_t observe)
 

Detailed Description

Nordic Semiconductor nRF24L01+ Single Chip 2.4GHz Transceiver device driver.

Circuit

This is the pin-out for the NRF24L01+ module. NRF24L01+ is a low voltage device (3V3) and input signals are 5V tolerant.

+------------+
(GND)---------------1-|GND |
(3V3)---------------2-|VCC |
(D9)----------------3-|CE |
(D10)---------------4-|CSN |
(D13/SCK)-----------5-|SCK |
(D11/MOSI)----------6-|MOSI |
(D12/MISO)----------7-|MISO |
(D2/EXT0)-----------8-|IRQ |
+------------+

References

  1. nRF24L01+ Product Specification (Rev. 1.0) http://www.nordicsemi.com/kor/nordic/download_resource/8765/2/17776224

Definition at line 56 of file NRF24L01P.hh.

Member Enumeration Documentation

anonymous enum
protected

Register CONFIG bitfields, configuration.

Enumerator
MASK_RX_DR 

Mask interrupt caused by RX_DR.

MASK_TX_DS 

Mask interrupt caused by TX_DS.

MASK_MAX_RT 

Mask interrupt caused byt MAX_RT.

EN_CRC 

Enable CRC.

CRCO 

CRC encoding scheme (2/1 bytes CRC).

PWR_UP 

Power up/down.

PRIM_RX 

RX/TX control (PRX/PTX).

Definition at line 323 of file NRF24L01P.hh.

anonymous enum
protected
Enumerator
POWER_DOWN 

PWR_UP bit settings.

POWER_UP 

Definition at line 333 of file NRF24L01P.hh.

anonymous enum
protected

Register EN_AA bitfields, auto acknowledgement.

Enumerator
ENAA_P5 

Enable auto acknowledgement data pipe 5.

ENAA_P4 
  • data pipe 4.
ENAA_P3 
  • data pipe 3.
ENAA_P2 
  • data pipe 2.
ENAA_P1 
  • data pipe 1.
ENAA_P0 
  • data pipe 0.
ENAA_PA 

Enable all auto ack on all data pipes.

Definition at line 341 of file NRF24L01P.hh.

anonymous enum
protected

Register EN_RXADDR bitfields, enable receive pipe.

Enumerator
ERX_P5 

Enable data pipe 5.

ERX_P4 
  • data pipe 4.
ERX_P3 
  • data pipe 3.
ERX_P2 
  • data pipe 2.
ERX_P1 
  • data pipe 1.
ERX_P0 
  • data pipe 0.
ERX_PA 

Enable all data pipes.

Definition at line 354 of file NRF24L01P.hh.

anonymous enum
protected

Register SETUP_AW bitfields, setup address width (3..5).

Enumerator
AW 

RX/TX address field width (bits 2).

AW_3BYTES 

3 bytes.

AW_4BYTES 

4 bytes.

AW_5BYTES 

5 bytes.

Definition at line 367 of file NRF24L01P.hh.

anonymous enum
protected

Register SETUP_RETR bitfields, configure retransmission.

Enumerator
ARD 

Auto retransmit delay (bits 4).

  • delay * 250 us (250..4000 us).
DEFAULT_ARD 

Default auto retransmit delay (500 us)

ARC 

Auto retransmit count (bits 4).

  • retransmit count (0..15).
DEFAULT_ARC 

Default auto retransmit count (15)

Definition at line 377 of file NRF24L01P.hh.

anonymous enum
protected

Register RF_SETUP bitfields, radio configuration.

Enumerator
CONT_WAVE 

Continuous carrier transmit.

RF_DR_LOW 

Set RF data rate to 250 kbps.

PLL_LOCK_SIGNAL 

Force PLL lock signal.

RF_DR_HIGH 

Air data bitrate (2 Mbps).

RF_PWR 

Set RF output power in TX mode (bits 2).

Definition at line 389 of file NRF24L01P.hh.

anonymous enum
protected

Transmission rates RF_DR_LOW/RF_DR_HIGH values, radio bit-rate.

Enumerator
RF_DR_1MBPS 

1 Mbps.

RF_DR_2MBPS 

2 Mbps.

RF_DR_250KBPS 

250 Kbps.

Definition at line 400 of file NRF24L01P.hh.

anonymous enum
protected

Output power RF_PWR values, radio power setting.

Enumerator
RF_PWR_18DBM 

-18dBm.

RF_PWR_12DBM 

-12dBm.

RF_PWR_6DBM 

-6dBm.

RF_PWR_0DBM 

0dBm.

Definition at line 409 of file NRF24L01P.hh.

anonymous enum
protected

Register STATUS bitfields.

Enumerator
RX_DR 

Data ready RX FIFO interrupt.

TX_DS 

Data send TX FIFO interrupt.

MAX_RT 

Maximum number of TX retransmits interrupt.

RX_P_NO 

Data pipe number for available payload (3b).

RX_P_NO_MASK 

Mask pipe number.

RX_P_NO_NONE 

No pipe.

TX_FIFO_FULL 

TX FIFO full flag.

Definition at line 419 of file NRF24L01P.hh.

anonymous enum
protected

Register OBSERVE_TX bitfields, performance statistics.

Enumerator
PLOS_CNT 

Count lost packets (bits 4).

ARC_CNT 

Count retransmitted packets (bits 4).

Definition at line 456 of file NRF24L01P.hh.

anonymous enum
protected

Register FIFO_STATUS bitfields, transmission queue status.

Enumerator
TX_REUSE 

Reuse last transmitted data packat.

TX_FULL 

TX FIFO full flag.

TX_EMPTY 

TX FIFO empty flag.

RX_FULL 

RX FIFO full flag.

RX_EMPTY 

RX FIFO empty flag.

Definition at line 485 of file NRF24L01P.hh.

anonymous enum
protected

Register DYNPD bitfields.

Enumerator
DPL_P5 

Enable dynamic payload length data pipe 5.

DPL_P4 
  • data pipe 4.
DPL_P3 
  • data pipe 3.
DPL_P2 
  • data pipe 2.
DPL_P1 
  • data pipe 1.
DPL_P0 
  • data pipe 0.
DPL_PA 

Enable dynamic payload length on all pipes.

Definition at line 521 of file NRF24L01P.hh.

anonymous enum
protected

Register FEATURE bitfields.

Enumerator
EN_DPL 

Enable dynamic payload length.

EN_ACK_PAY 

Enable payload with ACK.

EN_DYN_ACK 

Enable the W_TX_PAYLOAD_NOACK command.

Definition at line 534 of file NRF24L01P.hh.

anonymous enum
protected

Configuration max values.

Enumerator
AW_MAX 

Max address width in bytes.

PIPE_MAX 

Max number of pipes.

Definition at line 599 of file NRF24L01P.hh.

enum NRF24L01P::Command
protected

SPI Commands (See chap. 8.3.1, tab. 20, pp. 51).

Enumerator
R_REGISTER 

Read command and status register.

W_REGISTER 

Write command and status register.

REG_MASK 

Mask register address (5b).

R_RX_PAYLOAD 

Read RX payload.

W_TX_PAYLOAD 

Write TX payload.

FLUSH_TX 

Flush TX FIFO.

FLUSH_RX 

Flush RX FIFO.

REUSE_TX_PL 

Reuse last transmitted payload.

R_RX_PL_WID 

Read RX payload width.

W_ACK_PAYLOAD 

Write TX payload with ACK (3 bit addr).

PIPE_MASK 

Mask pipe address.

W_TX_PAYLOAD_NO_ACK 

Disable AUTOACK on this specific packet.

NOP 

No operation, return status.

Definition at line 236 of file NRF24L01P.hh.

enum NRF24L01P::Register
protected

NRF transceiver registers map (See chap. 9, tab. 28, pp. 57).

Enumerator
CONFIG 

Configuration register.

EN_AA 

Enable auto acknowledgement.

EN_RXADDR 

Enable rx addresses.

SETUP_AW 

Setup of address width.

SETUP_RETR 

Setup of auto retransmission.

RF_CH 

RF channel.

RF_SETUP 

RF setup register.

STATUS 

Status register.

OBSERVE_TX 

Transmit observe register.

RPD 

Received power detector.

RX_ADDR_P0 

Receive address data pipe 0.

RX_ADDR_P1 
  • data pipe 1.
RX_ADDR_P2 
  • data pipe 2.
RX_ADDR_P3 
  • data pipe 3.
RX_ADDR_P4 
  • data pipe 4.
RX_ADDR_P5 
  • data pipe 5.
TX_ADDR 

Transmit address.

RX_PW_P0 

Number of bytes in RX payload in data pipe 0.

RX_PW_P1 
  • data pipe 1.
RX_PW_P2 
  • data pipe 2.
RX_PW_P3 
  • data pipe 3.
RX_PW_P4 
  • data pipe 4.
RX_PW_P5 
  • data pipe 5.
FIFO_STATUS 

FIFO status register.

DYNPD 

Enable dynamic payload length.

FEATURE 

Feature register.

Definition at line 291 of file NRF24L01P.hh.

enum NRF24L01P::State
protected

NRF transceiver states (See chap. 6.1.1, fig. 4, pp. 22).

Enumerator
POWER_DOWN_STATE 
STANDBY_STATE 
RX_STATE 
TX_STATE 

Definition at line 226 of file NRF24L01P.hh.

Constructor & Destructor Documentation

NRF24L01P::NRF24L01P ( uint16_t  net,
uint8_t  dev,
Board::DigitalPin  csn = Board::D10,
Board::DigitalPin  ce = Board::D9,
Board::ExternalInterruptPin  irq = Board::EXT0 
)

Construct NRF transceiver with given channel and pin numbers for SPI slave select, activity enable and interrupt. Default in parenthesis (Standard/Mega Arduino/TinyX4).

Parameters
[in]netnetwork address.
[in]devdevice address.
[in]csnspi slave select pin number (default D10/D53/D2).
[in]cechip enable activates pin number (default D9/D48/D3).
[in]irqinterrupt pin number (default EXT0/EXT4/EXT0).

Definition at line 28 of file NRF24L01P.cpp.

Member Function Documentation

void Wireless::Driver::address ( int16_t  net,
uint8_t  dev 
)
inlineinherited

Set network and device address. Do not use the broadcast address(0). Should be used before calling begin().

Parameters
[in]netnetwork address.
[in]devdevice address.

Definition at line 106 of file Wireless.hh.

bool NRF24L01P::available ( )
virtual

Return true(1) if the data to receive on the device otherwise false(0).

Returns
bool

Reimplemented from Wireless::Driver.

Definition at line 280 of file NRF24L01P.cpp.

bool NRF24L01P::begin ( const void *  config = NULL)
virtual

Start up the device driver. Return true(1) if successful otherwise false(0).

Parameters
[in]configdevice configuration (default NULL).
Returns
bool

Implements Wireless::Driver.

Definition at line 178 of file NRF24L01P.cpp.

virtual int Wireless::Driver::broadcast ( uint8_t  port,
const iovec_t vec 
)
inlinevirtualinherited

Broadcast message in given null terminated io vector. Returns number of bytes sent if successful otherwise a negative error code.

Parameters
[in]portdevice port (or message type).
[in]vecnull termianted io vector.
Returns
number of bytes send or negative error code.

Definition at line 220 of file Wireless.hh.

virtual int Wireless::Driver::broadcast ( uint8_t  port,
const void *  buf,
size_t  len 
)
inlinevirtualinherited

Boardcast message in given buffer, with given number of bytes. Returns number of bytes sent if successful otherwise a negative error code.

Parameters
[in]portdevice port (or message type).
[in]bufbuffer to transmit.
[in]lennumber of bytes in buffer.
Returns
number of bytes send or negative error code.

Definition at line 235 of file Wireless.hh.

uint8_t Wireless::Driver::channel ( ) const
inlineinherited

Get driver channel.

Returns
channel.

Definition at line 77 of file Wireless.hh.

void Wireless::Driver::channel ( uint8_t  channel)
inlineinherited

Set device transmission channel. Should be used before calling begin().

Parameters
[in]channel.

Definition at line 117 of file Wireless.hh.

static Clock SPI::Driver::clock ( uint32_t  freq)
inlinestaticinherited

Calculate SPI clock rate (scale factor) for given frequency.

Parameters
[in]freqdevice max frequency (in Hz).
Returns
clock rate.

Definition at line 117 of file SPI.hh.

static Clock SPI::Driver::cycle ( uint16_t  ns)
inlinestaticinherited

Calculate SPI clock rate (scale factor) for given clock cycle time in nano seconds.

Parameters
[in]nsmin device clock cycle time.
Returns
clock rate.

Definition at line 135 of file SPI.hh.

uint8_t Wireless::Driver::device_address ( ) const
inlineinherited

Get driver device address.

Returns
device address.

Definition at line 95 of file Wireless.hh.

uint16_t NRF24L01P::drops ( ) const
inline

Return number of dropped messages.

Returns
drop count.

Definition at line 217 of file NRF24L01P.hh.

virtual bool NRF24L01P::end ( )
inlinevirtual

Shut down the device driver. Return true(1) if successful otherwise false(0).

Returns
bool

Reimplemented from Wireless::Driver.

Definition at line 128 of file NRF24L01P.hh.

virtual int Wireless::Driver::input_power_level ( )
inlinevirtualinherited

Return estimated input power level (dBm). Default zero(0).

Returns
power level in dBm.

Reimplemented in CC1101, and RFM69.

Definition at line 282 of file Wireless.hh.

virtual bool Wireless::Driver::is_broadcast ( )
inlinevirtualinherited

Return true(1) if the latest received message was a broadcast otherwise false(0).

Definition at line 262 of file Wireless.hh.

virtual int Wireless::Driver::link_quality_indicator ( )
inlinevirtualinherited

Return link quality indicator. Default zero(0).

Returns
quality indicator.

Reimplemented in VWI, and CC1101.

Definition at line 292 of file Wireless.hh.

int16_t Wireless::Driver::network_address ( ) const
inlineinherited

Get driver network address.

Returns
network address.

Definition at line 86 of file Wireless.hh.

void NRF24L01P::output_power_level ( int8_t  dBm)
virtual

Set output power level (-30..10 dBm)

Parameters
[in]dBm.

Reimplemented from Wireless::Driver.

Definition at line 328 of file NRF24L01P.cpp.

void NRF24L01P::powerdown ( )
virtual

Set power down. Turn off radio and go into low power mode.

Reimplemented from Wireless::Driver.

Definition at line 169 of file NRF24L01P.cpp.

void NRF24L01P::powerup ( )
virtual

Set power up mode. Will initiate radio with necessary settings after power on reset.

Reimplemented from Wireless::Driver.

Definition at line 112 of file NRF24L01P.cpp.

uint8_t NRF24L01P::read ( Command  cmd)
protected

Issue read command register.

Parameters
[in]cmdcommand.
Returns
command value.

Definition at line 46 of file NRF24L01P.cpp.

void NRF24L01P::read ( Command  cmd,
void *  buf,
size_t  size 
)
protected

Read command values into given buffer.

Parameters
[in]cmdcommand.
[in]bufbuffer for read data.
[in]sizenumber of bytes to read.

Definition at line 58 of file NRF24L01P.cpp.

uint8_t NRF24L01P::read ( Register  reg)
inlineprotected

Read register value. Issue R_REGISTER command with given register and read value.

Parameters
[in]regregister address.
Returns
register value.

Definition at line 547 of file NRF24L01P.hh.

void NRF24L01P::read ( Register  reg,
void *  buf,
size_t  size 
)
inlineprotected

Read register values. Issue R_REGISTER command with given register and write given buffer.

Parameters
[in]regregister address.
[in]bufbuffer for read data.
[in]sizenumber of bytes to read.

Definition at line 559 of file NRF24L01P.hh.

fifo_status_t NRF24L01P::read_fifo_status ( )
inlineprotected

Read FIFO status. Issue FIFO_STATUS command to read status.

Returns
fifo status.

Definition at line 639 of file NRF24L01P.hh.

observe_tx_t NRF24L01P::read_observe_tx ( )
inlineprotected

Read transmission status. Issue OBSERVE_TX command to read status.

Returns
observe tx status.

Definition at line 649 of file NRF24L01P.hh.

NRF24L01P::status_t NRF24L01P::read_status ( )
protected

Read status. Issue NOP command to read status.

Returns
status.

Definition at line 101 of file NRF24L01P.cpp.

void NRF24L01P::receiver_mode ( )
protected

Set receive mode.

Definition at line 129 of file NRF24L01P.cpp.

int NRF24L01P::recv ( uint8_t &  src,
uint8_t &  port,
void *  buf,
size_t  count,
uint32_t  ms = 0L 
)
virtual

Receive message and store into given buffer with given maximum size. The source network address is returned in the parameter src. Returns error code(-2) if no message is available and/or a timeout occured. Returns error code(-1) if the buffer size if to small for incoming message or if the receiver fifo has overflowed. Otherwise the actual number of received bytes is returned

Parameters
[out]srcsource network address.
[out]portdevice port (or message type).
[in]bufbuffer to store incoming message.
[in]countmaximum number of bytes to receive.
[in]msmaximum time out period.
Returns
number of bytes received or negative error code.

Implements Wireless::Driver.

Definition at line 292 of file NRF24L01P.cpp.

uint16_t NRF24L01P::retrans ( ) const
inline

Return number of retransmissions.

Returns
retransmitt count.

Definition at line 208 of file NRF24L01P.hh.

virtual bool Wireless::Driver::room ( )
inlinevirtualinherited

Return true(1) if there is room to send on the device otherwise false(0).

Returns
bool.

Definition at line 176 of file Wireless.hh.

int NRF24L01P::send ( uint8_t  dest,
uint8_t  port,
const iovec_t vec 
)
virtual

Send message in given null terminated io vector. Returns number of bytes sent. Returns error code(-1) if number of bytes is greater than PAYLOAD_MAX. Return error code(-2) if fails to set transmit mode.

Parameters
[in]destdestination network address.
[in]portdevice port (or message type).
[in]vecnull termianted io vector.
Returns
number of bytes send or negative error code.

Implements Wireless::Driver.

Definition at line 211 of file NRF24L01P.cpp.

int NRF24L01P::send ( uint8_t  dest,
uint8_t  port,
const void *  buf,
size_t  len 
)
virtual

Send message in given buffer, with given number of bytes. Returns number of bytes sent. Returns error code(-1) if number of bytes is greater than PAYLOAD_MAX. Return error code(-2) if fails to set transmit mode. Note that port numbers (128 and higher are reserved for system protocols).

Parameters
[in]destdestination network address.
[in]portdevice port (or message type).
[in]bufbuffer to transmit.
[in]lennumber of bytes in buffer.
Returns
number of bytes send or negative error code.

Reimplemented from Wireless::Driver.

Definition at line 270 of file NRF24L01P.cpp.

void SPI::Driver::set_clock ( Clock  rate)
inherited

Set SPI master clock rate.

Parameters
[in]clockrate.

Definition at line 297 of file SPI.cpp.

void SPI::Driver::set_clock ( uint32_t  freq)
inlineinherited

Set SPI master clock frequency.

Parameters
[in]freqdevice max frequency (in Hz).

Definition at line 157 of file SPI.hh.

void NRF24L01P::standby ( )

Set standby mode.

Definition at line 161 of file NRF24L01P.cpp.

uint16_t NRF24L01P::trans ( ) const
inline

Return number of transmitted messages.

Returns
transmitt count.

Definition at line 199 of file NRF24L01P.hh.

void NRF24L01P::transmit_mode ( uint8_t  dest)
protected

Set transmit mode and given destination device address.

Parameters

Definition at line 142 of file NRF24L01P.cpp.

virtual void Wireless::Driver::wakeup_on_radio ( )
inlinevirtualinherited

Set device in wakeup on radio mode.

Reimplemented in CC1101, and RFM69.

Definition at line 158 of file Wireless.hh.

void NRF24L01P::write ( Command  cmd)
protected

Issue command.

Parameters
[in]cmdcommand.

Definition at line 69 of file NRF24L01P.cpp.

void NRF24L01P::write ( Command  cmd,
uint8_t  data 
)
protected

Write command and value.

Parameters
[in]cmdcommand.
[in]datanew setting.

Definition at line 79 of file NRF24L01P.cpp.

void NRF24L01P::write ( Command  cmd,
const void *  buf,
size_t  size 
)
protected

Write command and values from given buffer.

Parameters
[in]cmdcommand.
[in]bufbuffer with data to write.
[in]sizenumber of bytes to write.

Definition at line 90 of file NRF24L01P.cpp.

void NRF24L01P::write ( Register  reg,
uint8_t  data 
)
inlineprotected

Write command and value. Issue W_REGISTER command with register and write data.

Parameters
[in]regregister address.
[in]datanew setting.
Returns
status.

Definition at line 571 of file NRF24L01P.hh.

void NRF24L01P::write ( Register  reg,
const void *  buf,
size_t  size 
)
inlineprotected

Write command and values. Issue W_REGISTER command with register and write data from given buffer.

Parameters
[in]regregister address.
[in]bufbuffer with data to write.
[in]sizenumber of bytes to write.
Returns
status.

Definition at line 584 of file NRF24L01P.hh.

Friends And Related Function Documentation

IOStream& operator<< ( IOStream outs,
status_t  status 
)
friend

Output operator for status field print out.

Parameters
[in]outsoutput stream.
[in]statusvalue to print.
Returns
iostream.

Definition at line 338 of file NRF24L01P.cpp.

IOStream& operator<< ( IOStream outs,
fifo_status_t  status 
)
friend

Output operator for transmitter queue status field print out.

Parameters
[in]outsoutput stream.
[in]statusvalue to print.
Returns
iostream.

Definition at line 355 of file NRF24L01P.cpp.

IOStream& operator<< ( IOStream outs,
observe_tx_t  observe 
)
friend

Output operator for observe statistics field print out.

Parameters
[in]outsoutput stream.
[in]observevalue to print.
Returns
iostream.

Definition at line 348 of file NRF24L01P.cpp.

Member Data Documentation

const uint8_t Wireless::Driver::BROADCAST = 0x00
staticinherited

Broadcast device address.

Definition at line 58 of file Wireless.hh.

const size_t NRF24L01P::DEVICE_PAYLOAD_MAX = 32
static

Maximum size of payload on device.

Definition at line 61 of file NRF24L01P.hh.

addr_t Wireless::Driver::m_addr
protectedinherited

Current network and device address.

Definition at line 299 of file Wireless.hh.

volatile bool Wireless::Driver::m_avail
protectedinherited

Message available. May be set by ISR.

Definition at line 300 of file Wireless.hh.

OutputPin NRF24L01P::m_ce
protected

Chip enable activity RX/TX select pin.

Definition at line 620 of file NRF24L01P.hh.

uint8_t Wireless::Driver::m_channel
protectedinherited

Current channel (device dependent.

Definition at line 298 of file Wireless.hh.

OutputPin SPI::Driver::m_cs
protectedinherited

Device chip select pin.

Definition at line 166 of file SPI.hh.

uint8_t Wireless::Driver::m_dest
protectedinherited

Latest message destination device address.

Definition at line 301 of file Wireless.hh.

uint16_t NRF24L01P::m_drops
protected

Dropped messages.

Definition at line 627 of file NRF24L01P.hh.

IRQPin NRF24L01P::m_irq
protected

Chip interrupt pin and handler.

Definition at line 621 of file NRF24L01P.hh.

Driver* SPI::Driver::m_next
protectedinherited

List of drivers.

Definition at line 164 of file SPI.hh.

Pulse SPI::Driver::m_pulse
protectedinherited

Chip select pulse width.

Definition at line 167 of file SPI.hh.

uint16_t NRF24L01P::m_retrans
protected

Retransmittion count.

Definition at line 626 of file NRF24L01P.hh.

uint8_t SPI::Driver::m_spcr
protectedinherited

SPI/SPCR hardware control register setting.

Definition at line 173 of file SPI.hh.

uint8_t SPI::Driver::m_spsr
protectedinherited

SPI/SPSR hardware status register.

Definition at line 174 of file SPI.hh.

State NRF24L01P::m_state
protected

Transceiver state.

Definition at line 623 of file NRF24L01P.hh.

status_t NRF24L01P::m_status
protected

Latest status.

Definition at line 622 of file NRF24L01P.hh.

uint16_t NRF24L01P::m_trans
protected

Send count.

Definition at line 625 of file NRF24L01P.hh.

const size_t NRF24L01P::PAYLOAD_MAX = DEVICE_PAYLOAD_MAX - 2
static

Maximum size of payload. The device allows 32 bytes payload. The source address one byte and port one byte as header.

Definition at line 67 of file NRF24L01P.hh.

const uint16_t NRF24L01P::Thce_us = 10
staticprotected

Definition at line 594 of file NRF24L01P.hh.

const uint16_t NRF24L01P::Tpd2stby_ms = 3
staticprotected

Timing information (ch. 6.1.7, tab. 16, pp. 24).

Definition at line 592 of file NRF24L01P.hh.

const uint16_t NRF24L01P::Tstby2a_us = 130
staticprotected

Definition at line 593 of file NRF24L01P.hh.


The documentation for this class was generated from the following files: