38 #define NRF_R_REGISTER 0x00
39 #define NRF_W_REGISTER 0x20
40 #define NRF_R_RX_PAYLOAD 0x61
41 #define NRF_W_TX_PAYLOAD 0xA0
42 #define NRF_FLUSH_TX 0xE1
43 #define NRF_FLUSH_RX 0xE2
44 #define NRF_REUSE_TX_PL 0xE3
45 #define NRF_ACTIVATE 0x50
46 #define NRF_R_RX_PL_WID 0x60
47 #define NRF_W_ACK_PAYLOAD 0xA8
48 #define NRF_W_TX_PAYLOAD_NO_ACK 0xB0
51 #define NRF_REGISTER_gm 0x1F
52 #define NRF_PIPE_gm 0x07
57 #define REG_CONFIG 0x00
58 #define REG_EN_AA 0x01
59 #define REG_EN_RXADDR 0x02
60 #define REG_SETUP_AW 0x03
61 #define REG_SETUP_RETR 0x04
62 #define REG_RF_CH 0x05
63 #define REG_RF_SETUP 0x06
64 #define REG_STATUS 0x07
65 #define REG_OBSERVE_TX 0x08
68 #define REG_RX_ADDR_P0 0x0A
69 #define REG_RX_ADDR_P1 0x0B
70 #define REG_RX_ADDR_P2 0x0C
71 #define REG_RX_ADDR_P3 0x0D
72 #define REG_RX_ADDR_P4 0x0E
73 #define REG_RX_ADDR_P5 0x0F
74 #define REG_TX_ADDR 0x10
75 #define REG_RX_PW_P0 0x11
76 #define REG_RX_PW_P1 0x12
77 #define REG_RX_PW_P2 0x13
78 #define REG_RX_PW_P3 0x14
79 #define REG_RX_PW_P4 0x15
80 #define REG_RX_PW_P5 0x16
81 #define REG_FIFO_STATUS 0x17
82 #define REG_DYNPD 0x1C
83 #define REG_FEATURE 0x1D
86 #define NRF_CONFIG_MASK_RX_DR_bm (1<<6)
87 #define NRF_CONFIG_MASK_TX_DS_bm (1<<5)
88 #define NRF_CONFIG_MASK_MAX_RT_bm (1<<4)
89 #define NRF_CONFIG_EN_CRC_bm (1<<3)
90 #define NRF_CONFIG_CRC0_bm (1<<2)
91 #define NRF_CONFIG_PWR_UP_bm (1<<1)
92 #define NRF_CONFIG_PRIM_RX_bm (1<<0)
100 #define NRF_CONFIG_CRC_gm ( NRF_CONFIG_EN_CRC_bm | NRF_CONFIG_CRC0_bm )
103 #define NRF_EN_AA_P5_bm (1<<5)
104 #define NRF_EN_AA_P4_bm (1<<4)
105 #define NRF_EN_AA_P3_bm (1<<3)
106 #define NRF_EN_AA_P2_bm (1<<2)
107 #define NRF_EN_AA_P1_bm (1<<1)
108 #define NRF_EN_AA_P0_bm (1<<0)
109 #define NRF_EN_AA_P_ALL_gm (0x3F)
112 #define NRF_EN_RXADDR_P5_bm (1<<5)
113 #define NRF_EN_RXADDR_P4_bm (1<<4)
114 #define NRF_EN_RXADDR_P3_bm (1<<3)
115 #define NRF_EN_RXADDR_P2_bm (1<<2)
116 #define NRF_EN_RXADDR_P1_bm (1<<1)
117 #define NRF_EN_RXADDR_P0_bm (1<<0)
147 #define NRF_SETUP_ARD_gm (0xF0)
148 #define NRF_SETUP_ARD_gp 4
169 #define NRF_SETUP_ARC_gm (0x0F)
170 #define NRF_SETUP_ARC_gp 0
173 #define NRF_RF_CH_gm 0x7F
174 #define NRF_RF_CH_max 0x7F
177 #define NRF_RF_SETUP_CONT_WAVE_bm (1<<7)
178 #define NRF_RF_SETUP_RF_DR_LOW_bm (1<<5)
179 #define NRF_RF_SETUP_PLL_LOCK_bm (1<<4)
180 #define NRF_RF_SETUP_RF_DR_HIGH_bm (1<<3)
187 #define NRF_RF_SETUP_RF_DR_gm ((1<<5)|(1<<3))
195 #define NRF_RF_SETUP_PWR_gm (0x06)
198 #define NRF_STATUS_RX_DR_bm (1<<6)
199 #define NRF_STATUS_TX_DS_bm (1<<5)
200 #define NRF_STATUS_MAX_RT_bm (1<<4)
211 #define NRF_STATUS_RX_P_NO_gp 1
212 #define NRF_STATUS_RX_P_NO_gm (0x0E)
213 #define NRF_STATUS_TX_FULL_bm (1<<0)
216 #define NRF_OBSERVE_TX_PLOS_CNT_gm 0xF0
217 #define NRF_OBSERVE_TX_ARC_CNT_gm 0x0F
220 #define NRF_RPD_RPD_bm (1<<0)
221 #define NRF_CD_CD_bm (1<<0)
224 #define NRF_RX_PW_P0_gm (0x3F)
225 #define NRF_RX_PW_P1_gm (0x3F)
226 #define NRF_RX_PW_P2_gm (0x3F)
227 #define NRF_RX_PW_P3_gm (0x3F)
228 #define NRF_RX_PW_P4_gm (0x3F)
229 #define NRF_RX_PW_P5_gm (0x3F)
232 #define NRF_FIFO_STATUS_TX_REUSE_bm (1<<6)
233 #define NRF_FIFO_STATUS_TX_FULL_bm (1<<5)
234 #define NRF_FIFO_STATUS_TX_EMPTY_bm (1<<4)
235 #define NRF_FIFO_STATUS_RX_FULL_bm (1<<1)
236 #define NRF_FIFO_STATUS_RX_EMPTY_bm (1<<0)
239 #define NRF_DYNPD_DPL_P5_bm (1<<5)
240 #define NRF_DYNPD_DPL_P4_bm (1<<4)
241 #define NRF_DYNPD_DPL_P3_bm (1<<3)
242 #define NRF_DYNPD_DPL_P2_bm (1<<2)
243 #define NRF_DYNPD_DPL_P1_bm (1<<1)
244 #define NRF_DYNPD_DPL_P0_bm (1<<0)
245 #define NRF_DYNPD_DPL_gm (0x3F)
248 #define NRF_FEATURE_EN_DPL_bm (1<<2)
249 #define NRF_FEATURE_EN_ACK_PAY_bm (1<<1)
250 #define NRF_FEATURE_EN_DYN_ACK_bm (1<<0)
255 #define NRF_MAX_PAYLOAD_SIZE 32
256 #define NRF_MAX_CHANNEL 127
265 uint8_t
nrfWritePayload(
const void* buf, uint8_t len,
const uint8_t writeType);
281 uint8_t
nrfWrite( uint8_t* buf, uint8_t len);
286 void nrfStartWrite(
const void* buf, uint8_t len, uint8_t multicast);
287 uint8_t
nrfRead(
void* buf, uint8_t len );
288 void nrfWhatHappened(uint8_t *tx_ok, uint8_t *tx_fail, uint8_t *rx_ready);
void nrfSetAutoAck(uint8_t enable)
Enable or disable auto-acknowlede packets.
Definition: nrf24L01.c:880
Definition: nrf24L01.h:203
NRF_SETUP_AW_ARC_enum
Definition: nrf24L01.h:150
uint8_t nrfWriteRegister(uint8_t reg, uint8_t value)
Write a byte to a register.
Definition: nrf24L01.c:205
Definition: nrf24L01.h:122
Definition: nrf24L01.h:143
Definition: nrf24L01.h:208
nrf_rf_setup_rf_dr_t nrfGetDataRate(void)
Get the transmission data rate.
Definition: nrf24L01.c:1029
Definition: nrf24L01.h:138
enum NRF_STATUS_P_NO_enum NRF_STATUS_P_NO_t
NRF_CONFIG_CRC_enum
Definition: nrf24L01.h:94
Definition: nrf24L01.h:209
Definition: nrf24L01.h:191
uint8_t nrfWaitForAck(void)
Wait for acknowledge.
Definition: nrf24L01.c:467
void nrfEnableDynamicPayloads(void)
Enable dynamically-sized payloads.
Definition: nrf24L01.c:728
NRF_RF_SETUP_RF_DR_enum
Definition: nrf24L01.h:181
void nrfStartWrite(const void *buf, uint8_t len, uint8_t multicast)
Write to open writing pipe.
Definition: nrf24L01.c:498
NRF_SETUP_AW_ARD_enum
Definition: nrf24L01.h:128
Definition: nrf24L01.h:97
Definition: nrf24L01.h:156
Definition: nrf24L01.h:158
Definition: nrf24L01.h:184
Definition: nrf24L01.h:204
uint8_t nrfVerifySPIConnection(void)
Verify SPI Interface.
Definition: nrf24L01.c:1142
uint8_t pipe[5]
pipe address is "HvA01"
Definition: nrf24_test_receive.c:45
NRF_RF_SETUP_PWR_enum
Definition: nrf24L01.h:188
enum NRF_SETUP_AW_ARC_enum NRF_SETUP_AW_ARC_t
void nrfPowerDown(void)
Enter low-power mode.
Definition: nrf24L01.c:524
uint8_t nrfWrite(uint8_t *buf, uint8_t len)
Write to the open writing pipe.
Definition: nrf24L01.c:439
void nrfBegin(void)
Begin operation of NRF24L01p.
Definition: nrf24L01.c:76
Definition: nrf24L01.h:159
Definition: nrf24L01.h:167
Definition: nrf24L01.h:163
enum NRF_SETUP_AW_ARD_enum NRF_SETUP_AW_ARD_t
Definition: nrf24L01.h:96
uint8_t nrfIsPVariant(void)
Determine whether the hardware is an nRF24L01+ or not.
Definition: nrf24L01.c:866
uint8_t nrfTestCarrier(void)
Test whether there was a carrier on the line for the previous listening period.
Definition: nrf24L01.c:922
uint8_t nrfGetDynamicPayloadSize(void)
Get Dynamic Payload Size.
Definition: nrf24L01.c:789
void nrfSetPayloadSize(uint8_t size)
Definition: nrf24L01.c:846
uint8_t nrfReadPayload(void *buf, uint8_t len)
Write the receive payload.
Definition: nrf24L01.c:302
nrf_rf_setup_pwr_t nrfGetPALevel(void)
Gets the current PA level.
Definition: nrf24L01.c:977
Definition: nrf24L01.h:161
uint8_t nrfWriteRegisterMulti(uint8_t reg, const uint8_t *buf, uint8_t len)
Write multiple bytes to a register.
Definition: nrf24L01.c:182
Definition: nrf24L01.h:157
void nrfClearInterruptBits(void)
Clear Interrupt Bits.
Definition: nrf24L01.c:1126
void nrfSetRetries(uint8_t delay, uint8_t retries)
Sets the number of retries and the delay between the retries.
Definition: nrf24L01.c:1096
Definition: nrf24L01.h:155
void nrfOpen64ReadingPipe(uint8_t child, uint64_t address)
Open a pipe for reading.
Definition: nrf24L01.c:622
Definition: nrf24L01.h:133
Definition: nrf24L01.h:162
enum NRF_CONFIG_CRC_enum nrf_config_crc_t
Definition: nrf24L01.h:124
enum NRF_RF_SETUP_PWR_enum nrf_rf_setup_pwr_t
void nrfOpen64WritingPipe(uint64_t value)
Open a pipe for writing.
Definition: nrf24L01.c:604
Definition: nrf24L01.h:192
Definition: nrf24L01.h:141
uint8_t nrfRead(void *buf, uint8_t len)
Read the payload.
Definition: nrf24L01.c:336
Definition: nrf24L01.h:132
void nrfOpenWritingPipe(uint8_t *address)
Open a pipe for writing.
Definition: nrf24L01.c:658
Definition: nrf24L01.h:152
uint8_t nrfGetChannel(void)
Definition: nrf24L01.c:840
Definition: nrf24L01.h:183
void nrfSetPALevel(nrf_rf_setup_pwr_t level)
Set Power Amplifier (PA) level.
Definition: nrf24L01.c:956
void nrfOpenReadingPipe(uint8_t child, uint8_t *address)
Open a pipe for reading.
Definition: nrf24L01.c:680
#define NRF_CONFIG_EN_CRC_bm
Definition: nrf24L01.h:89
void nrfSetChannel(uint8_t channel)
Definition: nrf24L01.c:830
Definition: nrf24L01.h:139
uint8_t nrfReadRegisterMulti(uint8_t reg, uint8_t *buf, uint8_t len)
Prototypes of functions.
Definition: nrf24L01.c:136
Definition: nrf24L01.h:123
Definition: nrf24L01.h:140
Definition: nrf24L01.h:137
void nrfPowerUp(void)
Leave low-power mode - making radio more responsive.
Definition: nrf24L01.c:535
void nrfSetCRCLength(nrf_config_crc_t length)
Sets the CRC length.
Definition: nrf24L01.c:1043
Definition: nrf24L01.h:136
uint8_t nrfWritePayload(const void *buf, uint8_t len, const uint8_t writeType)
Write the transmit payload.
Definition: nrf24L01.c:233
void nrfWhatHappened(uint8_t *tx_ok, uint8_t *tx_fail, uint8_t *rx_ready)
Call this to find out which interrupt occured.
Definition: nrf24L01.c:587
Definition: nrf24L01.h:166
void nrfStartListening(void)
Start listening on the pipes opened for reading.
Definition: nrf24L01.c:386
NRF_SETUP_AW_enum
Definition: nrf24L01.h:120
uint8_t nrfGetStatus(void)
Get fixed payload size.
Definition: nrf24L01.c:818
Definition: nrf24L01.h:185
uint8_t nrfFlushTx(void)
Empty the transmit fifo.
Definition: nrf24L01.c:367
void nrfEnableAckPayload(void)
Enable custom payloads on the acknowledge packets.
Definition: nrf24L01.c:757
Definition: nrf24L01.h:190
Definition: nrf24L01.h:207
Definition: nrf24L01.h:131
uint16_t nrfGetMaxTimeout(void)
Calculate the maximum timeout in us based on current configuration.
Definition: nrf24L01.c:1112
Definition: nrf24L01.h:206
Definition: nrf24L01.h:164
Definition: nrf24L01.h:134
Definition: nrf24L01.h:135
Definition: nrf24L01.h:130
Definition: nrf24L01.h:142
NRF_STATUS_P_NO_enum
Definition: nrf24L01.h:201
Definition: nrf24L01.h:153
void nrfDisableCRC(void)
Disbale CRC.
Definition: nrf24L01.c:1073
void nrfSetAutoAckPipe(uint8_t pipe, uint8_t enable)
Enable or disable auto-acknowlede packets for a distinct pipe.
Definition: nrf24L01.c:898
Definition: nrf24L01.h:144
void nrfToggleFeatures(void)
Turn on or off the special features.
Definition: nrf24L01.c:713
Definition: nrf24L01.h:193
#define NRF_CONFIG_CRC0_bm
Definition: nrf24L01.h:90
uint8_t nrfTestRPD(void)
Test whether a signal (carrier or otherwise) greater than or equal to -64dBm is present on the channe...
Definition: nrf24L01.c:939
nrf_config_crc_t nrfGetCRCLength(void)
Get the CRC length.
Definition: nrf24L01.c:1064
uint8_t nrfAvailable(uint8_t *pipe_num)
Test whether there are bytes available to be read.
Definition: nrf24L01.c:552
uint8_t nrfFlushRx(void)
Empty the receive fifo.
Definition: nrf24L01.c:351
uint8_t nrfGetPayloadSize(void)
Get fixed payload size.
Definition: nrf24L01.c:807
void nrfStopListening(void)
Stop listening for incoming messages.
Definition: nrf24L01.c:417
uint8_t nrfSetDataRate(nrf_rf_setup_rf_dr_t speed)
Set the transmission data rate.
Definition: nrf24L01.c:997
Definition: nrf24L01.h:98
Definition: nrf24L01.h:205
Definition: nrf24L01.h:160
enum NRF_SETUP_AW_enum NRF_SETUP_AW_t
enum NRF_RF_SETUP_RF_DR_enum nrf_rf_setup_rf_dr_t
void nrfWriteAckPayload(uint8_t pipe, uint8_t *buf, uint8_t len)
Write an ack payload for the specified pipe.
Definition: nrf24L01.c:274
Definition: nrf24L01.h:165
Definition: nrf24L01.h:154
uint8_t nrfReadRegister(uint8_t reg)
Read a byte from a register.
Definition: nrf24L01.c:158
Definition: nrf24L01.h:145