View Source Nrf24.Transciever (nrf24 v1.0.0)
Module for communicating with nRF24L01+ transciever.
It sets up device, by default, to work in ShockBurst mode with ACK (auto acknowledgement) and CRC check enabled.
Link to this section Summary
Functions
Turns auto-acknowledgement on and off.
Returns a channel on which tranciever is working.
Function prints out status of registers. Useful mostly for debugging purposes.
Reads received data of payload_size
size.
Resets device to initial settings.
Resets RX and TX FIFO interrupts and maximum number of TX retrasmits.
Sends data of 1-32 bytes length. Always uses auto acknowledgment.
Sets a channel on which tranciever will receive/send data.
Sets CRC length. Allowed values are 1 or 2.
Sets the size of data to be received on the given pipe.
Sets pipe's address, payload size and enables pipe in en_rxaddr register.
Sets 5-byte address for pipes 0 and 1 (values between 0 and 255) and single byte address for pipes 2-5.
Configures transciever to receive data.
Sets a number of retransmits before trasmit is considered as failed.
Set auto Retransmit Delay ‘0000’ – Wait 250μS ‘0001’ – Wait 500μS ‘0010’ – Wait 750μS ........ ‘1111’ – Wait 4000μS (Delay defined from end of transmission to start of next transmission)
Sets data speed rate.
Sets address on which transciever will transmit data. Trasmit address is 5-bytes long and if auto-acknowledgement is turned on it has to be the same as address of the pipe 0.
Configures transciever to send data.
Configures transciever for receiving data, resets status and powers on transciever.
Powers off transciever and sets CE pin to low.
Link to this section Functions
Turns auto-acknowledgement on and off.
Returns a channel on which tranciever is working.
Function prints out status of registers. Useful mostly for debugging purposes.
Reads received data of payload_size
size.
If data is received on any pipe corresponding value in the status register will be set to pipe number and function will read data from FIFO register.
Function returns map with pipe no on which data was received and received value.
Resets device to initial settings.
Resets RX and TX FIFO interrupts and maximum number of TX retrasmits.
Sends data of 1-32 bytes length. Always uses auto acknowledgment.
Sets a channel on which tranciever will receive/send data.
Sets CRC length. Allowed values are 1 or 2.
Sets the size of data to be received on the given pipe.
Sets pipe's address, payload size and enables pipe in en_rxaddr register.
For pipes 0 and 1 dddress must be 5 bytes length binary, i.e.
<<0xe1, 0xc0, 0x00, 0x01, 0xa0>>
For simpler, easier to remember case, address can be just a five-characters string, i.e.
"Rcvr1"
For pipes 2 to 5 address must be binary consisting of only one integer between 0 and 255.
<<0xce>>
Anything else including binary of different size will fallback to default pipe address.
options
Options
:address
- Pipe address. For first two pipes (0 and 1) it is expected to be 5 integers binary and for pipes 2 to 5 one integer binary. Anything else will just use default pipe addresses.:payload_size
- Pipe payload size in bytes.:auto_acknowledgement
- If false auto acknowledgement for the pipe will be disabled. If nil auto acknowledgement will be enabled by default.
example
Example
# Enable pipe1 with address 0x0a0b0c0d0e and 6 bytes
# payload size
{:ok, spi} = Circuits.SPI.open("spidev0.0")
address = <<0x0a, 0x0b, 0x0c, 0x0d, 0x0e>>
Nrf24.set_pipe(spi, 1, address: address, payload_size: 6)
# Enable pipe 4 with addres 0xa7 and 12 bytes payload size
Nrf24.set_pipe(spi, 4, address: <<0xa7>>, payload_size: 12)
Sets 5-byte address for pipes 0 and 1 (values between 0 and 255) and single byte address for pipes 2-5.
For pipes 0 and 1 it is good practice to set mnemonic pipe address
set_pipe_address(spi, 0, "Recv1")
but address can also be set with 5-byte binary
set_pipe_address(spi, 1, <<0xe7, 0xa0, 0x17, 0x13, 0x25>>)
For pipes 2-5 address is just integer between 0 and 255
set_pipe_address(spi, 4, 147)
Configures transciever to receive data.
Sets a number of retransmits before trasmit is considered as failed.
Set auto Retransmit Delay ‘0000’ – Wait 250μS ‘0001’ – Wait 500μS ‘0010’ – Wait 750μS ........ ‘1111’ – Wait 4000μS (Delay defined from end of transmission to start of next transmission)
Please take care when setting this parameter. If the ACK payload is more than 15 byte in 2Mbps mode the ARD must be 500μS or more, if the ACK payload is more than 5byte in 1Mbps mode the ARD must be 500μS or more. In 250kbps mode (even when the payload is not in ACK) the ARD must be 500μS or more.
Sets data speed rate.
- :low - speed 250Kbps
- :medium - speed 1Mbps
- :high - speed 2Mbps
Sets address on which transciever will transmit data. Trasmit address is 5-bytes long and if auto-acknowledgement is turned on it has to be the same as address of the pipe 0.
Configures transciever to send data.
Configures transciever for receiving data, resets status and powers on transciever.
This function must be called before data is received.
Powers off transciever and sets CE pin to low.
Call this function after data is received.