Loading...
Searching...
No Matches
nrf24l01p_ng_communication.h File Reference

Functions to communicate with the NRF24L01+ (NG) transceiver via SPI. More...

Detailed Description

Functions to communicate with the NRF24L01+ (NG) transceiver via SPI.

Author
Fabian Hüßler fabia.nosp@m.n.hu.nosp@m.essle.nosp@m.r@ov.nosp@m.gu.de

Definition in file nrf24l01p_ng_communication.h.

#include "nrf24l01p_ng.h"
+ Include dependency graph for nrf24l01p_ng_communication.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define NRF24L01P_NG_ADDR_MASK   (0x1F)
 Mask for 5 bit register address.
 
#define NRF24L01P_NG_PIPE_MASK   (0x07)
 Mask for 3 bit pipe number.
 
#define NRF24L01P_NG_CMD_R_REGISTER(reg)    (0x00 | ((reg) & NRF24L01P_NG_ADDR_MASK))
 Read register value (1 to 5 bytes)
 
#define NRF24L01P_NG_CMD_W_REGISTER(reg)    (0x20 | ((reg) & NRF24L01P_NG_ADDR_MASK))
 Write register value (1 to 5 bytes)
 
#define NRF24L01P_NG_CMD_R_RX_PAYLOAD   (0x61)
 Read RX payload buffer (1 to 32 bytes)
 
#define NRF24L01P_NG_CMD_W_TX_PAYLOAD   (0xA0)
 Write TX payload buffer (1 to 32 bytes)
 
#define NRF24L01P_NG_CMD_FLUSH_TX   (0xE1)
 Flush TX buffer (0 bytes data)
 
#define NRF24L01P_NG_CMD_FLUSH_RX   (0xE2)
 Flush RX buffer (0 bytes data)
 
#define NRF24L01P_NG_CMD_REUSE_TX_PL   (0xE3)
 Reuse last transmitted payload (0 bytes data)
 
#define NRF24L01P_NG_CMD_R_RX_PL_WID   (0x60)
 Read RX payload width for the top R_RX_PAYLOAD in RX FIFO (1 byte data)
 
#define NRF24L01P_NG_CMD_W_ACK_PAYLOAD(pipe)    (0xA8 | ((pipe) & NRF24L01P_NG_PIPE_MASK))
 Write payload to be transmitted together with ACK for certain pipe (1 to 32 bytes data)
 
#define NRF24L01P_NG_CMD_W_TX_PAYLOAD_NO_ACK   (0xB0)
 Disable auto ACK on this specific frame.
 
#define NRF24L01P_NG_CMD_NOP   (0xFF)
 No operation.
 
void nrf24l01p_ng_acquire (nrf24l01p_ng_t *dev)
 Acquire the SPI bus of the transceiver.
 
void nrf24l01p_ng_release (nrf24l01p_ng_t *dev)
 Release the SPI bus of the transceiver.
 
uint8_t nrf24l01p_ng_read_reg (const nrf24l01p_ng_t *dev, uint8_t reg, uint8_t *dest, size_t len)
 Read a register value.
 
uint8_t nrf24l01p_ng_write_reg (const nrf24l01p_ng_t *dev, uint8_t reg, const uint8_t *src, size_t len)
 Write a register value.
 
uint8_t nrf24l01p_ng_read_rx_payload (const nrf24l01p_ng_t *dev, void *dest, size_t len)
 Read received payload.
 
uint8_t nrf24l01p_ng_write_tx_payload (const nrf24l01p_ng_t *dev, const void *src, size_t len)
 Write payload to be transmitted.
 
uint8_t nrf24l01p_ng_flush_tx (const nrf24l01p_ng_t *dev)
 Flush TX FIFO.
 
uint8_t nrf24l01p_ng_flush_rx (const nrf24l01p_ng_t *dev)
 Flush RX FIFO.
 
uint8_t nrf24l01p_ng_reuse_tx_pl (const nrf24l01p_ng_t *dev)
 Reuse TX payload in FIFO.
 
uint8_t nrf24l01p_ng_read_rx_pl_width (const nrf24l01p_ng_t *dev, uint8_t *dest)
 Read received payload width.
 
uint8_t nrf24l01p_ng_write_ack_pl (const nrf24l01p_ng_t *dev, const void *src, size_t len, uint8_t pipe)
 Write Payload to be transmitted in an ACK frame.
 
uint8_t nrf24l01p_ng_write_tx_pl_no_ack (const nrf24l01p_ng_t *dev, const void *src, size_t len)
 Write payload to be transmitted but do not expect an ACK for this frame.
 
uint8_t nrf24l01p_ng_get_status (const nrf24l01p_ng_t *dev)
 Get status register value.
 

Macro Definition Documentation

◆ NRF24L01P_NG_ADDR_MASK

#define NRF24L01P_NG_ADDR_MASK   (0x1F)

Mask for 5 bit register address.

Definition at line 30 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_FLUSH_RX

#define NRF24L01P_NG_CMD_FLUSH_RX   (0xE2)

Flush RX buffer (0 bytes data)

Definition at line 73 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_FLUSH_TX

#define NRF24L01P_NG_CMD_FLUSH_TX   (0xE1)

Flush TX buffer (0 bytes data)

Definition at line 67 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_NOP

#define NRF24L01P_NG_CMD_NOP   (0xFF)

No operation.

Definition at line 102 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_R_REGISTER

#define NRF24L01P_NG_CMD_R_REGISTER (   reg)     (0x00 | ((reg) & NRF24L01P_NG_ADDR_MASK))

Read register value (1 to 5 bytes)

Definition at line 41 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_R_RX_PAYLOAD

#define NRF24L01P_NG_CMD_R_RX_PAYLOAD   (0x61)

Read RX payload buffer (1 to 32 bytes)

Definition at line 55 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_R_RX_PL_WID

#define NRF24L01P_NG_CMD_R_RX_PL_WID   (0x60)

Read RX payload width for the top R_RX_PAYLOAD in RX FIFO (1 byte data)

Definition at line 85 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_REUSE_TX_PL

#define NRF24L01P_NG_CMD_REUSE_TX_PL   (0xE3)

Reuse last transmitted payload (0 bytes data)

Definition at line 79 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_W_ACK_PAYLOAD

#define NRF24L01P_NG_CMD_W_ACK_PAYLOAD (   pipe)     (0xA8 | ((pipe) & NRF24L01P_NG_PIPE_MASK))

Write payload to be transmitted together with ACK for certain pipe (1 to 32 bytes data)

Definition at line 91 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_W_REGISTER

#define NRF24L01P_NG_CMD_W_REGISTER (   reg)     (0x20 | ((reg) & NRF24L01P_NG_ADDR_MASK))

Write register value (1 to 5 bytes)

Definition at line 48 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_W_TX_PAYLOAD

#define NRF24L01P_NG_CMD_W_TX_PAYLOAD   (0xA0)

Write TX payload buffer (1 to 32 bytes)

Definition at line 61 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_CMD_W_TX_PAYLOAD_NO_ACK

#define NRF24L01P_NG_CMD_W_TX_PAYLOAD_NO_ACK   (0xB0)

Disable auto ACK on this specific frame.

Definition at line 97 of file nrf24l01p_ng_communication.h.

◆ NRF24L01P_NG_PIPE_MASK

#define NRF24L01P_NG_PIPE_MASK   (0x07)

Mask for 3 bit pipe number.

Definition at line 35 of file nrf24l01p_ng_communication.h.

Function Documentation

◆ nrf24l01p_ng_acquire()

void nrf24l01p_ng_acquire ( nrf24l01p_ng_t dev)

Acquire the SPI bus of the transceiver.

Parameters
[in]devNRF24L01+ device handle

◆ nrf24l01p_ng_flush_rx()

uint8_t nrf24l01p_ng_flush_rx ( const nrf24l01p_ng_t dev)

Flush RX FIFO.

Parameters
[in]devNRF24L01+ device handle
Returns
Status register value

◆ nrf24l01p_ng_flush_tx()

uint8_t nrf24l01p_ng_flush_tx ( const nrf24l01p_ng_t dev)

Flush TX FIFO.

Parameters
[in]devNRF24L01+ device handle
Returns
Status register value

◆ nrf24l01p_ng_get_status()

uint8_t nrf24l01p_ng_get_status ( const nrf24l01p_ng_t dev)

Get status register value.

Parameters
[in]devNRF24L01+ device handle
Returns
Status register value

◆ nrf24l01p_ng_read_reg()

uint8_t nrf24l01p_ng_read_reg ( const nrf24l01p_ng_t dev,
uint8_t  reg,
uint8_t *  dest,
size_t  len 
)

Read a register value.

Parameters
[in]devNRF24L01+ device handle
[in]regRegister address
[out]destOutput register
[in]lenOutput register width
Returns
Status register value

◆ nrf24l01p_ng_read_rx_payload()

uint8_t nrf24l01p_ng_read_rx_payload ( const nrf24l01p_ng_t dev,
void *  dest,
size_t  len 
)

Read received payload.

Parameters
[in]devNRF24L01+ device handle
[out]destOutput payload buffer
[in]lenOutput payload length
Returns
Status register value

◆ nrf24l01p_ng_read_rx_pl_width()

uint8_t nrf24l01p_ng_read_rx_pl_width ( const nrf24l01p_ng_t dev,
uint8_t *  dest 
)

Read received payload width.

Parameters
[in]devNRF24L01+ device handle
[out]destPayload width
Returns
Status register value

◆ nrf24l01p_ng_release()

void nrf24l01p_ng_release ( nrf24l01p_ng_t dev)

Release the SPI bus of the transceiver.

Parameters
[in]devNRF24L01+ device handle

◆ nrf24l01p_ng_reuse_tx_pl()

uint8_t nrf24l01p_ng_reuse_tx_pl ( const nrf24l01p_ng_t dev)

Reuse TX payload in FIFO.

This function can be used to reattempt to transmit a frame, after a MAX_RT interrupt was triggered.

Parameters
[in]devNRF24L01+ device handle
Returns
Status register value

◆ nrf24l01p_ng_write_ack_pl()

uint8_t nrf24l01p_ng_write_ack_pl ( const nrf24l01p_ng_t dev,
const void *  src,
size_t  len,
uint8_t  pipe 
)

Write Payload to be transmitted in an ACK frame.

Parameters
[in]devNRF24L01+ device handle
[in]srcInput payload buffer
[in]lenInput payload length
[in]pipeIndex of data pipe
Returns
Status register value

◆ nrf24l01p_ng_write_reg()

uint8_t nrf24l01p_ng_write_reg ( const nrf24l01p_ng_t dev,
uint8_t  reg,
const uint8_t *  src,
size_t  len 
)

Write a register value.

Parameters
[in]devNRF24L01+ device handle
[in]regRegister address
[in]srcData to be written into the register
[in]lenRegister width
Returns
Status register value

◆ nrf24l01p_ng_write_tx_payload()

uint8_t nrf24l01p_ng_write_tx_payload ( const nrf24l01p_ng_t dev,
const void *  src,
size_t  len 
)

Write payload to be transmitted.

Parameters
[in]devNRF24L01+ device handle
[in]srcInput payload buffer
[in]lenInput payload length
Returns
Status register value

◆ nrf24l01p_ng_write_tx_pl_no_ack()

uint8_t nrf24l01p_ng_write_tx_pl_no_ack ( const nrf24l01p_ng_t dev,
const void *  src,
size_t  len 
)

Write payload to be transmitted but do not expect an ACK for this frame.

Parameters
[in]devNRF24L01+ device handle
[in]srcInput payload buffer
[in]lenInput payload length
Returns
Status register value