252 #include <pins_arduino.h>
260 #define NRF24_SPI_WRITE_MASK 0x80
265 #ifndef NRF24_MAX_MESSAGE_LEN
266 #define NRF24_MAX_MESSAGE_LEN 32
270 #define NRF24_MODE_IDLE 0
271 #define NRF24_MODE_RX 1
272 #define NRF24_MODE_TX 2
275 #define NRF24_TXFFAEM_THRESHOLD 4
276 #define NRF24_RXFFAFULL_THRESHOLD 55
279 #define NRF24_DEFAULT_NODE_ADDRESS 0x00000000
282 #define NRF24_BROADCAST_ADDRESS 0xffffffffff
285 #define NRF24_COMMAND_R_REGISTER 0x00
286 #define NRF24_COMMAND_W_REGISTER 0x20
287 #define NRF24_COMMAND_R_RX_PAYLOAD 0x61
288 #define NRF24_COMMAND_W_TX_PAYLOAD 0xa0
289 #define NRF24_COMMAND_FLUSH_TX 0xe1
290 #define NRF24_COMMAND_FLUSH_RX 0xe2
291 #define NRF24_COMMAND_REUSE_TX_PL 0xe3
292 #define NRF24_COMMAND_R_RX_PL_WID 0x60
293 #define NRF24_COMMAND_W_ACK_PAYLOAD(pipe) (0xa8|(pipe&0x7))
294 #define NRF24_COMMAND_W_TX_PAYLOAD_NOACK 0xb0
295 #define NRF24_COMMAND_NOP 0xff
298 #define NRF24_REGISTER_MASK 0x1f
299 #define NRF24_REG_00_CONFIG 0x00
300 #define NRF24_REG_01_EN_AA 0x01
301 #define NRF24_REG_02_EN_RXADDR 0x02
302 #define NRF24_REG_03_SETUP_AW 0x03
303 #define NRF24_REG_04_SETUP_RETR 0x04
304 #define NRF24_REG_05_RF_CH 0x05
305 #define NRF24_REG_06_RF_SETUP 0x06
306 #define NRF24_REG_07_STATUS 0x07
307 #define NRF24_REG_08_OBSERVE_TX 0x08
308 #define NRF24_REG_09_RPD 0x09
309 #define NRF24_REG_0A_RX_ADDR_P0 0x0a
310 #define NRF24_REG_0B_RX_ADDR_P1 0x0b
311 #define NRF24_REG_0C_RX_ADDR_P2 0x0c
312 #define NRF24_REG_0D_RX_ADDR_P3 0x0d
313 #define NRF24_REG_0E_RX_ADDR_P4 0x0e
314 #define NRF24_REG_0F_RX_ADDR_P5 0x0f
315 #define NRF24_REG_10_TX_ADDR 0x10
316 #define NRF24_REG_11_RX_PW_P0 0x11
317 #define NRF24_REG_12_RX_PW_P1 0x12
318 #define NRF24_REG_13_RX_PW_P2 0x13
319 #define NRF24_REG_14_RX_PW_P3 0x14
320 #define NRF24_REG_15_RX_PW_P4 0x15
321 #define NRF24_REG_16_RX_PW_P5 0x16
322 #define NRF24_REG_17_FIFO_STATUS 0x17
323 #define NRF24_REG_1C_DYNPD 0x1c
324 #define NRF24_REG_1D_FEATURE 0x1d
329 #define NRF24_MASK_RX_DR 0x40
330 #define NRF24_MASK_TX_DS 0x20
331 #define NRF24_MASK_MAX_RT 0x10
332 #define NRF24_EN_CRC 0x08
333 #define NRF24_CRCO 0x04
334 #define NRF24_PWR_UP 0x02
335 #define NRF24_PRIM_RX 0x01
338 #define NRF24_ENAA_P5 0x20
339 #define NRF24_ENAA_P4 0x10
340 #define NRF24_ENAA_P3 0x08
341 #define NRF24_ENAA_P2 0x04
342 #define NRF24_ENAA_P1 0x02
343 #define NRF24_ENAA_P0 0x01
346 #define NRF24_ERX_P5 0x20
347 #define NRF24_ERX_P4 0x10
348 #define NRF24_ERX_P3 0x08
349 #define NRF24_ERX_P2 0x04
350 #define NRF24_ERX_P1 0x02
351 #define NRF24_ERX_P0 0x01
354 #define NRF24_AW_3_BYTES 0x01
355 #define NRF24_AW_4_BYTES 0x02
356 #define NRF24_AW_5_BYTES 0x03
359 #define NRF24_ARD 0xf0
360 #define NRF24_ARC 0x0f
363 #define NRF24_RF_CH 0x7f
366 #define NRF24_CONT_WAVE 0x80
367 #define NRF24_RF_DR_LOW 0x20
368 #define NRF24_PLL_LOCK 0x10
369 #define NRF24_RF_DR_HIGH 0x08
370 #define NRF24_PWR 0x06
371 #define NRF24_PWR_m18dBm 0x00
372 #define NRF24_PWR_m12dBm 0x02
373 #define NRF24_PWR_m6dBm 0x04
374 #define NRF24_PWR_0dBm 0x06
377 #define NRF24_RX_DR 0x40
378 #define NRF24_TX_DS 0x20
379 #define NRF24_MAX_RT 0x10
380 #define NRF24_RX_P_NO 0x0e
381 #define NRF24_STATUS_TX_FULL 0x01
385 #define NRF24_PLOS_CNT 0xf0
386 #define NRF24_ARC_CNT 0x0f
389 #define NRF24_RPD 0x01
392 #define NRF24_TX_REUSE 0x40
393 #define NRF24_TX_FULL 0x20
394 #define NRF24_TX_EMPTY 0x10
395 #define NRF24_RX_FULL 0x02
396 #define NRF24_RX_EMPTY 0x01
399 #define NRF24_DPL_P5 0x20
400 #define NRF24_DPL_P4 0x10
401 #define NRF24_DPL_P3 0x08
402 #define NRF24_DPL_P2 0x04
403 #define NRF24_DPL_P1 0x02
404 #define NRF24_DPL_P0 0x01
407 #define NRF24_EN_DPL 0x04
408 #define NRF24_EN_ACK_PAY 0x02
409 #define NRF24_EN_DYN_ACK 0x01
467 NRF24(uint8_t chipEnablePin = 8, uint8_t chipSelectPin = SS);
489 uint8_t
spiRead(uint8_t command);
495 uint8_t
spiWrite(uint8_t command, uint8_t val);
502 void spiBurstRead(uint8_t command, uint8_t* dest, uint8_t len);
509 uint8_t
spiBurstWrite(uint8_t command, uint8_t* src, uint8_t len);
570 boolean setPipeAddress(uint8_t pipe, uint8_t* address, uint8_t len);
581 boolean setRetry(uint8_t delay, uint8_t count = 3);
607 boolean setRF(uint8_t data_rate, uint8_t power);
632 boolean send(uint8_t* data, uint8_t len,
boolean noack =
false);
673 boolean recv(uint8_t* buf, uint8_t* len);
678 uint8_t _configuration;
679 uint8_t _chipEnablePin;
680 uint8_t _chipSelectPin;
NRF24(uint8_t chipEnablePin=8, uint8_t chipSelectPin=SS)
Definition: NRF24.cpp:9
void spiBurstReadRegister(uint8_t reg, uint8_t *dest, uint8_t len)
Definition: NRF24.cpp:112
250 kbps
Definition: NRF24.h:446
boolean setRetry(uint8_t delay, uint8_t count=3)
Definition: NRF24.cpp:154
boolean send(uint8_t *data, uint8_t len, boolean noack=false)
Definition: NRF24.cpp:225
-12 dBm
Definition: NRF24.h:455
uint8_t spiWriteRegister(uint8_t reg, uint8_t val)
Definition: NRF24.cpp:107
boolean isSending()
Definition: NRF24.cpp:253
uint8_t spiCommand(uint8_t command)
Definition: NRF24.cpp:54
boolean available()
Definition: NRF24.cpp:272
boolean recv(uint8_t *buf, uint8_t *len)
Definition: NRF24.cpp:305
-18 dBm
Definition: NRF24.h:454
uint8_t flushTx()
Definition: NRF24.cpp:128
uint8_t spiWrite(uint8_t command, uint8_t val)
Definition: NRF24.cpp:72
uint8_t flushRx()
Definition: NRF24.cpp:133
uint8_t spiReadRegister(uint8_t reg)
Definition: NRF24.cpp:102
0 dBm
Definition: NRF24.h:457
bool waitAvailableTimeout(uint16_t timeout)
Definition: NRF24.cpp:295
1 Mbps
Definition: NRF24.h:444
boolean setChannel(uint8_t channel)
Definition: NRF24.cpp:138
uint8_t spiBurstWriteRegister(uint8_t reg, uint8_t *src, uint8_t len)
Definition: NRF24.cpp:117
void waitAvailable()
Definition: NRF24.cpp:285
2 Mbps
Definition: NRF24.h:445
NRF24TransmitPower
Convenient values for setting transmitter power in setRF() These are designed to agree with the value...
Definition: NRF24.h:452
void spiBurstRead(uint8_t command, uint8_t *dest, uint8_t len)
Definition: NRF24.cpp:81
uint8_t spiRead(uint8_t command)
Definition: NRF24.cpp:63
uint8_t spiBurstWrite(uint8_t command, uint8_t *src, uint8_t len)
Definition: NRF24.cpp:91
boolean waitPacketSent()
Definition: NRF24.cpp:233
boolean powerDown()
Definition: NRF24.cpp:202
boolean setPipeAddress(uint8_t pipe, uint8_t *address, uint8_t len)
Definition: NRF24.cpp:148
boolean printRegisters()
Definition: NRF24.cpp:258
boolean setRF(uint8_t data_rate, uint8_t power)
Definition: NRF24.cpp:183
NRF24DataRate
Defines convenient values for setting data rates in setRF()
Definition: NRF24.h:442
Send and receive addressed, reliable, acknowledged datagrams by nRF24L01.
Definition: NRF24.h:437
boolean powerUpTx()
Definition: NRF24.cpp:216
boolean powerUpRx()
Definition: NRF24.cpp:209
uint8_t statusRead()
Definition: NRF24.cpp:122
boolean setPayloadSize(uint8_t size)
Definition: NRF24.cpp:176
boolean init()
Definition: NRF24.cpp:16
boolean setThisAddress(uint8_t *address, uint8_t len)
Definition: NRF24.cpp:160
boolean setConfiguration(uint8_t configuration)
Definition: NRF24.cpp:143
-6 dBm
Definition: NRF24.h:456
boolean setTransmitAddress(uint8_t *address, uint8_t len)
Definition: NRF24.cpp:168