LibDriver NRF24L01  1.0.0
NRF24L01 full-featured driver
driver_nrf24l01.h File Reference

driver nrf24l01 header file More...

#include <stdio.h>
#include <stdint.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  nrf24l01_handle_s
 nrf24l01 handle structure definition More...
 
struct  nrf24l01_info_s
 nrf24l01 information structure definition More...
 

Macros

#define DRIVER_NRF24L01_LINK_INIT(HANDLE, STRUCTURE)   memset(HANDLE, 0, sizeof(STRUCTURE))
 initialize nrf24l01_handle_t structure More...
 
#define DRIVER_NRF24L01_LINK_SPI_INIT(HANDLE, FUC)   (HANDLE)->spi_init = FUC
 link spi_init function More...
 
#define DRIVER_NRF24L01_LINK_SPI_DEINIT(HANDLE, FUC)   (HANDLE)->spi_deinit = FUC
 link spi_deinit function More...
 
#define DRIVER_NRF24L01_LINK_SPI_READ(HANDLE, FUC)   (HANDLE)->spi_read = FUC
 link spi_read function More...
 
#define DRIVER_NRF24L01_LINK_SPI_WRITE(HANDLE, FUC)   (HANDLE)->spi_write = FUC
 link gpio_write function More...
 
#define DRIVER_NRF24L01_LINK_GPIO_INIT(HANDLE, FUC)   (HANDLE)->gpio_init = FUC
 link gpio_init function More...
 
#define DRIVER_NRF24L01_LINK_GPIO_DEINIT(HANDLE, FUC)   (HANDLE)->gpio_deinit = FUC
 link gpio_deinit function More...
 
#define DRIVER_NRF24L01_LINK_GPIO_WRITE(HANDLE, FUC)   (HANDLE)->gpio_write = FUC
 link gpio_write function More...
 
#define DRIVER_NRF24L01_LINK_DELAY_MS(HANDLE, FUC)   (HANDLE)->delay_ms = FUC
 link delay_ms function More...
 
#define DRIVER_NRF24L01_LINK_DEBUG_PRINT(HANDLE, FUC)   (HANDLE)->debug_print = FUC
 link debug_print function More...
 
#define DRIVER_NRF24L01_LINK_RECEIVE_CALLBACK(HANDLE, FUC)   (HANDLE)->receive_callback = FUC
 link receive_callback function More...
 

Typedefs

typedef struct nrf24l01_handle_s nrf24l01_handle_t
 nrf24l01 handle structure definition More...
 
typedef struct nrf24l01_info_s nrf24l01_info_t
 nrf24l01 information structure definition More...
 

Enumerations

enum  nrf24l01_bool_t { NRF24L01_BOOL_FALSE = 0x00 , NRF24L01_BOOL_TRUE = 0x01 }
 nrf24l01 bool enumeration definition More...
 
enum  nrf24l01_config_t {
  NRF24L01_CONFIG_MASK_RX_DR = 6 , NRF24L01_CONFIG_MASK_TX_DS = 5 , NRF24L01_CONFIG_MASK_MAX_RT = 4 , NRF24L01_CONFIG_EN_CRC = 3 ,
  NRF24L01_CONFIG_CRCO = 2 , NRF24L01_CONFIG_PWR_UP = 1
}
 nrf24l01 config enumeration definition More...
 
enum  nrf24l01_mode_t { NRF24L01_MODE_TX = 0x00 , NRF24L01_MODE_RX = 0x01 }
 nrf24l01 mode enumeration definition More...
 
enum  nrf24l01_pipe_t {
  NRF24L01_PIPE_0 = 0 , NRF24L01_PIPE_1 = 1 , NRF24L01_PIPE_2 = 2 , NRF24L01_PIPE_3 = 3 ,
  NRF24L01_PIPE_4 = 4 , NRF24L01_PIPE_5 = 5
}
 nrf24l01 pipe enumeration definition More...
 
enum  nrf24l01_address_width_t { NRF24L01_ADDRESS_WIDTH_ILLEGAL = 0 , NRF24L01_ADDRESS_WIDTH_3_BYTES = 1 , NRF24L01_ADDRESS_WIDTH_4_BYTES = 2 , NRF24L01_ADDRESS_WIDTH_5_BYTES = 3 }
 nrf24l01 address width enumeration definition More...
 
enum  nrf24l01_data_rate_t { NRF24L01_DATA_RATE_1M = 0 , NRF24L01_DATA_RATE_2M = 1 , NRF24L01_DATA_RATE_250K = 2 }
 nrf24l01 data rate enumeration definition More...
 
enum  nrf24l01_output_power_t { NRF24L01_OUTPUT_POWER_NEGATIVE_18_DBM = 0 , NRF24L01_OUTPUT_POWER_NEGATIVE_12_DBM = 1 , NRF24L01_OUTPUT_POWER_NEGATIVE_6_DBM = 2 , NRF24L01_OUTPUT_POWER_0_DBM = 3 }
 nrf24l01 output power enumeration definition More...
 
enum  nrf24l01_interrupt_t { NRF24L01_INTERRUPT_RX_DR = 6 , NRF24L01_INTERRUPT_TX_DS = 5 , NRF24L01_INTERRUPT_MAX_RT = 4 , NRF24L01_INTERRUPT_TX_FULL = 0 }
 nrf24l01 interrupt enumeration definition More...
 
enum  nrf24l01_fifo_status_t {
  NRF24L01_FIFO_STATUS_TX_REUSE = 6 , NRF24L01_FIFO_STATUS_TX_FULL = 5 , NRF24L01_FIFO_STATUS_TX_EMPTY = 4 , NRF24L01_FIFO_STATUS_RX_FULL = 1 ,
  NRF24L01_FIFO_STATUS_RX_EMPTY = 0
}
 nrf24l01 fifo status enumeration definition More...
 

Functions

uint8_t nrf24l01_info (nrf24l01_info_t *info)
 get chip's information More...
 
uint8_t nrf24l01_irq_handler (nrf24l01_handle_t *handle)
 irq handler More...
 
uint8_t nrf24l01_init (nrf24l01_handle_t *handle)
 initialize the chip More...
 
uint8_t nrf24l01_deinit (nrf24l01_handle_t *handle)
 close the chip More...
 
uint8_t nrf24l01_send (nrf24l01_handle_t *handle, uint8_t *buf, uint8_t len)
 send data More...
 
uint8_t nrf24l01_set_active (nrf24l01_handle_t *handle, nrf24l01_bool_t enable)
 enable or disable the chip More...
 
uint8_t nrf24l01_set_config (nrf24l01_handle_t *handle, nrf24l01_config_t config, nrf24l01_bool_t enable)
 enable or disable configure More...
 
uint8_t nrf24l01_get_config (nrf24l01_handle_t *handle, nrf24l01_config_t config, nrf24l01_bool_t *enable)
 get the configure More...
 
uint8_t nrf24l01_set_mode (nrf24l01_handle_t *handle, nrf24l01_mode_t mode)
 set the chip mode More...
 
uint8_t nrf24l01_get_mode (nrf24l01_handle_t *handle, nrf24l01_mode_t *mode)
 get the chip mode More...
 
uint8_t nrf24l01_set_auto_acknowledgment (nrf24l01_handle_t *handle, nrf24l01_pipe_t pipe, nrf24l01_bool_t enable)
 enable or disable auto acknowledgment More...
 
uint8_t nrf24l01_get_auto_acknowledgment (nrf24l01_handle_t *handle, nrf24l01_pipe_t pipe, nrf24l01_bool_t *enable)
 get the auto acknowledgment status More...
 
uint8_t nrf24l01_set_rx_pipe (nrf24l01_handle_t *handle, nrf24l01_pipe_t pipe, nrf24l01_bool_t enable)
 enable or disable rx pipe More...
 
uint8_t nrf24l01_get_rx_pipe (nrf24l01_handle_t *handle, nrf24l01_pipe_t pipe, nrf24l01_bool_t *enable)
 get the rx pipe status More...
 
uint8_t nrf24l01_set_address_width (nrf24l01_handle_t *handle, nrf24l01_address_width_t width)
 set the address width More...
 
uint8_t nrf24l01_get_address_width (nrf24l01_handle_t *handle, nrf24l01_address_width_t *width)
 get the address width More...
 
uint8_t nrf24l01_set_auto_retransmit_delay (nrf24l01_handle_t *handle, uint8_t delay)
 set the auto retransmit delay More...
 
uint8_t nrf24l01_get_auto_retransmit_delay (nrf24l01_handle_t *handle, uint8_t *delay)
 get the auto retransmit delay More...
 
uint8_t nrf24l01_auto_retransmit_delay_convert_to_register (nrf24l01_handle_t *handle, uint32_t us, uint8_t *reg)
 convert the delay to the register raw data More...
 
uint8_t nrf24l01_auto_retransmit_delay_convert_to_data (nrf24l01_handle_t *handle, uint8_t reg, uint32_t *us)
 convert the register raw data to the delay More...
 
uint8_t nrf24l01_set_auto_retransmit_count (nrf24l01_handle_t *handle, uint8_t count)
 set the auto retransmit count More...
 
uint8_t nrf24l01_get_auto_retransmit_count (nrf24l01_handle_t *handle, uint8_t *count)
 get the auto retransmit count More...
 
uint8_t nrf24l01_set_channel_frequency (nrf24l01_handle_t *handle, uint8_t freq)
 set the channel frequency More...
 
uint8_t nrf24l01_get_channel_frequency (nrf24l01_handle_t *handle, uint8_t *freq)
 get the channel frequency More...
 
uint8_t nrf24l01_set_continuous_carrier_transmit (nrf24l01_handle_t *handle, nrf24l01_bool_t enable)
 enable or disable continuous carrier transmit More...
 
uint8_t nrf24l01_get_continuous_carrier_transmit (nrf24l01_handle_t *handle, nrf24l01_bool_t *enable)
 get the continuous carrier transmit status More...
 
uint8_t nrf24l01_set_force_pll_lock_signal (nrf24l01_handle_t *handle, nrf24l01_bool_t enable)
 enable or disable force pll lock signal More...
 
uint8_t nrf24l01_get_force_pll_lock_signal (nrf24l01_handle_t *handle, nrf24l01_bool_t *enable)
 get the force pll lock signal status More...
 
uint8_t nrf24l01_set_data_rate (nrf24l01_handle_t *handle, nrf24l01_data_rate_t rate)
 set the data rate More...
 
uint8_t nrf24l01_get_data_rate (nrf24l01_handle_t *handle, nrf24l01_data_rate_t *rate)
 get the data rate More...
 
uint8_t nrf24l01_set_output_power (nrf24l01_handle_t *handle, nrf24l01_output_power_t power)
 set the output power More...
 
uint8_t nrf24l01_get_output_power (nrf24l01_handle_t *handle, nrf24l01_output_power_t *power)
 get the output power More...
 
uint8_t nrf24l01_get_interrupt (nrf24l01_handle_t *handle, nrf24l01_interrupt_t type, nrf24l01_bool_t *enable)
 get the interrupt status More...
 
uint8_t nrf24l01_clear_interrupt (nrf24l01_handle_t *handle, nrf24l01_interrupt_t type)
 clear the interrupt status More...
 
uint8_t nrf24l01_get_data_pipe_number (nrf24l01_handle_t *handle, uint8_t *number)
 get the data pipe number More...
 
uint8_t nrf24l01_get_lost_packet_count (nrf24l01_handle_t *handle, uint8_t *count)
 get the lost packet count More...
 
uint8_t nrf24l01_get_retransmitted_packet_count (nrf24l01_handle_t *handle, uint8_t *count)
 get the retransmitted packet count More...
 
uint8_t nrf24l01_get_received_power_detector (nrf24l01_handle_t *handle, nrf24l01_bool_t *enable)
 get the received power detector More...
 
uint8_t nrf24l01_set_rx_pipe_0_address (nrf24l01_handle_t *handle, uint8_t *addr, uint8_t len)
 set the rx pipe 0 address More...
 
uint8_t nrf24l01_get_rx_pipe_0_address (nrf24l01_handle_t *handle, uint8_t *addr, uint8_t *len)
 get the rx pipe 0 address More...
 
uint8_t nrf24l01_set_rx_pipe_1_address (nrf24l01_handle_t *handle, uint8_t *addr, uint8_t len)
 set the rx pipe 1 address More...
 
uint8_t nrf24l01_get_rx_pipe_1_address (nrf24l01_handle_t *handle, uint8_t *addr, uint8_t *len)
 get the rx pipe 1 address More...
 
uint8_t nrf24l01_set_rx_pipe_2_address (nrf24l01_handle_t *handle, uint8_t addr)
 set the rx pipe 2 address More...
 
uint8_t nrf24l01_get_rx_pipe_2_address (nrf24l01_handle_t *handle, uint8_t *addr)
 get the rx pipe 2 address More...
 
uint8_t nrf24l01_set_rx_pipe_3_address (nrf24l01_handle_t *handle, uint8_t addr)
 set the rx pipe 3 address More...
 
uint8_t nrf24l01_get_rx_pipe_3_address (nrf24l01_handle_t *handle, uint8_t *addr)
 get the rx pipe 3 address More...
 
uint8_t nrf24l01_set_rx_pipe_4_address (nrf24l01_handle_t *handle, uint8_t addr)
 set the rx pipe 4 address More...
 
uint8_t nrf24l01_get_rx_pipe_4_address (nrf24l01_handle_t *handle, uint8_t *addr)
 get the rx pipe 4 address More...
 
uint8_t nrf24l01_set_rx_pipe_5_address (nrf24l01_handle_t *handle, uint8_t addr)
 set the rx pipe 5 address More...
 
uint8_t nrf24l01_get_rx_pipe_5_address (nrf24l01_handle_t *handle, uint8_t *addr)
 get the rx pipe 5 address More...
 
uint8_t nrf24l01_set_tx_address (nrf24l01_handle_t *handle, uint8_t *addr, uint8_t len)
 set the tx address More...
 
uint8_t nrf24l01_get_tx_address (nrf24l01_handle_t *handle, uint8_t *addr, uint8_t *len)
 get the tx address More...
 
uint8_t nrf24l01_set_pipe_0_payload_number (nrf24l01_handle_t *handle, uint8_t num)
 set the pipe 0 payload number More...
 
uint8_t nrf24l01_get_pipe_0_payload_number (nrf24l01_handle_t *handle, uint8_t *num)
 get the pipe 0 payload number More...
 
uint8_t nrf24l01_set_pipe_1_payload_number (nrf24l01_handle_t *handle, uint8_t num)
 set the pipe 1 payload number More...
 
uint8_t nrf24l01_get_pipe_1_payload_number (nrf24l01_handle_t *handle, uint8_t *num)
 get the pipe 1 payload number More...
 
uint8_t nrf24l01_set_pipe_2_payload_number (nrf24l01_handle_t *handle, uint8_t num)
 set the pipe 2 payload number More...
 
uint8_t nrf24l01_get_pipe_2_payload_number (nrf24l01_handle_t *handle, uint8_t *num)
 get the pipe 2 payload number More...
 
uint8_t nrf24l01_set_pipe_3_payload_number (nrf24l01_handle_t *handle, uint8_t num)
 set the pipe 3 payload number More...
 
uint8_t nrf24l01_get_pipe_3_payload_number (nrf24l01_handle_t *handle, uint8_t *num)
 get the pipe 3 payload number More...
 
uint8_t nrf24l01_set_pipe_4_payload_number (nrf24l01_handle_t *handle, uint8_t num)
 set the pipe 4 payload number More...
 
uint8_t nrf24l01_get_pipe_4_payload_number (nrf24l01_handle_t *handle, uint8_t *num)
 get the pipe 4 payload number More...
 
uint8_t nrf24l01_set_pipe_5_payload_number (nrf24l01_handle_t *handle, uint8_t num)
 set the pipe 5 payload number More...
 
uint8_t nrf24l01_get_pipe_5_payload_number (nrf24l01_handle_t *handle, uint8_t *num)
 get the pipe 5 payload number More...
 
uint8_t nrf24l01_get_fifo_status (nrf24l01_handle_t *handle, uint8_t *status)
 get the fifo status More...
 
uint8_t nrf24l01_set_pipe_dynamic_payload (nrf24l01_handle_t *handle, nrf24l01_pipe_t pipe, nrf24l01_bool_t enable)
 enable or disable the pipe dynamic payload More...
 
uint8_t nrf24l01_get_pipe_dynamic_payload (nrf24l01_handle_t *handle, nrf24l01_pipe_t pipe, nrf24l01_bool_t *enable)
 get the pipe dynamic payload status More...
 
uint8_t nrf24l01_set_dynamic_payload (nrf24l01_handle_t *handle, nrf24l01_bool_t enable)
 enable or disable the dynamic payload More...
 
uint8_t nrf24l01_get_dynamic_payload (nrf24l01_handle_t *handle, nrf24l01_bool_t *enable)
 get the dynamic payload status More...
 
uint8_t nrf24l01_set_payload_with_ack (nrf24l01_handle_t *handle, nrf24l01_bool_t enable)
 enable or disable the payload with ack More...
 
uint8_t nrf24l01_get_payload_with_ack (nrf24l01_handle_t *handle, nrf24l01_bool_t *enable)
 get the payload with ack status More...
 
uint8_t nrf24l01_set_tx_payload_with_no_ack (nrf24l01_handle_t *handle, nrf24l01_bool_t enable)
 enable or disable the tx payload with no ack More...
 
uint8_t nrf24l01_get_tx_payload_with_no_ack (nrf24l01_handle_t *handle, nrf24l01_bool_t *enable)
 get the tx payload with no ack status More...
 
uint8_t nrf24l01_read_rx_payload (nrf24l01_handle_t *handle, uint8_t *buf, uint8_t len)
 read the rx payload More...
 
uint8_t nrf24l01_write_tx_payload (nrf24l01_handle_t *handle, uint8_t *buf, uint8_t len)
 write the tx payload More...
 
uint8_t nrf24l01_flush_tx (nrf24l01_handle_t *handle)
 flush tx More...
 
uint8_t nrf24l01_flush_rx (nrf24l01_handle_t *handle)
 flush rx More...
 
uint8_t nrf24l01_reuse_tx_payload (nrf24l01_handle_t *handle)
 reuse the tx payload More...
 
uint8_t nrf24l01_get_rx_payload_width (nrf24l01_handle_t *handle, uint8_t *width)
 get the rx payload width More...
 
uint8_t nrf24l01_write_payload_with_ack (nrf24l01_handle_t *handle, nrf24l01_pipe_t pipe, uint8_t *buf, uint8_t len)
 write the payload with ack More...
 
uint8_t nrf24l01_write_payload_with_no_ack (nrf24l01_handle_t *handle, uint8_t *buf, uint8_t len)
 write the payload with no ack More...
 
uint8_t nrf24l01_nop (nrf24l01_handle_t *handle)
 nop More...
 
uint8_t nrf24l01_set_reg (nrf24l01_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 set the chip register More...
 
uint8_t nrf24l01_get_reg (nrf24l01_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 get the chip register More...
 

Detailed Description

driver nrf24l01 header file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2021-11-28

history

Date Version Author Description
2021/11/28 1.0 Shifeng Li first upload

Definition in file driver_nrf24l01.h.