Crates.io | nrf24radio |
lib.rs | nrf24radio |
version | 0.1.0 |
source | src |
created_at | 2023-10-04 13:06:28.053321 |
updated_at | 2023-10-04 13:06:28.053321 |
description | Asynchronous embedded driver for NRF24L01(+) devices |
homepage | |
repository | https://github.com/micro-rust/nrf24radio |
max_upload_size | |
id | 992279 |
size | 77,708 |
nrf24radio
is an async, no-std
and executor agnostic device driver for NRF24L01 and NRF24L01+ devices.
It provides both high level and low level APIs to interact with the radio devices.
To add this library to your project simple execute the cargo
command
cargo add nrf24radio
The drivers are split into two main abstractions: driver handle and data pipes. This split decouples the driver logic from the data transmission logic, simplifying the development process.
Please see our showcase examples here for some common use cases of this library.
To run an example navigate to the folder of the MCU you are using (e.g. rp
for RP2040) and run the command
cargo run --release --bin <example>
to run the example using probe-run
or
cargo build --release --bin <example>
to build it and the run it with your runner of choice.
Driver handles contain all the logic to configure and interact with the NRF24 device. They can set the RF configuration, create data pipes and handle errors in the device, but do not interact with the actual data being transmitted.
Driver handle tasks are more complex tasks that require some care when interacting with the devices. There are examples of these tasks in the examples folder.
Data pipes are simplified abstraction over buffers that can send or receive data through the NRF24 devices. These pipes have a simple API to interact with this data and be notified of errors during communication.
async fn send(mut pipe: TXDataPipe) {
// Buffer to send.
let buf = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F];
// This flag indicates if the radio must expect and acknowledgement from the receiver.
let ack = true;
// Send the data packet.
if let Err(_) = pipe.send( &buf, ack ).await {
// If there was an error handle it here.
}
}
This library and its examples are licensed under
Contributions to this project will fall under the same license as defined above.