Skip to main content

Wiring

Struct Wiring 

Source
pub struct Wiring {
    pub spi: PathBuf,
    pub spi_hz: u32,
    pub gpio_chip: PathBuf,
    pub reset_line: u32,
    pub busy_line: Option<u32>,
}
Expand description

Where a radio module is wired on a Linux board.

§Examples

use pamoja_radios::linux::{Wiring, DEFAULT_SPI_HZ};

// An SX1262 board on SPI0's second chip select, BUSY on GPIO24 and reset on GPIO25.
let wiring = Wiring::new("/dev/spidev0.1", "/dev/gpiochip0", 25).with_busy_line(24);
assert_eq!(wiring.busy_line, Some(24));
assert_eq!(wiring.spi_hz, DEFAULT_SPI_HZ);

Fields§

§spi: PathBuf

The SPI device file, one per chip select, such as /dev/spidev0.0.

§spi_hz: u32

The SPI clock in hertz.

§gpio_chip: PathBuf

The GPIO chip the lines are on, /dev/gpiochip0 for a Raspberry Pi’s header.

§reset_line: u32

The line the module’s reset pin is on: its offset on the chip, which on a Raspberry Pi is the BCM GPIO number.

§busy_line: Option<u32>

The line an SX126x’s BUSY pin is on. The SX127x has no BUSY pin.

Implementations§

Source§

impl Wiring

Source

pub fn new( spi: impl Into<PathBuf>, gpio_chip: impl Into<PathBuf>, reset_line: u32, ) -> Wiring

Describes a module on an SPI device with its reset pin on a GPIO line, clocked at DEFAULT_SPI_HZ and with no BUSY line.

§Arguments
  • spi - the SPI device file.
  • gpio_chip - the GPIO chip the lines are on.
  • reset_line - the line the reset pin is on.
§Returns

The wiring.

Source

pub fn with_busy_line(self, line: u32) -> Wiring

Returns the wiring with an SX126x’s BUSY pin on a line.

§Arguments
  • line - the line the BUSY pin is on.
§Returns

The wiring.

Source

pub fn with_spi_hz(self, hz: u32) -> Wiring

Returns the wiring with another SPI clock.

§Arguments
  • hz - the clock in hertz.
§Returns

The wiring.

Trait Implementations§

Source§

impl Clone for Wiring

Source§

fn clone(&self) -> Wiring

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Wiring

Source§

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

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

impl Eq for Wiring

Source§

impl Hash for Wiring

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Wiring

Source§

fn eq(&self, other: &Wiring) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Wiring

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.