• Stars
    star
    323
  • Rank 130,051 (Top 3 %)
  • Language
    C
  • License
    MIT License
  • Created almost 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NRF24L01 full function driver for general MCU and Linux.

English | 简体中文 | 繁體中文 | 日本語 | Deutsch | 한국어

LibDriver NRF24L01

MISRA API License

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].

More Repositories

1

w25qxx

W25QXX full function driver for general MCU and Linux.
C
470
star
2

ssd1306

SSD1306 full function driver for general MCU and Linux.
C
402
star
3

mpu9250

MPU9250 full function driver for general MCU and Linux.
C
332
star
4

mpu6050

MPU6050 full function driver for general MCU and Linux.
C
300
star
5

ds18b20

DS18B20 full function driver for general MCU and Linux.
C
233
star
6

adxl345

ADXL345 full function driver for general MCU and Linux.
C
170
star
7

mfrc522

MFRC522 full function driver for general MCU and Linux.
C
157
star
8

mifare_classic

MIFARE Classic full function driver for general MCU and Linux.
C
155
star
9

ws2812b

WS2812B full function driver for general MCU and Linux.
C
153
star
10

dht11

DHT11 full function driver for general MCU and Linux.
C
139
star
11

pcf8574

PCF8574 full function driver for general MCU and Linux.
C
109
star
12

max7219

MAX7219 full function driver for general MCU and Linux.
C
96
star
13

max30102

MAX30102 full function driver for general MCU and Linux.
C
95
star
14

nrf905

NRF905 full function driver for general MCU and Linux.
C
94
star
15

as5600

AS5600 full function driver for general MCU and Linux.
C
86
star
16

hmc5883l

HMC5883L full function driver for general MCU and Linux.
C
79
star
17

amg8833

AMG8833 full function driver for general MCU and Linux.
C
79
star
18

bmp180

BMP180 full function driver for general MCU and Linux.
C
75
star
19

pca9685

PCA9685 full function driver for general MCU and Linux.
C
70
star
20

hx711

HX711 full function driver for general MCU and Linux.
C
66
star
21

ds3231

DS3231 full function driver for general MCU and Linux.
C
64
star
22

htu21d

HTU21D full function driver for general MCU and Linux.
C
63
star
23

tea5767

TEA5767 full function driver for general MCU and Linux.
C
62
star
24

ir_remote

NEC IR remote decode full function driver for general MCU and Linux.
C
60
star
25

bh1750fvi

BH1750FVI full function driver for general MCU and Linux.
C
54
star
26

ms5837

MS5837 full function driver for general MCU and Linux.
C
52
star
27

max31865

MAX31865 full function driver for general MCU and Linux.
C
51
star
28

mifare_ultralight

MIFARE Ultralight full function driver for general MCU and Linux.
C
51
star
29

ads1115

ADS1115 full function driver for general MCU and Linux.
C
43
star
30

ssd1351

SSD1351 full function driver for general MCU and Linux.
C
40
star
31

sx1268

SX1268 full function driver for general MCU and Linux.
C
40
star
32

max30105

MAX30105 full function driver for general MCU and Linux.
C
39
star
33

st7920

ST7920 full function driver for general MCU and Linux.
C
39
star
34

sps30

SPS30 full function driver for general MCU and Linux.
C
36
star
35

sgp30

SGP30 full function driver for general MCU and Linux.
C
35
star
36

tsl2561

TSL2561 full function driver for general MCU and Linux.
C
35
star
37

pcf8591

PCF8591 full function driver for general MCU and Linux.
C
34
star
38

at24cxx

AT24CXX full function driver for general MCU and Linux.
C
32
star
39

ntag21x

NTAG21X full function driver for general MCU and Linux.
C
32
star
40

sht31

SHT31 full function driver for general MCU and Linux.
C
31
star
41

max6675

MAX6675 full function driver for general MCU and Linux.
C
31
star
42

ina219

INA219 full function driver for general MCU and Linux.
C
30
star
43

hcsr04

HCSR04 full function driver for general MCU and Linux.
C
27
star
44

l3gd20h

L3GD20H full function driver for general MCU and Linux.
C
25
star
45

apds9960

APDS9960 full function driver for general MCU and Linux.
C
25
star
46

mcp9600

MCP9600 full function driver for general MCU and Linux.
C
24
star
47

ld3320

LD3320 full function driver for general MCU and Linux.
C
24
star
48

mlx90614

MLX90614 full function driver for general MCU and Linux.
C
24
star
49

pmw3901mb

PMW3901MB full function driver for general MCU and Linux.
C
23
star
50

isd17xx

ISD17XX full function driver for general MCU and Linux.
C
22
star
51

aht20

AHT20 full function driver for general MCU and Linux.
C
22
star
52

dht20

DHT20 full function driver for general MCU and Linux.
C
21
star
53

max30205

MAX30205 full function driver for general MCU and Linux.
C
20
star
54

tcs34725

TCS34725 full function driver for general MCU and Linux.
C
20
star
55

syn6288

SYN6288 full function driver for general MCU and Linux.
C
19
star
56

bmp390

BMP390 full function driver for general MCU and Linux.
C
18
star
57

mcp4725

MCP4725 full function driver for general MCU and Linux.
C
18
star
58

bmp388

BMP388 full function driver for general MCU and Linux.
C
16
star
59

uvis25

UVIS25 full function driver for general MCU and Linux.
C
15
star
60

adxl362

ADXL362 full function driver for general MCU and Linux.
C
15
star
61

lm75b

LM75B full function driver for general MCU and Linux.
C
15
star
62

fm24clxx

FM24CLXX full function driver for general MCU and Linux.
C
15
star
63

ssd1681

SSD1681 full function driver for general MCU and Linux.
C
12
star
64

sgp41

SGP41 full function driver for general MCU and Linux.
C
4
star
65

sgp40

SGP40 full function driver for general MCU and Linux.
C
1
star
66

lan8720

LAN8720 full function driver for general MCU and Linux.
C
1
star
67

ch9121

CH9121 full function driver for general MCU and Linux.
C
1
star
68

em4100

EM4100 full function driver library for general MCU and Linux.
C
1
star