nrf24L01
1.0
nrf24L01 library
|
Header file for driver for Nordic NRF24L01p with Xmega. More...
Go to the source code of this file.
Macros | |
#define | NRF_R_REGISTER 0x00 |
Definitions of commands, see table 20 datasheet. More... | |
#define | NRF_W_REGISTER 0x20 |
#define | NRF_R_RX_PAYLOAD 0x61 |
#define | NRF_W_TX_PAYLOAD 0xA0 |
#define | NRF_FLUSH_TX 0xE1 |
#define | NRF_FLUSH_RX 0xE2 |
#define | NRF_REUSE_TX_PL 0xE3 |
#define | NRF_ACTIVATE 0x50 |
#define | NRF_R_RX_PL_WID 0x60 |
#define | NRF_W_ACK_PAYLOAD 0xA8 |
#define | NRF_W_TX_PAYLOAD_NO_ACK 0xB0 |
#define | NRF_NOP 0xFF |
#define | NRF_REGISTER_gm 0x1F |
#define | NRF_PIPE_gm 0x07 |
#define | REG_CONFIG 0x00 |
Definitions of registers, see table 28 datasheet. More... | |
#define | REG_EN_AA 0x01 |
Enable Auto Acknowledgment. More... | |
#define | REG_EN_RXADDR 0x02 |
Enabled RX addresses. More... | |
#define | REG_SETUP_AW 0x03 |
Setup address width. More... | |
#define | REG_SETUP_RETR 0x04 |
Setup Auto. Retrans. More... | |
#define | REG_RF_CH 0x05 |
RF channel. More... | |
#define | REG_RF_SETUP 0x06 |
RF setup. More... | |
#define | REG_STATUS 0x07 |
Status. More... | |
#define | REG_OBSERVE_TX 0x08 |
Observe TX. More... | |
#define | REG_CD 0x09 |
Carrier Detect for nRF24L01. More... | |
#define | REG_RPD 0x09 |
Received Power Detector for nRF24L01p. More... | |
#define | REG_RX_ADDR_P0 0x0A |
RX address pipe0. More... | |
#define | REG_RX_ADDR_P1 0x0B |
RX address pipe1. More... | |
#define | REG_RX_ADDR_P2 0x0C |
RX address pipe2. More... | |
#define | REG_RX_ADDR_P3 0x0D |
RX address pipe3. More... | |
#define | REG_RX_ADDR_P4 0x0E |
RX address pipe4. More... | |
#define | REG_RX_ADDR_P5 0x0F |
RX address pipe5. More... | |
#define | REG_TX_ADDR 0x10 |
TX address. More... | |
#define | REG_RX_PW_P0 0x11 |
RX payload width pipe0. More... | |
#define | REG_RX_PW_P1 0x12 |
RX payload width pipe1. More... | |
#define | REG_RX_PW_P2 0x13 |
RX payload width pipe2. More... | |
#define | REG_RX_PW_P3 0x14 |
RX payload width pipe3. More... | |
#define | REG_RX_PW_P4 0x15 |
RX payload width pipe4. More... | |
#define | REG_RX_PW_P5 0x16 |
RX payload width pipe5. More... | |
#define | REG_FIFO_STATUS 0x17 |
FIFO Status Register. More... | |
#define | REG_DYNPD 0x1C |
Dynamic payload length. More... | |
#define | REG_FEATURE 0x1D |
Feature register. More... | |
#define | NRF_CONFIG_MASK_RX_DR_bm (1<<6) |
#define | NRF_CONFIG_MASK_TX_DS_bm (1<<5) |
#define | NRF_CONFIG_MASK_MAX_RT_bm (1<<4) |
#define | NRF_CONFIG_EN_CRC_bm (1<<3) |
#define | NRF_CONFIG_CRC0_bm (1<<2) |
#define | NRF_CONFIG_PWR_UP_bm (1<<1) |
#define | NRF_CONFIG_PRIM_RX_bm (1<<0) |
#define | NRF_CONFIG_CRC_gm ( NRF_CONFIG_EN_CRC_bm | NRF_CONFIG_CRC0_bm ) |
#define | NRF_EN_AA_P5_bm (1<<5) |
#define | NRF_EN_AA_P4_bm (1<<4) |
#define | NRF_EN_AA_P3_bm (1<<3) |
#define | NRF_EN_AA_P2_bm (1<<2) |
#define | NRF_EN_AA_P1_bm (1<<1) |
#define | NRF_EN_AA_P0_bm (1<<0) |
#define | NRF_EN_AA_P_ALL_gm (0x3F) |
#define | NRF_EN_RXADDR_P5_bm (1<<5) |
#define | NRF_EN_RXADDR_P4_bm (1<<4) |
#define | NRF_EN_RXADDR_P3_bm (1<<3) |
#define | NRF_EN_RXADDR_P2_bm (1<<2) |
#define | NRF_EN_RXADDR_P1_bm (1<<1) |
#define | NRF_EN_RXADDR_P0_bm (1<<0) |
#define | NRF_SETUP_ARD_gm (0xF0) |
#define | NRF_SETUP_ARD_gp 4 |
#define | NRF_SETUP_ARC_gm (0x0F) |
#define | NRF_SETUP_ARC_gp 0 |
#define | NRF_RF_CH_gm 0x7F |
#define | NRF_RF_CH_max 0x7F |
#define | NRF_RF_SETUP_CONT_WAVE_bm (1<<7) |
#define | NRF_RF_SETUP_RF_DR_LOW_bm (1<<5) |
#define | NRF_RF_SETUP_PLL_LOCK_bm (1<<4) |
#define | NRF_RF_SETUP_RF_DR_HIGH_bm (1<<3) |
#define | NRF_RF_SETUP_RF_DR_gm ((1<<5)|(1<<3)) |
#define | NRF_RF_SETUP_PWR_gm (0x06) |
#define | NRF_STATUS_RX_DR_bm (1<<6) |
#define | NRF_STATUS_TX_DS_bm (1<<5) |
#define | NRF_STATUS_MAX_RT_bm (1<<4) |
#define | NRF_STATUS_RX_P_NO_gp 1 |
#define | NRF_STATUS_RX_P_NO_gm (0x0E) |
#define | NRF_STATUS_TX_FULL_bm (1<<0) |
#define | NRF_OBSERVE_TX_PLOS_CNT_gm 0xF0 |
#define | NRF_OBSERVE_TX_ARC_CNT_gm 0x0F |
#define | NRF_RPD_RPD_bm (1<<0) |
#define | NRF_CD_CD_bm (1<<0) |
#define | NRF_RX_PW_P0_gm (0x3F) |
#define | NRF_RX_PW_P1_gm (0x3F) |
#define | NRF_RX_PW_P2_gm (0x3F) |
#define | NRF_RX_PW_P3_gm (0x3F) |
#define | NRF_RX_PW_P4_gm (0x3F) |
#define | NRF_RX_PW_P5_gm (0x3F) |
#define | NRF_FIFO_STATUS_TX_REUSE_bm (1<<6) |
#define | NRF_FIFO_STATUS_TX_FULL_bm (1<<5) |
#define | NRF_FIFO_STATUS_TX_EMPTY_bm (1<<4) |
#define | NRF_FIFO_STATUS_RX_FULL_bm (1<<1) |
#define | NRF_FIFO_STATUS_RX_EMPTY_bm (1<<0) |
#define | NRF_DYNPD_DPL_P5_bm (1<<5) |
#define | NRF_DYNPD_DPL_P4_bm (1<<4) |
#define | NRF_DYNPD_DPL_P3_bm (1<<3) |
#define | NRF_DYNPD_DPL_P2_bm (1<<2) |
#define | NRF_DYNPD_DPL_P1_bm (1<<1) |
#define | NRF_DYNPD_DPL_P0_bm (1<<0) |
#define | NRF_DYNPD_DPL_gm (0x3F) |
#define | NRF_FEATURE_EN_DPL_bm (1<<2) |
#define | NRF_FEATURE_EN_ACK_PAY_bm (1<<1) |
#define | NRF_FEATURE_EN_DYN_ACK_bm (1<<0) |
#define | NRF_MAX_PAYLOAD_SIZE 32 |
Some parameters of the NRF24L01p. More... | |
#define | NRF_MAX_CHANNEL 127 |
Typedefs | |
typedef enum NRF_CONFIG_CRC_enum | nrf_config_crc_t |
typedef enum NRF_SETUP_AW_enum | NRF_SETUP_AW_t |
typedef enum NRF_SETUP_AW_ARD_enum | NRF_SETUP_AW_ARD_t |
typedef enum NRF_SETUP_AW_ARC_enum | NRF_SETUP_AW_ARC_t |
typedef enum NRF_RF_SETUP_RF_DR_enum | nrf_rf_setup_rf_dr_t |
typedef enum NRF_RF_SETUP_PWR_enum | nrf_rf_setup_pwr_t |
typedef enum NRF_STATUS_P_NO_enum | NRF_STATUS_P_NO_t |
Functions | |
uint8_t | nrfReadRegisterMulti (uint8_t reg, uint8_t *buf, uint8_t len) |
Prototypes of functions. More... | |
uint8_t | nrfReadRegister (uint8_t reg) |
Read a byte from a register. More... | |
uint8_t | nrfWriteRegisterMulti (uint8_t reg, const uint8_t *buf, uint8_t len) |
Write multiple bytes to a register. More... | |
uint8_t | nrfWriteRegister (uint8_t reg, uint8_t value) |
Write a byte to a register. More... | |
uint8_t | nrfWritePayload (const void *buf, uint8_t len, const uint8_t writeType) |
Write the transmit payload. More... | |
uint8_t | nrfReadPayload (void *buf, uint8_t len) |
Write the receive payload. More... | |
uint8_t | nrfFlushRx (void) |
Empty the receive fifo. More... | |
uint8_t | nrfFlushTx (void) |
Empty the transmit fifo. More... | |
void | nrfToggleFeatures (void) |
Turn on or off the special features. More... | |
void | nrfBegin (void) |
Begin operation of NRF24L01p. More... | |
void | nrfStartListening (void) |
Start listening on the pipes opened for reading. More... | |
void | nrfStopListening (void) |
Stop listening for incoming messages. More... | |
uint8_t | nrfGetStatus (void) |
Get fixed payload size. More... | |
void | nrfSetChannel (uint8_t channel) |
uint8_t | nrfGetChannel (void) |
void | nrfSetPayloadSize (uint8_t size) |
uint8_t | nrfGetPayloadSize (void) |
Get fixed payload size. More... | |
void | nrfPowerDown (void) |
Enter low-power mode. More... | |
void | nrfPowerUp (void) |
Leave low-power mode - making radio more responsive. More... | |
uint8_t | nrfWrite (uint8_t *buf, uint8_t len) |
Write to the open writing pipe. More... | |
uint8_t | nrfWaitForAck (void) |
Wait for acknowledge. More... | |
uint8_t | nrfAvailable (uint8_t *pipe_num) |
Test whether there are bytes available to be read. More... | |
uint8_t | nrfGetDynamicPayloadSize (void) |
Get Dynamic Payload Size. More... | |
void | nrfWriteAckPayload (uint8_t pipe, uint8_t *buf, uint8_t len) |
Write an ack payload for the specified pipe. More... | |
void | nrfStartWrite (const void *buf, uint8_t len, uint8_t multicast) |
Write to open writing pipe. More... | |
uint8_t | nrfRead (void *buf, uint8_t len) |
Read the payload. More... | |
void | nrfWhatHappened (uint8_t *tx_ok, uint8_t *tx_fail, uint8_t *rx_ready) |
Call this to find out which interrupt occured. More... | |
void | nrfOpen64WritingPipe (uint64_t value) |
Open a pipe for writing. More... | |
void | nrfOpenWritingPipe (uint8_t *address) |
Open a pipe for writing. More... | |
void | nrfOpen64ReadingPipe (uint8_t child, uint64_t address) |
Open a pipe for reading. More... | |
void | nrfOpenReadingPipe (uint8_t child, uint8_t *address) |
Open a pipe for reading. More... | |
void | nrfEnableDynamicPayloads (void) |
Enable dynamically-sized payloads. More... | |
void | nrfEnableAckPayload (void) |
Enable custom payloads on the acknowledge packets. More... | |
uint8_t | nrfIsPVariant (void) |
Determine whether the hardware is an nRF24L01+ or not. More... | |
void | nrfSetAutoAck (uint8_t enable) |
Enable or disable auto-acknowlede packets. More... | |
void | nrfSetAutoAckPipe (uint8_t pipe, uint8_t enable) |
Enable or disable auto-acknowlede packets for a distinct pipe. More... | |
uint8_t | nrfTestCarrier (void) |
Test whether there was a carrier on the line for the previous listening period. More... | |
uint8_t | nrfTestRPD (void) |
Test whether a signal (carrier or otherwise) greater than or equal to -64dBm is present on the channel. More... | |
void | nrfSetPALevel (nrf_rf_setup_pwr_t level) |
Set Power Amplifier (PA) level. More... | |
nrf_rf_setup_pwr_t | nrfGetPALevel (void) |
Gets the current PA level. More... | |
uint8_t | nrfSetDataRate (nrf_rf_setup_rf_dr_t speed) |
Set the transmission data rate. More... | |
nrf_rf_setup_rf_dr_t | nrfGetDataRate (void) |
Get the transmission data rate. More... | |
void | nrfSetCRCLength (nrf_config_crc_t length) |
Sets the CRC length. More... | |
nrf_config_crc_t | nrfGetCRCLength (void) |
Get the CRC length. More... | |
void | nrfDisableCRC (void) |
Disbale CRC. More... | |
void | nrfSetRetries (uint8_t delay, uint8_t retries) |
Sets the number of retries and the delay between the retries. More... | |
uint16_t | nrfGetMaxTimeout (void) |
Calculate the maximum timeout in us based on current configuration. More... | |
void | nrfClearInterruptBits (void) |
Clear Interrupt Bits. More... | |
uint8_t | nrfVerifySPIConnection (void) |
Verify SPI Interface. More... | |
Header file for driver for Nordic NRF24L01p with Xmega.
This file contains he definitions and prototypes for interfacing interfacing a Nordic NRF24L01+ and a Xmega. The accompanying files nrf24spiXM2.c and nrf24spiXM2.h comtains the driverroutines for the HvA Xmegaboard version 2.
This driver is based on:
Other references:
#define NRF_ACTIVATE 0x50 |
#define NRF_CD_CD_bm (1<<0) |
#define NRF_CONFIG_CRC0_bm (1<<2) |
#define NRF_CONFIG_CRC_gm ( NRF_CONFIG_EN_CRC_bm | NRF_CONFIG_CRC0_bm ) |
#define NRF_CONFIG_EN_CRC_bm (1<<3) |
#define NRF_CONFIG_MASK_MAX_RT_bm (1<<4) |
#define NRF_CONFIG_MASK_RX_DR_bm (1<<6) |
#define NRF_CONFIG_MASK_TX_DS_bm (1<<5) |
#define NRF_CONFIG_PRIM_RX_bm (1<<0) |
#define NRF_CONFIG_PWR_UP_bm (1<<1) |
#define NRF_DYNPD_DPL_gm (0x3F) |
#define NRF_DYNPD_DPL_P0_bm (1<<0) |
#define NRF_DYNPD_DPL_P1_bm (1<<1) |
#define NRF_DYNPD_DPL_P2_bm (1<<2) |
#define NRF_DYNPD_DPL_P3_bm (1<<3) |
#define NRF_DYNPD_DPL_P4_bm (1<<4) |
#define NRF_DYNPD_DPL_P5_bm (1<<5) |
#define NRF_EN_AA_P0_bm (1<<0) |
#define NRF_EN_AA_P1_bm (1<<1) |
#define NRF_EN_AA_P2_bm (1<<2) |
#define NRF_EN_AA_P3_bm (1<<3) |
#define NRF_EN_AA_P4_bm (1<<4) |
#define NRF_EN_AA_P5_bm (1<<5) |
#define NRF_EN_AA_P_ALL_gm (0x3F) |
#define NRF_EN_RXADDR_P0_bm (1<<0) |
#define NRF_EN_RXADDR_P1_bm (1<<1) |
#define NRF_EN_RXADDR_P2_bm (1<<2) |
#define NRF_EN_RXADDR_P3_bm (1<<3) |
#define NRF_EN_RXADDR_P4_bm (1<<4) |
#define NRF_EN_RXADDR_P5_bm (1<<5) |
#define NRF_FEATURE_EN_ACK_PAY_bm (1<<1) |
#define NRF_FEATURE_EN_DPL_bm (1<<2) |
#define NRF_FEATURE_EN_DYN_ACK_bm (1<<0) |
#define NRF_FIFO_STATUS_RX_EMPTY_bm (1<<0) |
#define NRF_FIFO_STATUS_RX_FULL_bm (1<<1) |
#define NRF_FIFO_STATUS_TX_EMPTY_bm (1<<4) |
#define NRF_FIFO_STATUS_TX_FULL_bm (1<<5) |
#define NRF_FIFO_STATUS_TX_REUSE_bm (1<<6) |
#define NRF_FLUSH_RX 0xE2 |
#define NRF_FLUSH_TX 0xE1 |
#define NRF_MAX_CHANNEL 127 |
#define NRF_MAX_PAYLOAD_SIZE 32 |
Some parameters of the NRF24L01p.
#define NRF_NOP 0xFF |
#define NRF_OBSERVE_TX_ARC_CNT_gm 0x0F |
#define NRF_OBSERVE_TX_PLOS_CNT_gm 0xF0 |
#define NRF_PIPE_gm 0x07 |
#define NRF_R_REGISTER 0x00 |
Definitions of commands, see table 20 datasheet.
#define NRF_R_RX_PAYLOAD 0x61 |
#define NRF_R_RX_PL_WID 0x60 |
#define NRF_REGISTER_gm 0x1F |
#define NRF_REUSE_TX_PL 0xE3 |
#define NRF_RF_CH_gm 0x7F |
#define NRF_RF_CH_max 0x7F |
#define NRF_RF_SETUP_CONT_WAVE_bm (1<<7) |
#define NRF_RF_SETUP_PLL_LOCK_bm (1<<4) |
#define NRF_RF_SETUP_PWR_gm (0x06) |
#define NRF_RF_SETUP_RF_DR_gm ((1<<5)|(1<<3)) |
#define NRF_RF_SETUP_RF_DR_HIGH_bm (1<<3) |
#define NRF_RF_SETUP_RF_DR_LOW_bm (1<<5) |
#define NRF_RPD_RPD_bm (1<<0) |
#define NRF_RX_PW_P0_gm (0x3F) |
#define NRF_RX_PW_P1_gm (0x3F) |
#define NRF_RX_PW_P2_gm (0x3F) |
#define NRF_RX_PW_P3_gm (0x3F) |
#define NRF_RX_PW_P4_gm (0x3F) |
#define NRF_RX_PW_P5_gm (0x3F) |
#define NRF_SETUP_ARC_gm (0x0F) |
#define NRF_SETUP_ARC_gp 0 |
#define NRF_SETUP_ARD_gm (0xF0) |
#define NRF_SETUP_ARD_gp 4 |
#define NRF_STATUS_MAX_RT_bm (1<<4) |
#define NRF_STATUS_RX_DR_bm (1<<6) |
#define NRF_STATUS_RX_P_NO_gm (0x0E) |
#define NRF_STATUS_RX_P_NO_gp 1 |
#define NRF_STATUS_TX_DS_bm (1<<5) |
#define NRF_STATUS_TX_FULL_bm (1<<0) |
#define NRF_W_ACK_PAYLOAD 0xA8 |
#define NRF_W_REGISTER 0x20 |
#define NRF_W_TX_PAYLOAD 0xA0 |
#define NRF_W_TX_PAYLOAD_NO_ACK 0xB0 |
#define REG_CD 0x09 |
Carrier Detect for nRF24L01.
#define REG_CONFIG 0x00 |
Definitions of registers, see table 28 datasheet.
Config
#define REG_DYNPD 0x1C |
Dynamic payload length.
#define REG_EN_AA 0x01 |
Enable Auto Acknowledgment.
#define REG_EN_RXADDR 0x02 |
Enabled RX addresses.
#define REG_FEATURE 0x1D |
Feature register.
#define REG_FIFO_STATUS 0x17 |
FIFO Status Register.
#define REG_OBSERVE_TX 0x08 |
Observe TX.
#define REG_RF_CH 0x05 |
RF channel.
#define REG_RF_SETUP 0x06 |
RF setup.
#define REG_RPD 0x09 |
Received Power Detector for nRF24L01p.
#define REG_RX_ADDR_P0 0x0A |
RX address pipe0.
#define REG_RX_ADDR_P1 0x0B |
RX address pipe1.
#define REG_RX_ADDR_P2 0x0C |
RX address pipe2.
#define REG_RX_ADDR_P3 0x0D |
RX address pipe3.
#define REG_RX_ADDR_P4 0x0E |
RX address pipe4.
#define REG_RX_ADDR_P5 0x0F |
RX address pipe5.
#define REG_RX_PW_P0 0x11 |
RX payload width pipe0.
#define REG_RX_PW_P1 0x12 |
RX payload width pipe1.
#define REG_RX_PW_P2 0x13 |
RX payload width pipe2.
#define REG_RX_PW_P3 0x14 |
RX payload width pipe3.
#define REG_RX_PW_P4 0x15 |
RX payload width pipe4.
#define REG_RX_PW_P5 0x16 |
RX payload width pipe5.
#define REG_SETUP_AW 0x03 |
Setup address width.
#define REG_SETUP_RETR 0x04 |
Setup Auto. Retrans.
#define REG_STATUS 0x07 |
Status.
#define REG_TX_ADDR 0x10 |
TX address.
typedef enum NRF_CONFIG_CRC_enum nrf_config_crc_t |
typedef enum NRF_RF_SETUP_PWR_enum nrf_rf_setup_pwr_t |
typedef enum NRF_RF_SETUP_RF_DR_enum nrf_rf_setup_rf_dr_t |
typedef enum NRF_SETUP_AW_ARC_enum NRF_SETUP_AW_ARC_t |
typedef enum NRF_SETUP_AW_ARD_enum NRF_SETUP_AW_ARD_t |
typedef enum NRF_SETUP_AW_enum NRF_SETUP_AW_t |
typedef enum NRF_STATUS_P_NO_enum NRF_STATUS_P_NO_t |
enum NRF_CONFIG_CRC_enum |
enum NRF_SETUP_AW_enum |
enum NRF_STATUS_P_NO_enum |
uint8_t nrfAvailable | ( | uint8_t * | pipe_num | ) |
Test whether there are bytes available to be read.
Call nrfAvaliable(NULL) if you're not interested in the pipe number Call nrfAvaliable(&pipe) puts the pipenumber in pipe
[out] | pipe_num | Pointer to pipenumber, where it writes the pipenumber with a payload that is available |
void nrfBegin | ( | void | ) |
Begin operation of NRF24L01p.
This function is used at the inilialzation of NRF24L01p.
void nrfClearInterruptBits | ( | void | ) |
Clear Interrupt Bits.
void nrfDisableCRC | ( | void | ) |
Disbale CRC.
void nrfEnableAckPayload | ( | void | ) |
Enable custom payloads on the acknowledge packets.
Ack payloads are a handy way to return data back to senders without manually changing the radio modes on both units.
void nrfEnableDynamicPayloads | ( | void | ) |
Enable dynamically-sized payloads.
This way you don't always have to send large packets. It enables dynamic payloads on ALL pipes.
uint8_t nrfFlushRx | ( | void | ) |
Empty the receive fifo.
uint8_t nrfFlushTx | ( | void | ) |
Empty the transmit fifo.
uint8_t nrfGetChannel | ( | void | ) |
nrf_config_crc_t nrfGetCRCLength | ( | void | ) |
Get the CRC length.
The CRC correspond to the following lengths respectively:
nrf_rf_setup_rf_dr_t nrfGetDataRate | ( | void | ) |
Get the transmission data rate.
The data rates correspond to the following speeds respectively:
uint8_t nrfGetDynamicPayloadSize | ( | void | ) |
Get Dynamic Payload Size.
For dynamic payloads, this returns the size of the payload
uint16_t nrfGetMaxTimeout | ( | void | ) |
Calculate the maximum timeout in us based on current configuration.
This depends on the number of retries en the delays betweeen them. The maximum timeout is delay * (retries+1) us. It is a value between 250 us and 64000 us.
nrf_rf_setup_pwr_t nrfGetPALevel | ( | void | ) |
Gets the current PA level.
The power levels correspond to the following output levels respectively:
NRF_RF_SETUP_PWR_18DBM_gc
NRF_RF_SETUP_PWR_12DBM_gc
NRF_RF_SETUP_PWR_6DBM_gc
NRF_RF_SETUP_PWR_0DBM_gc
uint8_t nrfGetPayloadSize | ( | void | ) |
Get fixed payload size.
uint8_t nrfGetStatus | ( | void | ) |
Get fixed payload size.
uint8_t nrfIsPVariant | ( | void | ) |
Determine whether the hardware is an nRF24L01+ or not.
void nrfOpen64ReadingPipe | ( | uint8_t | child, |
uint64_t | address | ||
) |
void nrfOpen64WritingPipe | ( | uint64_t | value | ) |
void nrfOpenReadingPipe | ( | uint8_t | child, |
uint8_t * | address | ||
) |
Open a pipe for reading.
Up to 6 pipes can be open for reading at once. Open all the required reading pipes, and then call startListening().
child | Pipe number (0-5) to read from. |
address | Pointer to address of the pipe to open. |
void nrfOpenWritingPipe | ( | uint8_t * | address | ) |
Open a pipe for writing.
The address is a pointer to byte array with 3-5 bytes. Only one writing pipe can be open at once, but you can change the address you'll write to.
address | Pointer to address of the pipe to open. |
void nrfPowerDown | ( | void | ) |
Enter low-power mode.
To return to normal power mode, either nrfWrite() some data or nrfStartListening(), or nrfPowerUp().
void nrfPowerUp | ( | void | ) |
Leave low-power mode - making radio more responsive.
To return to low power mode, call nrfPowerDown().
uint8_t nrfRead | ( | void * | buf, |
uint8_t | len | ||
) |
Read the payload.
Get the last payload received
buf | Buffer where the data should be written to |
len | Maximum number of bytes to read into the buffer |
uint8_t nrfReadPayload | ( | void * | buf, |
uint8_t | len | ||
) |
Write the receive payload.
The size of data written is the fixed payload size, see getPayloadSize()
buf | Buffer to write the data to |
len | Maximum number of bytes to receive |
uint8_t nrfReadRegister | ( | uint8_t | reg | ) |
Read a byte from a register.
reg | Register address, see also tabel 28 of datasheet |
reg
uint8_t nrfReadRegisterMulti | ( | uint8_t | reg, |
uint8_t * | buf, | ||
uint8_t | len | ||
) |
Prototypes of functions.
Prototypes of functions.
reg | Register address, see also tabel 28 of datasheet |
buf | Pointer to buffer to put data in |
len | Number of bytes to be received |
void nrfSetAutoAck | ( | uint8_t | enable | ) |
Enable or disable auto-acknowlede packets.
Auto acknowledge is enabled by default, so it's only needed if you want to turn it off for some reason.
enable | Whether to enable (true, non 0) or disable (false, 0). |
void nrfSetAutoAckPipe | ( | uint8_t | pipe, |
uint8_t | enable | ||
) |
Enable or disable auto-acknowlede packets for a distinct pipe.
Auto acknowledge is enabled by default, so it's only needed if you want to turn it off for some reason.
pipe | Pipe number which you want to enable or disable |
enable | Whether to enable (true, non 0) or disable (false, 0). |
void nrfSetChannel | ( | uint8_t | channel | ) |
void nrfSetCRCLength | ( | nrf_config_crc_t | length | ) |
Sets the CRC length.
The CRC correspond to the following lengths respectively:
uint8_t nrfSetDataRate | ( | nrf_rf_setup_rf_dr_t | speed | ) |
Set the transmission data rate.
The data rates correspond to the following speeds respectively:
speed | (is one of the group configurations) |
void nrfSetPALevel | ( | nrf_rf_setup_pwr_t | level | ) |
Set Power Amplifier (PA) level.
The power levels correspond to the following output levels respectively:
NRF_RF_SETUP_PWR_18DBM_gc
NRF_RF_SETUP_PWR_12DBM_gc
NRF_RF_SETUP_PWR_6DBM_gc
NRF_RF_SETUP_PWR_0DBM_gc
level | Desired level (is one of the group configurations) |
void nrfSetPayloadSize | ( | uint8_t | size | ) |
void nrfSetRetries | ( | uint8_t | delay, |
uint8_t | retries | ||
) |
Sets the number of retries and the delay between the retries.
The number of retries is 0 to 15 The delay between the retries is 250 us to 4000 us with with a 250 us step size.
The groupsconfiguration for the retries is NRF_SETUP_ARC_::RETRANSMIT_gc where # is NO or 1 to 15.
The groupsconfiguration for the delays is NRF_SETUP_ARD_::US_gc where # is 250 to 4000 with a 250 step size.
delay | (groupsconfiguration NRF_SETUP_ARD_::US_gc for delay #) |
retries | (groupsconfiguration NRF_SETUP_ARC_::RETRANSMIT_gc for retries #) |
void nrfStartListening | ( | void | ) |
Start listening on the pipes opened for reading.
Be sure to call openReadingPipe() first. Do not call write() while in this mode, without first calling stopListening(). Call isAvailable() to check for incoming traffic, and read() to get it.
void nrfStartWrite | ( | const void * | buf, |
uint8_t | len, | ||
uint8_t | multicast | ||
) |
Write to open writing pipe.
Same as write() but doesn't wait for acknowledge
buf | Pointer to the data to be sent |
len | Number of bytes to be sent |
multicast | ?? NRF_W_TX_PAYLOAD or NRF_W_TX_PAYLOAD_NO_ACK. |
void nrfStopListening | ( | void | ) |
Stop listening for incoming messages.
Do this before calling write().
uint8_t nrfTestCarrier | ( | void | ) |
Test whether there was a carrier on the line for the previous listening period.
Valid only on nRF24L01. On nRF24L01, use nrfTestRPD().
uint8_t nrfTestRPD | ( | void | ) |
Test whether a signal (carrier or otherwise) greater than or equal to -64dBm is present on the channel.
Valid only on nRF24L01+(p). On nRF24L01, use nrfTestCarrier(). Useful to check for interference on the current channel and channel hopping strategies.
void nrfToggleFeatures | ( | void | ) |
Turn on or off the special features.
The nrf2401(+) has certain 'features' which are only available when the 'features' are enabled.
uint8_t nrfVerifySPIConnection | ( | void | ) |
Verify SPI Interface.
It sends and reads back a random value to the SETUP register It restores the original setup
uint8_t nrfWaitForAck | ( | void | ) |
Wait for acknowledge.
It waits for interrupt on TX complete, maximum retransmits reached or timer expired. The time depends on the number of retries and delay time. This time calculated with nrfGetMaxTimeout();
only write with an acknowledge is implemented
void nrfWhatHappened | ( | uint8_t * | tx_ok, |
uint8_t * | tx_fail, | ||
uint8_t * | rx_ready | ||
) |
Call this to find out which interrupt occured.
Tells you what caused the interrupt, and clears the state of interrupts. The retuend values are not equal to 0 if the interrupt occured.
[out] | tx_ok | The send was successful (TX_DS) |
[out] | tx_fail | The send failed, too many retries (MAX_RT) |
[out] | rx_ready | There is a message waiting to be read (RX_DR) |
uint8_t nrfWrite | ( | uint8_t * | buf, |
uint8_t | len | ||
) |
Write to the open writing pipe.
Be sure to call openWritingPipe() first to set the destination of where to write to.
only write with an acknowledge is implemented
buf | Pointer to the data to be sent |
len | Number of bytes to be sent |
void nrfWriteAckPayload | ( | uint8_t | pipe, |
uint8_t * | buf, | ||
uint8_t | len | ||
) |
Write an ack payload for the specified pipe.
The next time a message is received on pipe
, the data in buf
will be sent back in the acknowledgement.
pipe | Pipe number |
buf | Buffer to get the data from |
len | Number of bytes to be written |
uint8_t nrfWritePayload | ( | const void * | buf, |
uint8_t | len, | ||
const uint8_t | writeType | ||
) |
Write the transmit payload.
The size of data written has a fixed payload size or a dynamic payload size. It uses the command W_TX_PAYLOAD (fixed size) or W_TX_PAYLOAD_NO_ACK (dynamic size).
buf | Buffer to get the data from |
len | Number of bytes to be written |
writeType | W_TX_PAYLOAD: fixed data size W_TX_PAYLOAD_NO_ACK: variable data size (multicast) |
uint8_t nrfWriteRegister | ( | uint8_t | reg, |
uint8_t | value | ||
) |
Write a byte to a register.
reg | Register address, see also tabel 28 of datasheet |
value | The new value of the register |
uint8_t nrfWriteRegisterMulti | ( | uint8_t | reg, |
const uint8_t * | buf, | ||
uint8_t | len | ||
) |
Write multiple bytes to a register.
reg | Register address, see also tabel 28 of datasheet |
buf | Pointer to buffer with data to be sent |
len | Number of bytes to be sent |
This function is used at the inilialzation of NRF24L01p.