NRF24L01 Library
Defines | Functions

nrf24l01.h File Reference

Go to the source code of this file.

Defines

#define _RX_DR   (1<<6)
 Data Ready RX FIFO interrupt.
#define _TX_DS   (1<<5)
 Data Sent TX FIFO interrupt.
#define _MAX_RT   (1<<4)
 Maximum number of TX retransmits interrupt.
#define _POWER_DOWN   0
 Power Down mode.
#define _POWER_UP   (1<<1)
 Power Up mode.
#define _TX_MODE   0
 Mode radio transmitter.
#define _RX_MODE   1
 Mode radio receiver.
#define _1Mbps   0
 Air data rate = 1 Mbps.
#define _2Mbps   (1<<3)
 Air data rate = 2 Mbps.
#define _ShockBurst_ON   1
 Enable ShockBurst.
#define _ShockBurst_OFF   0
 Disable ShockBurst.
#define CONFIG   0x00
#define EN_AA   0x01
#define EN_RXADDR   0x02
#define SETUP_AW   0x03
#define SETUP_RETR   0x04
#define RF_CH   0x05
#define RF_SETUP   0x06
#define STATUS   0x07
#define OBSERVE_TX   0x08
#define CD   0x09
#define RX_ADDR_P0   0x0A
#define RX_ADDR_P1   0x0B
#define RX_ADDR_P2   0x0C
#define RX_ADDR_P3   0x0D
#define RX_ADDR_P4   0x0E
#define RX_ADDR_P5   0x0F
#define TX_ADDR   0x10
#define RX_PW_P0   0x11
#define RX_PW_P1   0x12
#define RX_PW_P2   0x13
#define RX_PW_P3   0x14
#define RX_PW_P4   0x15
#define RX_PW_P5   0x16
#define FIFO_STATUS   0x17
#define DYNPD   0x1C
#define FEATURE   0x1D
#define R_REGISTER   0x00
#define W_REGISTER   0x20
#define R_RX_PAYLOAD   0x61
#define W_TX_PAYLOAD   0xA0
#define FLUSH_TX   0xE1
#define FLUSH_RX   0xE2
#define REUSE_TX_PL   0xE3
#define ACTIVATE   0x50
#define R_RX_PL_WID   0x60
#define W_ACK_PAYLOAD   0xA8
#define W_TX_PAYLOAD_NOACK   0x58
#define NOP   0xFF

Functions

char NRF24L01_ReadReg (char Reg)
 Read a register.
char NRF24L01_WriteReg (char Reg, char Value)
 Returns the STATUS register and then modify a register.
char NRF24L01_ReadRegBuf (char Reg, char *Buf, int Size)
 Returns the STATUS register and then read "n" registers.
char NRF24L01_WriteRegBuf (char Reg, char *Buf, int Size)
 Returns the STATUS register and then write "n" registers.
char NRF24L01_Get_Status (void)
 Returns the STATUS register.
char NRF24L01_Get_CD (void)
 Returns the carrier signal in RX mode (high when detected)
void NRF24L01_Set_Power (char Mode)
 Select power mode.
void NRF24L01_Set_CH (char CH)
 Select the radio channel.
void NRF24L01_Set_ShockBurst (char Mode)
 Select Enhanced ShockBurst ON/OFF.
void NRF24L01_Set_Address_Width (char Width)
 Select the address width.
void NRF24L01_Set_Device_Mode (char Device_Mode)
 Select mode receiver or transmitter.
void NRF24L01_Set_RX_Pipe (char PipeNum, char *Address, int AddressSize, char PayloadSize)
 Enables and configures the pipe receiving the data.
void NRF24L01_Disable_All_Pipes (void)
 Disable all pipes.
char NRF24L01_Clear_Interrupts (void)
 Returns the STATUS register and then clear all interrupts.
void NRF24L01_Set_TX_Address (char *Address, int Size)
 Sets the direction of transmission.
void NRF24L01_Flush_TX (void)
 Empty the transmit buffer.
void NRF24L01_Flush_RX (void)
 Empty the receive buffer.
void NRF24L01_Init (char Device_Mode, char CH, char DataRate, char *Address, char Address_Width, char Size_Payload)
 Initializes the device.
void NRF24L01_RF_TX (void)
 Turn on transmitter, and transmits the data loaded into the buffer.
void NRF24L01_Write_TX_Buf (char *Buf, int Size)
 Writes the buffer of data transmission.
void NRF24L01_Read_RX_Buf (char *Buf, int Size)
 Read the data reception buffer.

Define Documentation

#define _1Mbps   0

Air data rate = 1 Mbps.

See also:
NRF24L01_Init(char Device_Mode, char CH, char DataRate, char *Address, char Address_Width, char Size_Payload)
#define _2Mbps   (1<<3)

Air data rate = 2 Mbps.

See also:
NRF24L01_Init(char Device_Mode, char CH, char DataRate, char *Address, char Address_Width, char Size_Payload)
#define _MAX_RT   (1<<4)

Maximum number of TX retransmits interrupt.

#define _POWER_DOWN   0

Power Down mode.

Minimal current consumption, SPI can be activated

See also:
NRF24L01_Set_Power(char Mode)
#define _POWER_UP   (1<<1)

Power Up mode.

Standby-I mode

See also:
NRF24L01_Set_Power(char Mode)
#define _RX_DR   (1<<6)

Data Ready RX FIFO interrupt.

#define _RX_MODE   1

Mode radio receiver.

See also:
NRF24L01_Set_Device_Mode(char Device_Mode)
NRF24L01_Init(char Device_Mode, char CH, char DataRate, char *Address, char Address_Width, char Size_Payload)
#define _ShockBurst_OFF   0

Disable ShockBurst.

See also:
NRF24L01_Set_ShockBurst(char Mode)
#define _ShockBurst_ON   1

Enable ShockBurst.

Automatic Retransmission (Up to 1 Re-Transmit on fail of AA)

Auto Acknowledgment (data pipe 0)

See also:
NRF24L01_Set_ShockBurst(char Mode)
#define _TX_DS   (1<<5)

Data Sent TX FIFO interrupt.

#define _TX_MODE   0

Mode radio transmitter.

See also:
NRF24L01_Set_Device_Mode(char Device_Mode)
NRF24L01_Init(char Device_Mode, char CH, char DataRate, char *Address, char Address_Width, char Size_Payload)
#define ACTIVATE   0x50
#define CD   0x09
#define CONFIG   0x00
#define DYNPD   0x1C
#define EN_AA   0x01
#define EN_RXADDR   0x02
#define FEATURE   0x1D
#define FIFO_STATUS   0x17
#define FLUSH_RX   0xE2
#define FLUSH_TX   0xE1
#define NOP   0xFF
#define OBSERVE_TX   0x08
#define R_REGISTER   0x00
#define R_RX_PAYLOAD   0x61
#define R_RX_PL_WID   0x60
#define REUSE_TX_PL   0xE3
#define RF_CH   0x05
#define RF_SETUP   0x06
#define RX_ADDR_P0   0x0A
#define RX_ADDR_P1   0x0B
#define RX_ADDR_P2   0x0C
#define RX_ADDR_P3   0x0D
#define RX_ADDR_P4   0x0E
#define RX_ADDR_P5   0x0F
#define RX_PW_P0   0x11
#define RX_PW_P1   0x12
#define RX_PW_P2   0x13
#define RX_PW_P3   0x14
#define RX_PW_P4   0x15
#define RX_PW_P5   0x16
#define SETUP_AW   0x03
#define SETUP_RETR   0x04
#define STATUS   0x07
#define TX_ADDR   0x10
#define W_ACK_PAYLOAD   0xA8
#define W_REGISTER   0x20
#define W_TX_PAYLOAD   0xA0
#define W_TX_PAYLOAD_NOACK   0x58

Function Documentation

char NRF24L01_Clear_Interrupts ( void  )

Returns the STATUS register and then clear all interrupts.

Returns:
STATUS Register
void NRF24L01_Disable_All_Pipes ( void  )

Disable all pipes.

void NRF24L01_Flush_RX ( void  )

Empty the receive buffer.

void NRF24L01_Flush_TX ( void  )

Empty the transmit buffer.

char NRF24L01_Get_CD ( void  )

Returns the carrier signal in RX mode (high when detected)

Returns:
CD
char NRF24L01_Get_Status ( void  )

Returns the STATUS register.

Returns:
STATUS Register
void NRF24L01_Init ( char  Device_Mode,
char  CH,
char  DataRate,
char *  Address,
char  Address_Width,
char  Size_Payload 
)

Initializes the device.

Parameters:
Device_Mode= _TX_MODE, _RX_MODE
CH= 0..125
DataRate= _1Mbps, _2Mbps
AddressAddress
Address_WidthWidth direction: 3..5
Size_PayloadData buffer size
See also:
_TX_MODE
_RX_MODE
_1Mbps
_2Mbps
void NRF24L01_Read_RX_Buf ( char *  Buf,
int  Size 
)

Read the data reception buffer.

Parameters:
BufBuffer with data received
SizeBuffer size
char NRF24L01_ReadReg ( char  Reg)

Read a register.

Parameters:
RegRegister to read
Returns:
Registry Value
char NRF24L01_ReadRegBuf ( char  Reg,
char *  Buf,
int  Size 
)

Returns the STATUS register and then read "n" registers.

Parameters:
RegRegister to read
BufPointer to a buffer
SizeBuffer Size
Returns:
STATUS Register
void NRF24L01_RF_TX ( void  )

Turn on transmitter, and transmits the data loaded into the buffer.

void NRF24L01_Set_Address_Width ( char  Width)

Select the address width.

Parameters:
Width= 3..5
void NRF24L01_Set_CH ( char  CH)

Select the radio channel.

Parameters:
CH= 0..125
void NRF24L01_Set_Device_Mode ( char  Device_Mode)

Select mode receiver or transmitter.

Parameters:
Device_Mode= _TX_MODE, _RX_MODE
See also:
_TX_MODE
_RX_MODE
void NRF24L01_Set_Power ( char  Mode)

Select power mode.

Parameters:
Mode= _POWER_DOWN, _POWER_UP
See also:
_POWER_DOWN
_POWER_UP
void NRF24L01_Set_RX_Pipe ( char  PipeNum,
char *  Address,
int  AddressSize,
char  PayloadSize 
)

Enables and configures the pipe receiving the data.

Parameters:
PipeNumNumber of pipe
AddressAddress
AddressSizeAddress size
PayloadSizeBuffer size, data receiver
void NRF24L01_Set_ShockBurst ( char  Mode)

Select Enhanced ShockBurst ON/OFF.

Disable this functionality to be compatible with nRF2401

Parameters:
Mode= _ShockBurst_ON, _ShockBurst_OFF
See also:
_ShockBurst_ON
_ShockBurst_OFF
void NRF24L01_Set_TX_Address ( char *  Address,
int  Size 
)

Sets the direction of transmission.

Parameters:
AddressAddress
SizeAddress size 3..5
void NRF24L01_Write_TX_Buf ( char *  Buf,
int  Size 
)

Writes the buffer of data transmission.

Parameters:
BufBuffer with data to send
SizeBuffer size
char NRF24L01_WriteReg ( char  Reg,
char  Value 
)

Returns the STATUS register and then modify a register.

Parameters:
RegRegister to change
ValueNew value
Returns:
STATUS Register
char NRF24L01_WriteRegBuf ( char  Reg,
char *  Buf,
int  Size 
)

Returns the STATUS register and then write "n" registers.

Parameters:
RegRegisters to change
BufPointer to a buffer
SizeBuffer Size
Returns:
STATUS Register
 All Files Functions Defines