pub struct NrfConfig { /* private fields */ }
Expand description
Configuration builder struct for NRF chip.
Always created with the default()
method and modified through
the builder pattern. See module level documentation for all the default values.
§Example: default
use nrf24::Nrf24l01;
use nrf24::config::NrfConfig;
let config = NrfConfig::default();
let mut chip = Nrf24l01::new(spi, ce, delay, config)?;
§Example: custom configuration
use nrf24::Nrf24l01;
use nrf24::config::{PALevel, DataRate, NrfConfig, PayloadSize};
let config = NrfConfig::default()
.payload_size(PayloadSize::Dynamic) // set dynamic payload size
.channel(7)
.addr_width(3),
.data_rate(DataRate::R2Mbps)
.pa_level(PALevel::Max)
.crc_encoding_scheme(EncodingScheme::NoRedundancyCheck) // disable crc
.ack_payloads_enabled(true)
.auto_retry((15, 15));
let mut chip = Nrf24l01::new(spi, ce, delay, config)?;
Implementations§
Source§impl NrfConfig
impl NrfConfig
Sourcepub fn payload_size<T: Into<PayloadSize>>(self, payload_size: T) -> Self
pub fn payload_size<T: Into<PayloadSize>>(self, payload_size: T) -> Self
Set Payload Size
A value of 0 means dynamic payloads will be enabled.
Values greater than MAX_PAYLOAD_SIZE
will be floored.
Sourcepub fn channel(self, channel: u8) -> Self
pub fn channel(self, channel: u8) -> Self
Set RF channel Must be a number in [0..125], values outside will be clipped
Sourcepub fn addr_width<T: Into<AddressWidth>>(self, addr_width: T) -> Self
pub fn addr_width<T: Into<AddressWidth>>(self, addr_width: T) -> Self
Set the Address Width If using a number, it must be in [3..5], values outside will be clipped
Sourcepub fn crc_encoding_scheme(self, crc_encoding_scheme: EncodingScheme) -> Self
pub fn crc_encoding_scheme(self, crc_encoding_scheme: EncodingScheme) -> Self
Set the Cyclic Redundancy Check Encoding Scheme
Sourcepub fn ack_payloads_enabled(self, ack_payloads_enabled: bool) -> Self
pub fn ack_payloads_enabled(self, ack_payloads_enabled: bool) -> Self
Configure if auto acknowledgements are enabled
Sourcepub fn auto_retry<T: Into<AutoRetransmission>>(self, auto_retry: T) -> Self
pub fn auto_retry<T: Into<AutoRetransmission>>(self, auto_retry: T) -> Self
Set the automatic retransmission config
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NrfConfig
impl RefUnwindSafe for NrfConfig
impl Send for NrfConfig
impl Sync for NrfConfig
impl Unpin for NrfConfig
impl UnwindSafe for NrfConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more