Skip to content

everedero/zephyr_driver_propyradio

Repository files navigation

Zephyr out-of-tree driver for nRF24L01 SPI 2.4GHz remote control module

This repository contains a Zephyr out-of-tree driver.

This repository is versioned together with the Zephyr main tree. This means that every time that Zephyr is tagged, this repository is tagged as well with the same version number, and the manifest entry for zephyr will point to the corresponding Zephyr tag. For example, the example-application v2.6.0 will point to Zephyr v2.6.0. Note that the main branch always points to the development branch of Zephyr, also main.

Getting Started

Before getting started, make sure you have a proper Zephyr development environment. Follow the official Zephyr Getting Started Guide.

Initialization

The first step is to initialize the workspace folder (my-workspace) where the application and all Zephyr modules will be cloned. Run the following command:

# initialize my-workspace for the example-application (main branch)
west init -m https://github.com/everedero/driver_nrf24l01 --mr main my-workspace
# update Zephyr modules
cd my-workspace
west update

This has been tested with Zephyr 3.5.99

Building and running

To build the application, run the following command:

west build -b $BOARD -p always app -- -DOVERLAY_CONFIG=prj.conf

where $BOARD is the target board.

BOARD="nucleo_f756zg"
BOARD="nrf52dk_nrf52832"
BOARD="esp32_devkitc_wroom"

In order to activate debug logs:

west build -b $BOARD -p always app -- -DOVERLAY_CONFIG=debug.conf

Once you have built the application, run the following command to flash it:

west flash

For more detailed information, see the example app Readme

Testing

To execute Twister integration tests, run the following command:

west twister -T tests --integration

This only tests correct compilation under 3 different platforms, it does not run tests on target or emulator.

API reference

This driver uses a minimalist custom API.

Read

int nrf24_read(const struct device *dev, uint8_t *buffer, uint8_t data_len)

This methods reads data_len bytes from the device dev, and places it in buffer. In trigger mode, if NRF24L01_READ_TIMEOUT is exceeded, the function times out.

In polling mode, it will loop forever.

Write

int nrf24_write(const struct device *dev, uint8_t *buffer, uint8_t data_len)

This methods writes data_len bytes from buffer, and sends it through device dev. In trigger mode, if NRF24L01_WRITE_TIMEOUT is exceeded, the function times out.

In polling mode, it will loop forever.

Troubleshooting

No RX received

  • Verify your device tree
  • Verify CE GPIO is active high and IRQ active low.

Issue with SPI read/write

Write in a register and read it.

  • Verify NRF24 is correctly plugged
  • Verify it is power supplied correctly
  • Verify the incoming SPI data is correct

About

Zephyr out-of-tree driver for proprietary 2.4 GHz radio chips

Topics

Resources

License

Stars

Watchers

Forks