Struct nrf24l01::NRF24L01 [] [src]

pub struct NRF24L01 { /* fields omitted */ }

The driver

Methods

impl NRF24L01
[src]

[src]

Construct a new driver instance.

  • ce_pin: the GPIO number (Linux SysFS) connected to the CE pin of the transceiver
  • spi_device: the SPI device number (or channel) the transceiver is connected to.

We use the spidev linux kernel driver. Ensure you have enabled SPI on your system.

Errors

System IO errors

[src]

Configure the device as Primary Receiver (PRX) or Primary Transmitter (PTX), set all its properties for proper operation and power it up.

The device remain in standby until self.listen() (RX mode) or self.send() (TX mode) is called.

All commands work when the device is in standby (recommended) as well as active state.

[src]

[src]

Power down the device.

The power consumption is minimum in this mode, and the device ceases all operation. It only accepts configuration commands.

[src]

Power the device up for full operation.

[src]

Put the device in standby (RX Mode)

Only used in RX mode to suspend active listening. In TX mode, standby is the default state when not sending data.

[src]

(RX mode only) Wake up and activate receiver.

In RX mode, call this function after a .configure(...), .standby() or power_up() to accept incoming packets.

[src]

Is there any incoming data to read?

Works in both RX and TX modes. In TX mode, this function returns true if a ACK payload has been received.

[src]

Read data from the receiver queue, one packet at a time.

The process_packet callback is fired for each packet, and is passed a slice into the packet data as argument.

read_all returns the number of messages read.

Note: this function puts the device in standby mode during the processing of the queue and restores operations when it returns successfully. So the process_packet callback should better return quickly.

[src]

Queue (FIFO) data to be sent, one packet at a time.

In TX mode, pipe_num is ignored. In RX mode, this function queues an ACK payload for the next message to arrive on pipe_num. if pipe_num is bigger than 5, it is capped to 5.

The maximum size for a packet is 32 bytes.

You can store a maximun of 3 payloads in the FIFO queue.

Note : The payloads remain in the queue until the end of an Enhanced Shockburst ™ transaction:

  • In TX mode, a payload is removed from the send queue if and only if it has been successfully sent, that is, an ACK (with or without payload) has been received for it.

  • In RX mode, an ACK payload is removed from the queue if and only if it has been sent AND the pipe receives a new message, different from the one the ACK payload responded to. This is because the receiver has no mean to know whether the transmitter has received the ACK until it receives a new, different message from the same transmitter. So, it keeps the ACK payload under hand in case the transmitter resends the same packet over again.

[src]

[TX mode only] Send all packets in the TX FIFO queue.

The call blocks until all packets are sent or the device reaches the max_retries number of retries after failure. Return the number of retries in case of success.

The payloads that failed to be sent remain in the TX queue. You can call .send() again to relaunch a send/retry cycle or call .flush_output to clear the queue.

Errors

Return Spidev errors as well as a custom io::ErrorKind::Timeout when the maximun number of retries has been reached.

[src]

Clear input queue.

In RX mode, use only when device is in standby.

[src]

Clear output queue.

In RX mode, use only when device is in standby.