Struct NRF24L01

Source
pub struct NRF24L01<E: Debug, CE: OutputPin<Error = E>, SPI: SpiDevice<u8>> {
    pub spi: SPI,
    /* private fields */
}
Expand description

Driver for the nRF24L01+

Never deal with this directly. Instead, you store one of the following types:

where D: Device

Fields§

§spi: SPI

核心对象spi

Implementations§

Source§

impl<E: Debug, CE: OutputPin<Error = E>, SPI: SpiDevice<u8, Error = SPIE>, SPIE: Debug> NRF24L01<E, CE, SPI>

Source

pub async fn new(ce: CE, spi: SPI) -> Result<StandbyMode<Self>, Error<SPIE>>

Construct a new driver instance.

Source

pub async fn is_connected(&mut self) -> Result<bool, Error<SPIE>>

Reads and validates content of the SETUP_AW register.

Trait Implementations§

Source§

impl<E: Debug, CE: OutputPin<Error = E>, SPI: SpiDevice<u8, Error = SPIE>, SPIE: Debug> Debug for NRF24L01<E, CE, SPI>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: Debug, CE: OutputPin<Error = E>, SPI: SpiDevice<u8, Error = SPIE>, SPIE: Debug> Device for NRF24L01<E, CE, SPI>

Source§

type Error = Error<SPIE>

Error from the SPI implementation
Source§

fn ce_enable(&mut self)

Set CE pin high
Source§

fn ce_disable(&mut self)

Set CE pin low
Source§

async fn send_command<C: Command>( &mut self, command: &C, ) -> Result<(Status, C::Response), Self::Error>

Send a command via SPI
Source§

async fn write_register<R: Register>( &mut self, register: R, ) -> Result<Status, Self::Error>

Send W_REGISTER command
Source§

async fn read_register<R: Register>( &mut self, ) -> Result<(Status, R), Self::Error>

Send R_REGISTER command
Source§

async fn update_config<F, R>(&mut self, f: F) -> Result<R, Self::Error>
where F: FnOnce(&mut Config) -> R,

Modify the (cached) CONFIG register and write if it has changed.
Source§

fn with_ce_disabled<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Helper; the receiving during RX and sending during TX require CE to be low.
Source§

async fn update_register<Reg, F, R>(&mut self, f: F) -> Result<R, Self::Error>
where Reg: Register + PartialEq + Clone, F: FnOnce(&mut Reg) -> R,

Read, and modify a register, and write it back if it has been changed.

Auto Trait Implementations§

§

impl<E, CE, SPI> Freeze for NRF24L01<E, CE, SPI>
where CE: Freeze, SPI: Freeze,

§

impl<E, CE, SPI> RefUnwindSafe for NRF24L01<E, CE, SPI>
where CE: RefUnwindSafe, SPI: RefUnwindSafe,

§

impl<E, CE, SPI> Send for NRF24L01<E, CE, SPI>
where CE: Send, SPI: Send,

§

impl<E, CE, SPI> Sync for NRF24L01<E, CE, SPI>
where CE: Sync, SPI: Sync,

§

impl<E, CE, SPI> Unpin for NRF24L01<E, CE, SPI>
where CE: Unpin, SPI: Unpin,

§

impl<E, CE, SPI> UnwindSafe for NRF24L01<E, CE, SPI>
where CE: UnwindSafe, SPI: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.