Giter VIP home page Giter VIP logo

embedded-nrf24l01's Introduction

embedded-nrf24l01

Features

  • Designed for use with the embedded-hal crate
  • Safe and declarative register definitions
  • Chip operation modes lifted to the type-level
  • Lets you go straight into RX/TX with the default config

Still missing

  • Auto-ack support

Reference datasheets

Usage

Parameters

Get the *-hal crate for your micro-controller unit. Figure out how to get to the peripherals implementing these embedded-hal traits:

  • embedded_hal::blocking::spi::Transfer for the SPI peripheral

    We provide a mod setup with a few constants for SPI.

  • embedded_hal::digital::OutputPin for the CE pin

  • embedded_hal::digital::OutputPin for the CSN pin

    (Although that one belongs to the SPI, we found it much more reliable to implement in software.)

Constructor

let mut nrf24 = NRF24L01::new(ce, csn, spi).unwrap();

This will provide an instance of Standby. You can use .rx() or .tx() to transfer into a RXMode and TXMode instances. They implement .standby() methods to get back to Standby and then switch to the other mode.

Configuration

Before you start transmission, the device must be configured. Example:

nrf24.set_channel(8)?;
nrf24.set_auto_retransmit(0, 0)?;
nrf24.set_rf(&nrf24::DataRate::R2Mbps, 3)?;
nrf24.set_pipes_rx_enable(&[true, false, false, false, false, false])?;
nrf24.set_auto_ack(&[false; 6])?;
nrf24.set_crc(&nrf24::CrcMode::Disabled)?;
nrf24.set_tx_addr(&b"fnord"[..])?;

Before first use, it's recommended to call nb::block!(rf24.wait_tx_empty()) to flush after a soft restart.

Use nrf24.wait_rx_ready() to poll (returning the pipe number). Use nrf24.read() to receive a packet.

Use nrf24.wait_tx_ready() to wait for space in tx queue. Use nrf24.send() to enqueue a packet. Use nrf24.wait_tx_empty() to flush the tx queue.

embedded-nrf24l01's People

Contributors

astro avatar rtxm avatar mgottschlag avatar jannic avatar geomatsi avatar diondokter avatar danieldk avatar barafael avatar

Stargazers

Diego Sánchez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.