FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
devices::rf::IRQ_NRF24L01< CSN, CE, IRQ > Class Template Reference

SPI device driver for Nordic Semiconductor nRF24L01+ support, with IRQ. More...

#include <fastarduino/devices/nrf24l01p.h>

Inheritance diagram for devices::rf::IRQ_NRF24L01< CSN, CE, IRQ >:
Collaboration diagram for devices::rf::IRQ_NRF24L01< CSN, CE, IRQ >:

Public Member Functions

 IRQ_NRF24L01 (uint16_t net, uint8_t dev)
 Construct NRF transceiver with given channel and pin numbers for SPI slave select, activity enable and interrupt. More...
 
void begin ()
 Start up the device driver. More...
 
void end ()
 Shut down the device driver. More...
 
- Public Member Functions inherited from devices::rf::NRF24L01< CSN, CE >
 NRF24L01 (uint16_t net, uint8_t dev)
 Construct NRF transceiver with given channel and pin numbers for SPI slave select, activity enable and interrupt. More...
 
uint8_t get_channel () const
 Get driver channel. More...
 
uint16_t get_network_address () const
 Get driver network address. More...
 
uint8_t get_device_address () const
 Get driver device address. More...
 
void set_address (int16_t net, uint8_t dev)
 Set network and device address. More...
 
void set_channel (uint8_t channel)
 Set device transmission channel. More...
 
void begin ()
 Start up the device driver. More...
 
void end ()
 Shut down the device driver. More...
 
void powerup ()
 Set power up mode. More...
 
void standby ()
 Set standby mode. More...
 
void powerdown ()
 Set power down. More...
 
template<typename T , typename TREF = const T&>
int send (uint8_t dest, uint8_t port, TREF buf)
 Send message with given object reference. More...
 
int send (uint8_t dest, uint8_t port)
 Send an empty message. More...
 
template<typename T , typename TREF = T&>
int recv (uint8_t &src, uint8_t &port, TREF buf, uint32_t ms=0L)
 Receive message and store into given object reference. More...
 
int recv (uint8_t &src, uint8_t &port, uint32_t ms=0L)
 Receive an empty message. More...
 
void set_output_power_level (int8_t dBm)
 Set output power level (-30..10 dBm) More...
 
uint16_t get_trans () const
 Return number of transmitted messages. More...
 
uint16_t get_retrans () const
 Return number of retransmissions. More...
 
uint16_t get_drops () const
 Return number of dropped messages. More...
 
template<typename T , typename TREF = const T&>
int broadcast (uint8_t port, TREF buf)
 Broadcast message with given object reference. More...
 
bool is_broadcast () const
 Return true if the latest received message was a broadcast otherwise false. More...
 

Additional Inherited Members

- Static Public Attributes inherited from devices::rf::NRF24L01< CSN, CE >
static const uint8_t BROADCAST = 0x00
 Broadcast device address. More...
 
static const size_t DEVICE_PAYLOAD_MAX = 32
 Maximum size of payload on device. More...
 
static const size_t PAYLOAD_MAX = DEVICE_PAYLOAD_MAX - 2
 Maximum size of payload. More...
 
- Protected Types inherited from devices::rf::NRF24L01< CSN, CE >
enum class  Command : uint8_t {
  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
}
 SPI Commands (See chap. More...
 
enum class  Register : uint8_t {
  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
}
 NRF transceiver registers map (See chap. More...
 
enum class  State : uint8_t {
  POWER_DOWN_STATE = 0 ,
  STANDBY_STATE ,
  RX_STATE ,
  TX_STATE
}
 NRF transceiver states (See chap. More...
 
- Protected Member Functions inherited from spi::SPIDevice< CSN >
 SPIDevice () INLINE=default
 Create a new SPIDevice; this sets up the CS pin for later use during transfers.
 
void start_transfer ()
 Start an SPI transfer to this device. More...
 
void end_transfer () INLINE
 End the current SPI ransfer tot hsi device. More...
 
- Protected Member Functions inherited from spi::AbstractSPIDevice
 AbstractSPIDevice (const AbstractSPIDevice &)=delete
 
AbstractSPIDeviceoperator= (const AbstractSPIDevice &)=delete
 
uint8_t transfer (uint8_t data)
 Transfer one byte to the currently selected SPI slave device through MOSI pin, and get the byte returned by the device through MISO pin. More...
 
void transfer (uint8_t *data, uint16_t size)
 Transfer an array of payload data to the currently selected SPI slave device through MOSI pin, and get all data bytes simultaneously received from that device through MISO pin. More...
 
void transfer (const uint8_t *data, uint16_t size)
 Transfer an array of payload data to the currently selected SPI slave device through MOSI pin; any data bytes simultaneously received from that device through MISO pin are lost. More...
 
void transfer (uint8_t *data, uint16_t size, uint8_t sent)
 Transfer the provided byte sent several times to the currently selected SPI slave device through MOSI pin, and get all data bytes simultaneously received from that device through MISO pin. More...
 
void transfer (uint16_t size, uint8_t sent)
 Transfer the provided byte sent several times to the currently selected SPI slave device through MOSI pin; any data bytes simultaneously received from that device through MISO pin are lost. More...
 

Detailed Description

template<board::DigitalPin CSN, board::DigitalPin CE, board::ExternalInterruptPin IRQ>
class devices::rf::IRQ_NRF24L01< CSN, CE, IRQ >

SPI device driver for Nordic Semiconductor nRF24L01+ support, with IRQ.

nRF24L01+ is a cheap 2.4GHz RX/TX chip.

It must be powered at 3.3V maximum but all its input pins are 5V tolerant, hence no level shifting is needed to operate it.

                     NRF24L01P
                  +------------+

(GND)------------—1-|GND | (3V3)------------—2-|VCC | (Dn)-------------—3-|CE | (Dn)-------------—4-|CSN | (SCK)------------—5-|SCK | (MOSI)-----------—6-|MOSI | (MISO)-----------—7-|MISO | (PCIn/EXTn)------—8-|IRQ | +---------—+ Notes:

  • IRQ can normally be linked to any EXT or PCI pin. However, on some AVR chips, some pins will not awaken the MCU from some "deep" sleep modes. Hence one has to think about this when selecting the pin.
  • CSN is the usual CS pin used by SPI to select the device and can be set to any AVR pin IMPORTANT: PCI pin is not yet supported actually.
Template Parameters
CSNthe board::DigitalPin connected to the CSN pin
CEthe board::DigitalPin connected to the CE pin
IRQthe board::ExternalInterruptPin connected to the IRQ pin
See also
NRF24L01

Definition at line 630 of file nrf24l01p.h.

Constructor & Destructor Documentation

◆ IRQ_NRF24L01()

devices::rf::IRQ_NRF24L01< CSN, CE, IRQ >::IRQ_NRF24L01 ( uint16_t  net,
uint8_t  dev 
)
inline

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.

Definition at line 640 of file nrf24l01p.h.

Member Function Documentation

◆ begin()

void devices::rf::IRQ_NRF24L01< CSN, CE, IRQ >::begin ( )
inline

Start up the device driver.

This must be called before any transmission or reception can take place.

Definition at line 649 of file nrf24l01p.h.

◆ end()

void devices::rf::IRQ_NRF24L01< CSN, CE, IRQ >::end ( )
inline

Shut down the device driver.

Definition at line 658 of file nrf24l01p.h.


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