Struct NrfConfig

Source
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

Source

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.

Source

pub fn channel(self, channel: u8) -> Self

Set RF channel Must be a number in [0..125], values outside will be clipped

Source

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

Source

pub fn data_rate(self, data_rate: DataRate) -> Self

Set the Data Rate

Source

pub fn pa_level(self, pa_level: PALevel) -> Self

Set the Power Amplification Level

Source

pub fn crc_encoding_scheme(self, crc_encoding_scheme: EncodingScheme) -> Self

Set the Cyclic Redundancy Check Encoding Scheme

Source

pub fn ack_payloads_enabled(self, ack_payloads_enabled: bool) -> Self

Configure if auto acknowledgements are enabled

Source

pub fn auto_retry<T: Into<AutoRetransmission>>(self, auto_retry: T) -> Self

Set the automatic retransmission config

Trait Implementations§

Source§

impl Clone for NrfConfig

Source§

fn clone(&self) -> NrfConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for NrfConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for NrfConfig

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.