10#include <RHGenericSPI.h>
11#include <RHNRFSPIDriver.h>
15#define RH_NRF24_MAX_PAYLOAD_LEN 32
19#define RH_NRF24_HEADER_LEN 4
23#define RH_NRF24_MAX_MESSAGE_LEN (RH_NRF24_MAX_PAYLOAD_LEN-RH_NRF24_HEADER_LEN)
26#define RH_NRF24_COMMAND_R_REGISTER 0x00
27#define RH_NRF24_COMMAND_W_REGISTER 0x20
28#define RH_NRF24_COMMAND_ACTIVATE 0x50
29#define RH_NRF24_COMMAND_R_RX_PAYLOAD 0x61
30#define RH_NRF24_COMMAND_W_TX_PAYLOAD 0xa0
31#define RH_NRF24_COMMAND_FLUSH_TX 0xe1
32#define RH_NRF24_COMMAND_FLUSH_RX 0xe2
33#define RH_NRF24_COMMAND_REUSE_TX_PL 0xe3
34#define RH_NRF24_COMMAND_R_RX_PL_WID 0x60
35#define RH_NRF24_COMMAND_W_ACK_PAYLOAD(pipe) (0xa8|(pipe&0x7))
36#define RH_NRF24_COMMAND_W_TX_PAYLOAD_NOACK 0xb0
37#define RH_NRF24_COMMAND_NOP 0xff
40#define RH_NRF24_REGISTER_MASK 0x1f
41#define RH_NRF24_REG_00_CONFIG 0x00
42#define RH_NRF24_REG_01_EN_AA 0x01
43#define RH_NRF24_REG_02_EN_RXADDR 0x02
44#define RH_NRF24_REG_03_SETUP_AW 0x03
45#define RH_NRF24_REG_04_SETUP_RETR 0x04
46#define RH_NRF24_REG_05_RF_CH 0x05
47#define RH_NRF24_REG_06_RF_SETUP 0x06
48#define RH_NRF24_REG_07_STATUS 0x07
49#define RH_NRF24_REG_08_OBSERVE_TX 0x08
50#define RH_NRF24_REG_09_RPD 0x09
51#define RH_NRF24_REG_0A_RX_ADDR_P0 0x0a
52#define RH_NRF24_REG_0B_RX_ADDR_P1 0x0b
53#define RH_NRF24_REG_0C_RX_ADDR_P2 0x0c
54#define RH_NRF24_REG_0D_RX_ADDR_P3 0x0d
55#define RH_NRF24_REG_0E_RX_ADDR_P4 0x0e
56#define RH_NRF24_REG_0F_RX_ADDR_P5 0x0f
57#define RH_NRF24_REG_10_TX_ADDR 0x10
58#define RH_NRF24_REG_11_RX_PW_P0 0x11
59#define RH_NRF24_REG_12_RX_PW_P1 0x12
60#define RH_NRF24_REG_13_RX_PW_P2 0x13
61#define RH_NRF24_REG_14_RX_PW_P3 0x14
62#define RH_NRF24_REG_15_RX_PW_P4 0x15
63#define RH_NRF24_REG_16_RX_PW_P5 0x16
64#define RH_NRF24_REG_17_FIFO_STATUS 0x17
65#define RH_NRF24_REG_1C_DYNPD 0x1c
66#define RH_NRF24_REG_1D_FEATURE 0x1d
71#define RH_NRF24_MASK_RX_DR 0x40
72#define RH_NRF24_MASK_TX_DS 0x20
73#define RH_NRF24_MASK_MAX_RT 0x10
74#define RH_NRF24_EN_CRC 0x08
75#define RH_NRF24_CRCO 0x04
76#define RH_NRF24_PWR_UP 0x02
77#define RH_NRF24_PRIM_RX 0x01
80#define RH_NRF24_ENAA_P5 0x20
81#define RH_NRF24_ENAA_P4 0x10
82#define RH_NRF24_ENAA_P3 0x08
83#define RH_NRF24_ENAA_P2 0x04
84#define RH_NRF24_ENAA_P1 0x02
85#define RH_NRF24_ENAA_P0 0x01
88#define RH_NRF24_ERX_P5 0x20
89#define RH_NRF24_ERX_P4 0x10
90#define RH_NRF24_ERX_P3 0x08
91#define RH_NRF24_ERX_P2 0x04
92#define RH_NRF24_ERX_P1 0x02
93#define RH_NRF24_ERX_P0 0x01
96#define RH_NRF24_AW_3_BYTES 0x01
97#define RH_NRF24_AW_4_BYTES 0x02
98#define RH_NRF24_AW_5_BYTES 0x03
101#define RH_NRF24_ARD 0xf0
102#define RH_NRF24_ARC 0x0f
105#define RH_NRF24_RF_CH 0x7f
108#define RH_NRF24_CONT_WAVE 0x80
109#define RH_NRF24_RF_DR_LOW 0x20
110#define RH_NRF24_PLL_LOCK 0x10
111#define RH_NRF24_RF_DR_HIGH 0x08
112#define RH_NRF24_PWR 0x06
113#define RH_NRF24_PWR_m18dBm 0x00
114#define RH_NRF24_PWR_m12dBm 0x02
115#define RH_NRF24_PWR_m6dBm 0x04
116#define RH_NRF24_PWR_0dBm 0x06
117#define RH_NRF24_LNA_HCURR 0x01
120#define RH_NRF24_RX_DR 0x40
121#define RH_NRF24_TX_DS 0x20
122#define RH_NRF24_MAX_RT 0x10
123#define RH_NRF24_RX_P_NO 0x0e
124#define RH_NRF24_STATUS_TX_FULL 0x01
127#define RH_NRF24_PLOS_CNT 0xf0
128#define RH_NRF24_ARC_CNT 0x0f
131#define RH_NRF24_RPD 0x01
134#define RH_NRF24_TX_REUSE 0x40
135#define RH_NRF24_TX_FULL 0x20
136#define RH_NRF24_TX_EMPTY 0x10
137#define RH_NRF24_RX_FULL 0x02
138#define RH_NRF24_RX_EMPTY 0x01
141#define RH_NRF24_DPL_ALL 0x3f
142#define RH_NRF24_DPL_P5 0x20
143#define RH_NRF24_DPL_P4 0x10
144#define RH_NRF24_DPL_P3 0x08
145#define RH_NRF24_DPL_P2 0x04
146#define RH_NRF24_DPL_P1 0x02
147#define RH_NRF24_DPL_P0 0x01
150#define RH_NRF24_EN_DPL 0x04
151#define RH_NRF24_EN_ACK_PAY 0x02
152#define RH_NRF24_EN_DYN_ACK 0x01
465 RH_NRF24(uint8_t chipEnablePin = 8, uint8_t slaveSelectPin = SS,
RHGenericSPI& spi = hardware_spi);
561 bool send(
const uint8_t* data, uint8_t len);
594 bool recv(uint8_t* buf, uint8_t* len);
605 virtual bool sleep();
624 uint8_t _configuration;
627 uint8_t _chipEnablePin;
633 uint8_t _buf[RH_NRF24_MAX_PAYLOAD_LEN];
virtual RHMode mode()
Definition RHGenericDriver.cpp:165
Base class for SPI interfaces.
Definition RHGenericSPI.h:31
Base class for RadioHead drivers that use the SPI bus to communicate with its NRF family transport ha...
Definition RHNRFSPIDriver.h:34
Send and receive unaddressed, unreliable datagrams by nRF24L01 and compatible transceivers.
Definition RH_NRF24.h:424
uint8_t statusRead()
Definition RH_NRF24.cpp:82
bool setOpMode(uint8_t mode)
Definition RH_NRF24.cpp:104
bool setRF(DataRate data_rate, TransmitPower power)
Definition RH_NRF24.cpp:122
uint8_t spiBurstWriteRegister(uint8_t reg, uint8_t *src, uint8_t len)
Definition RH_NRF24.cpp:77
void clearRxBuf()
Clear our local receive buffer.
Definition RH_NRF24.cpp:325
uint8_t spiWriteRegister(uint8_t reg, uint8_t val)
Definition RH_NRF24.cpp:67
uint8_t spiBurstReadRegister(uint8_t reg, uint8_t *dest, uint8_t len)
Definition RH_NRF24.cpp:72
bool recv(uint8_t *buf, uint8_t *len)
Definition RH_NRF24.cpp:331
bool isSending()
Definition RH_NRF24.cpp:236
uint8_t spiReadRegister(uint8_t reg)
Definition RH_NRF24.cpp:62
virtual bool waitPacketSent()
Definition RH_NRF24.cpp:209
void validateRxBuf()
Examine the receive buffer to determine whether the message is for this node.
Definition RH_NRF24.cpp:276
void setModeTx()
Definition RH_NRF24.cpp:173
bool setChannel(uint8_t channel)
Definition RH_NRF24.cpp:98
bool printRegisters()
Definition RH_NRF24.cpp:242
bool send(const uint8_t *data, uint8_t len)
Definition RH_NRF24.cpp:188
void setModeIdle()
Definition RH_NRF24.cpp:141
uint8_t maxMessageLength()
Definition RH_NRF24.cpp:346
DataRate
Defines convenient values for setting data rates in setRF()
Definition RH_NRF24.h:429
@ DataRate1Mbps
1 Mbps
Definition RH_NRF24.h:430
@ DataRate2Mbps
2 Mbps
Definition RH_NRF24.h:431
@ DataRate250kbps
250 kbps
Definition RH_NRF24.h:432
bool setNetworkAddress(uint8_t *address, uint8_t len)
Definition RH_NRF24.cpp:110
bool available()
Definition RH_NRF24.cpp:294
TransmitPower
Convenient values for setting transmitter power in setRF() These are designed to agree with the value...
Definition RH_NRF24.h:439
@ TransmitPowerm18dBm
On nRF24, -18 dBm.
Definition RH_NRF24.h:441
@ TransmitPowerm12dBm
On nRF24, -12 dBm.
Definition RH_NRF24.h:442
@ RFM73TransmitPowerm0dBm
On RFM73, 0 dBm.
Definition RH_NRF24.h:450
@ RFM73TransmitPowerm5dBm
On RFM73, -5 dBm.
Definition RH_NRF24.h:449
@ RFM73TransmitPower5dBm
On RFM73, 5 dBm. 20dBm on RFM73P-S2 ?
Definition RH_NRF24.h:451
@ TransmitPowerm6dBm
On nRF24, -6 dBm.
Definition RH_NRF24.h:443
@ RFM73TransmitPowerm10dBm
On RFM73, -10 dBm.
Definition RH_NRF24.h:448
@ TransmitPower0dBm
On nRF24, 0 dBm.
Definition RH_NRF24.h:444
virtual bool sleep()
Definition RH_NRF24.cpp:151
uint8_t flushRx()
Definition RH_NRF24.cpp:93
void setModeRx()
Definition RH_NRF24.cpp:163
uint8_t flushTx()
Definition RH_NRF24.cpp:88
bool init()
Definition RH_NRF24.cpp:17