embedded-software
reusable software modules for embedded systems
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nRF24L01+ Module

Data Structures

struct  nrf24_radio_t
 

Macros

#define nRF24_ISR(nrf_object)   Task_Queue( (task_t)nRF24_EventHandler, nrf_object)
 

Typedefs

typedef struct nrf24_radio_t nrf24_t
 

Enumerations

enum  nrf24_pa_level_e { NRF24_PA_LOW = 0, NRF24_PA_MID, NRF24_PA_HIGH, NRF24_PA_MAX }
 
enum  nrf24_datarate_e { NRF24_250KBPS = 0, NRF24_1MBPS, NRF24_2MBPS }
 
enum  nrf24_crc_mode_e { NRF24_NO_CRC = 0, NRF24_CRC_8BIT, NRF24_CRC_16BIT }
 

Functions

void nRF24_Init (nrf24_t *nrf_object)
 
void nRF24_OpenRxPipe (nrf24_t *nrf_object, uint8_t pipenum, uint64_t address)
 
void nRF24_OpenTxPipe (nrf24_t *nrf_object, uint64_t address)
 
void nRF24_EventHandler (nrf24_t *nrf_object)
 
void nRF24_StartListening (nrf24_t *nrf_object)
 
void nRF24_Standby (nrf24_t *nrf_object)
 
void nRF24_WriteReg (nrf24_t *nrf_object, uint8_t reg_address, uint8_t value)
 
void nRF24_WriteMultReg (nrf24_t *nrf_object, uint8_t reg_address, uint8_t *data_ptr, uint8_t length)
 
uint8_t nRF24_ReadReg (nrf24_t *nrf_object, uint8_t reg_address)
 
uint8_t nRF24_GetPayloadLength (nrf24_t *nrf_object)
 
void nRF24_Write (nrf24_t *nrf_object, uint8_t *buf, uint8_t length)
 
void nRF24_Read (nrf24_t *nrf_object, uint8_t *buf, uint8_t length)
 
void nRF24_WriteAck (nrf24_t *nrf_object, uint8_t *buf, uint8_t length, uint8_t pipe)
 
void nRF24_SetPowerAmplificationLevel (nrf24_t *nrf_object, nrf24_pa_level_e level)
 
void nRF24_SetDataRate (nrf24_t *nrf_object, nrf24_datarate_e rate)
 
void nRF24_SetCRCMode (nrf24_t *nrf_object, nrf24_crc_mode_e mode)
 
void nRF24_SetChannel (nrf24_t *nrf_object, uint8_t channel)
 
void nRF24_SetActive (nrf24_t *nrf_object, uint8_t active)
 
void nRF24_SetRetries (nrf24_t *nrf_object, uint8_t delay, uint8_t count)
 
void nRF24_FlushRx (nrf24_t *nrf_object)
 
void nRF24_FlushTx (nrf24_t *nrf_object)
 

Detailed Description

This module provides an interface with the nRF24L01+ built on the SPI module.

Macro Definition Documentation

#define nRF24_ISR (   nrf_object)    Task_Queue( (task_t)nRF24_EventHandler, nrf_object)

Typedef Documentation

typedef struct nrf24_radio_t nrf24_t

TODO: Make this library work with big endian devices

Enumeration Type Documentation

Enumerator
NRF24_NO_CRC 
NRF24_CRC_8BIT 
NRF24_CRC_16BIT 
Enumerator
NRF24_250KBPS 
NRF24_1MBPS 
NRF24_2MBPS 
Enumerator
NRF24_PA_LOW 
NRF24_PA_MID 
NRF24_PA_HIGH 
NRF24_PA_MAX 

Function Documentation

void nRF24_EventHandler ( nrf24_t nrf_object)

Use nRF24_ISR() in the interrupt service routine that detects high to low changes for the IRQ pin.

Here is the call graph for this function:

void nRF24_FlushRx ( nrf24_t nrf_object)

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_FlushTx ( nrf24_t nrf_object)

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t nRF24_GetPayloadLength ( nrf24_t nrf_object)

Get the length of the payload received

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_Init ( nrf24_t nrf_object)

Initialize nRF24L01+ module with default settings

SPI channel should already be initialized before calling nRF24_Init().

Default Settings:

  • Max Retries 15
  • Power Amplification Max
  • Data Rate 2Mbps
  • 16-bit CRC
  • Channel 76
  • Dynamic Payload Length Feature
  • Ack Payload Feature
  • Dynamic Ack Payload Feature (allow empty acks)
  • Auto Ack Enabled on All Pipes
  • Dynamic Payload Enabled for All Pipes
  • 5-byte Address Width

Example Usage:

nrf24_t RF1; // make sure this isn't on the stack
//...
RF1.ce = RF1_CE; // where RF1_CE is a function to set ChipEnable
RF1.csn = RF1_CSN; // where RF1_CSN is a function to set ~ChipSelect
RF1.spi_channel = 2;
nRF24_Init(&RF1);
Parameters
nrf_objectPointer to nfr24_t object.

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_OpenRxPipe ( nrf24_t nrf_object,
uint8_t  pipenum,
uint64_t  address 
)

Open a RX pipe for a specific address

Note: for pipes 2-5 only the LSB of the address is used

Parameters
nrf_objectPointer to nfr24_t object.
pipenumPipe index to use (0-5)
addressaddress to receive from

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_OpenTxPipe ( nrf24_t nrf_object,
uint64_t  address 
)

Open a TX pipe for a specific address

Parameters
nrf_objectPointer to nfr24_t object.
addressaddress to transmit on

TODO: We may need to add this back in. I am unsure how using dynamic payload effects the use of the payload length registers

nRF24_WriteReg(nrf_object, RX_PW_P0, min(payload_size,max_payload_size));

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_Read ( nrf24_t nrf_object,
uint8_t *  buf,
uint8_t  length 
)

Read the received message

uint8_t nRF24_ReadReg ( nrf24_t nrf_object,
uint8_t  reg_address 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_SetActive ( nrf24_t nrf_object,
uint8_t  active 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_SetChannel ( nrf24_t nrf_object,
uint8_t  channel 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_SetCRCMode ( nrf24_t nrf_object,
nrf24_crc_mode_e  mode 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_SetDataRate ( nrf24_t nrf_object,
nrf24_datarate_e  rate 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_SetPowerAmplificationLevel ( nrf24_t nrf_object,
nrf24_pa_level_e  level 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_SetRetries ( nrf24_t nrf_object,
uint8_t  delay,
uint8_t  count 
)
Parameters
delaydelay before retransmit attempt, actual delay = 250us + delay*250us where delay is from 0-15
countretransmit count before triggering max retries interrupt, 0-15 where 0 is no retries and 15 is 15 retries

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_Standby ( nrf24_t nrf_object)

Disable the nRF24 chip and standby

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_StartListening ( nrf24_t nrf_object)

Start listening on primary RX node

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_Write ( nrf24_t nrf_object,
uint8_t *  buf,
uint8_t  length 
)

Send a message from a primary TX node

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_WriteAck ( nrf24_t nrf_object,
uint8_t *  buf,
uint8_t  length,
uint8_t  pipe 
)

Send a message in an ack response payload from a primary RX node

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_WriteMultReg ( nrf24_t nrf_object,
uint8_t  reg_address,
uint8_t *  data_ptr,
uint8_t  length 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void nRF24_WriteReg ( nrf24_t nrf_object,
uint8_t  reg_address,
uint8_t  value 
)

Here is the call graph for this function:

Here is the caller graph for this function: