English | 简体中文 | 繁體中文 | 日本語 | Deutsch | 한국어
LibDriver NRF24L01
The nRF24L01+ is a single chip 2.4GHz transceiver with an embedded baseband protocol engine (Enhanced ShockBurst™), suitable for ultra low power wireless applications. The nRF24L01+ is designed for operation in the world wide ISM frequency band at 2.400 - 2.4835GHz.To design a radio system with the nRF24L01+, you simply need an MCU (microcontroller) and a few external passive components.You can operate and configure the nRF24L01+ through a Serial Peripheral Interface (SPI). The register map, which is accessible through the SPI, contains all configuration registers in the nRF24L01+ and is accessible in all operation modes of the chip.The embedded baseband protocol engine (Enhanced ShockBurst™) is based on packet communication and supports various modes from manual operation to advanced autonomous protocol operation. Internal FIFOs ensure a smooth data flow between the radio front end and the system’s MCU. Enhanced Shock-Burst™ reduces system cost by handling all the high speed link layer operations.The radio front end uses GFSK modulation. It has user configurable parameters like frequency channel, output power and air data rate. nRF24L01+ supports an air data rate of 250 kbps, 1 Mbps and 2Mbps. The high air data rate combined with two power saving modes make the nRF24L01+ very suitable for ultra low power designs.nRF24L01+ is drop-in compatible with nRF24L01 and on-air compatible with nRF2401A, nRF2402, nRF24E1 and nRF24E2. Intermodulation and wideband blocking values in nRF24L01+ are much improved in comparison to the nRF24L01 and the addition of internal filtering to nRF24L01+ has improved the margins for meeting RF regulatory standards.Internal voltage regulators ensure a high Power Supply Rejection Ratio (PSRR) and a wide power supply range. NRF24L01 is used in wireless PC peripherals,mouse, keyboards, remotes, game controllers and so on.
LibDriver NRF24L01 is the full function driver of NRF24L01 launched by LibDriver.It provides functions of wireless senting, wireless receiving, etc. LibDriver is MISRA compliant.
Table of Contents
Instruction
/src includes LibDriver NRF24L01 source files.
/interface includes LibDriver NRF24L01 SPI platform independent template.
/test includes LibDriver NRF24L01 driver test code and this code can test the chip necessary function simply.
/example includes LibDriver NRF24L01 sample code.
/doc includes LibDriver NRF24L01 offline document.
/datasheet includes NRF24L01 datasheet.
/project includes the common Linux and MCU development board sample code. All projects use the shell script to debug the driver and the detail instruction can be found in each project's README.md.
/misra includes the LibDriver MISRA code scanning results.
Install
Reference /interface SPI platform independent template and finish your platform SPI driver.
Add /src, /interface and /example to your project.
Usage
example basic sent
#include "driver_nrf24l01_basic.h"
uint8_t (*g_gpio_irq)(void) = NULL;
uint8_t res;
uint8_t addr[5] = NRF24L01_BASIC_DEFAULT_RX_ADDR_0;
...
static void a_callback(uint8_t type, uint8_t num, uint8_t *buf, uint8_t len)
{
switch (type)
{
case NRF24L01_INTERRUPT_RX_DR :
{
uint8_t i;
nrf24l01_interface_debug_print("nrf24l01: irq receive with pipe %d with %d.\n", num, len);
for (i = 0; i < len; i++)
{
nrf24l01_interface_debug_print("0x%02X ", buf[i]);
}
nrf24l01_interface_debug_print(".\n");
break;
}
case NRF24L01_INTERRUPT_TX_DS :
{
nrf24l01_interface_debug_print("nrf24l01: irq sent ok.\n");
break;
}
case NRF24L01_INTERRUPT_MAX_RT :
{
nrf24l01_interface_debug_print("nrf24l01: irq reach max retry times.\n");
break;
}
case NRF24L01_INTERRUPT_TX_FULL :
{
break;
}
default :
{
break;
}
}
}
...
res = gpio_interrupt_init();
if (res != 0)
{
return 1;
}
g_gpio_irq = nrf24l01_interrupt_irq_handler;
res = nrf24l01_basic_init(NRF24L01_TYPE_TX, a_callback);
if (res != 0)
{
(void)gpio_interrupt_deinit();
g_gpio_irq = NULL;
return 1;
}
if (nrf24l01_basic_sent((uint8_t *)addr, (uint8_t *)"123", 3) != 0);
{
(void)nrf24l01_basic_deinit();
(void)gpio_interrupt_deinit();
g_gpio_irq = NULL;
return 1;
}
if (nrf24l01_basic_deinit() != 0)
{
(void)gpio_interrupt_deinit();
g_gpio_irq = NULL;
return 1;
}
(void)gpio_interrupt_deinit();
g_gpio_irq = NULL;
return 0;
example basic receive
#include "driver_nrf24l01_basic.h"
uint8_t (*g_gpio_irq)(void) = NULL;
uint8_t res;
uint32_t timeout;
...
static void a_callback(uint8_t type, uint8_t num, uint8_t *buf, uint8_t len)
{
switch (type)
{
case NRF24L01_INTERRUPT_RX_DR :
{
uint8_t i;
nrf24l01_interface_debug_print("nrf24l01: irq receive with pipe %d with %d.\n", num, len);
for (i = 0; i < len; i++)
{
nrf24l01_interface_debug_print("0x%02X ", buf[i]);
}
nrf24l01_interface_debug_print(".\n");
break;
}
case NRF24L01_INTERRUPT_TX_DS :
{
nrf24l01_interface_debug_print("nrf24l01: irq sent ok.\n");
break;
}
case NRF24L01_INTERRUPT_MAX_RT :
{
nrf24l01_interface_debug_print("nrf24l01: irq reach max retry times.\n");
break;
}
case NRF24L01_INTERRUPT_TX_FULL :
{
break;
}
default :
{
break;
}
}
}
...
timeout = 5000;
res = gpio_interrupt_init();
if (res != 0)
{
return 1;
}
g_gpio_irq = nrf24l01_interrupt_irq_handler;
res = nrf24l01_basic_init(NRF24L01_TYPE_RX, a_callback);
if (res != 0)
{
(void)gpio_interrupt_deinit();
g_gpio_irq = NULL;
return 1;
}
nrf24l01_interface_delay_ms(timeout);
if (nrf24l01_basic_deinit() != 0)
{
(void)gpio_interrupt_deinit();
g_gpio_irq = NULL;
return 1;
}
(void)gpio_interrupt_deinit();
g_gpio_irq = NULL;
return 0;
Document
Online documents: https://www.libdriver.com/docs/nrf24l01/index.html.
Offline documents: /doc/html/index.html.
Contributing
Please refer to CONTRIBUTING.md.
License
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.
Contact Us
Please sent an e-mail to [email protected].