[][src]Struct embedded_spi::wrapper::Wrapper

pub struct Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> { /* fields omitted */ }

Wrapper wraps an Spi and Pin object to support transactions

Methods

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
    CsPin: OutputPin<Error = PinError>,
    Delay: DelayMs<u32>, 
[src]

pub fn new(
    spi: Spi,
    cs: CsPin,
    busy: BusyPin,
    ready: ReadyPin,
    reset: ResetPin,
    delay: Delay
) -> Self
[src]

Create a new wrapper object with the provided SPI and pin

pub fn pin_write<P>(&mut self, pin: &mut P, value: bool) -> i32 where
    P: OutputPin<Error = PinError>, 
[src]

Write to a Pin instance while wrapping and storing the error internally This returns 0 for success or -1 for errors

pub fn pin_read<P>(&mut self, pin: &mut P) -> i32 where
    P: InputPin<Error = PinError>, 
[src]

Write to a Pin instance while wrapping and storing the error internally This returns 0 for low, 1 for high, and -1 for errors

pub fn check_error(&mut self) -> Result<(), Error<SpiError, PinError>>[src]

Check the internal error state of the peripheral This provides a mechanism to retrieve the rust error if an error occurs during an FFI call, and clears the internal error state

pub fn free(self) -> (Spi, CsPin, BusyPin, ReadyPin, ResetPin)[src]

Return hardware resources for reuse

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
    CsPin: OutputPin<Error = PinError>,
    Delay: DelayMs<u32>, 
[src]

pub extern "C" fn ffi_spi_write(
    ctx: *mut c_void,
    prefix: *mut u8,
    prefix_len: u16,
    data: *mut u8,
    data_len: u16
) -> isize
[src]

C FFI compatible spi_write function for dependency injection

pub extern "C" fn ffi_spi_read(
    ctx: *mut c_void,
    prefix: *mut u8,
    prefix_len: u16,
    data: *mut u8,
    data_len: u16
) -> isize
[src]

C FFI compatible spi_read function for dependency injection

Trait Implementations

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Busy for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    BusyPin: InputPin<Error = PinError>, 
[src]

type Error = Error<SpiError, PinError>

fn get_busy(&mut self) -> Result<PinState, Self::Error>[src]

Fetch the busy pin state

impl<Spi: Clone, SpiError: Clone, CsPin: Clone, BusyPin: Clone, ReadyPin: Clone, ResetPin: Clone, PinError: Clone, Delay: Clone> Clone for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>[src]

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Cursed for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>[src]

Mark Wrapper as a c u r s e d type to allow C coercion

impl<Spi: Debug, SpiError: Debug, CsPin: Debug, BusyPin: Debug, ReadyPin: Debug, ResetPin: Debug, PinError: Debug, Delay: Debug> Debug for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>[src]

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> DelayMs<u32> for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    Delay: DelayMs<u32>, 
[src]

fn delay_ms(&mut self, ms: u32)[src]

Set the reset pin state

impl<Spi: PartialEq, SpiError: PartialEq, CsPin: PartialEq, BusyPin: PartialEq, ReadyPin: PartialEq, ResetPin: PartialEq, PinError: PartialEq, Delay: PartialEq> PartialEq<Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>> for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>[src]

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Ready for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    ReadyPin: InputPin<Error = PinError>, 
[src]

type Error = Error<SpiError, PinError>

fn get_ready(&mut self) -> Result<PinState, Self::Error>[src]

Fetch the ready pin state

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Reset for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    ResetPin: OutputPin<Error = PinError>, 
[src]

type Error = Error<SpiError, PinError>

fn set_reset(&mut self, state: PinState) -> Result<(), Self::Error>[src]

Set the reset pin state

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> StructuralPartialEq for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>[src]

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Transactional for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
    CsPin: OutputPin<Error = PinError>,
    Delay: DelayMs<u32>, 
[src]

type Error = Error<SpiError, PinError>

fn spi_read<'a>(
    &mut self,
    prefix: &[u8],
    data: &'a mut [u8]
) -> Result<(), Self::Error>
[src]

Read data from a specified address This consumes the provided input data array and returns a reference to this on success

fn spi_write(&mut self, prefix: &[u8], data: &[u8]) -> Result<(), Self::Error>[src]

Write data to a specified register address

fn spi_exec(
    &mut self,
    transactions: &mut [Transaction]
) -> Result<(), Self::Error>
[src]

Execute the provided transactions

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Transfer<u8> for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>, 
[src]

type Error = SpiError

Error type

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Write<u8> for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>, 
[src]

type Error = SpiError

Error type

Auto Trait Implementations

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> RefUnwindSafe for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    BusyPin: RefUnwindSafe,
    CsPin: RefUnwindSafe,
    Delay: RefUnwindSafe,
    PinError: RefUnwindSafe,
    ReadyPin: RefUnwindSafe,
    ResetPin: RefUnwindSafe,
    Spi: RefUnwindSafe,
    SpiError: RefUnwindSafe

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Send for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    BusyPin: Send,
    CsPin: Send,
    Delay: Send,
    PinError: Send,
    ReadyPin: Send,
    ResetPin: Send,
    Spi: Send,
    SpiError: Send

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Sync for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    BusyPin: Sync,
    CsPin: Sync,
    Delay: Sync,
    PinError: Sync,
    ReadyPin: Sync,
    ResetPin: Sync,
    Spi: Sync,
    SpiError: Sync

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Unpin for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    BusyPin: Unpin,
    CsPin: Unpin,
    Delay: Unpin,
    PinError: Unpin,
    ReadyPin: Unpin,
    ResetPin: Unpin,
    Spi: Unpin,
    SpiError: Unpin

impl<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> UnwindSafe for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
    BusyPin: UnwindSafe,
    CsPin: UnwindSafe,
    Delay: UnwindSafe,
    PinError: UnwindSafe,
    ReadyPin: UnwindSafe,
    ResetPin: UnwindSafe,
    Spi: UnwindSafe,
    SpiError: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T where
    T: Cursed
[src]

fn to_c_ptr(&mut Self) -> *mut c_void[src]

Generate a C void pointer that can be re-cast into this object

fn from_c_ptr<'a>(*mut c_void) -> &'a mut T[src]

Cast a C void pointer created by to_c_ptr back into this object

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<W, S> Transfer<W> for S where
    S: Default<W>,
    W: Clone
[src]

type Error = <S as FullDuplex<W>>::Error

Error type

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<W, S> Write<W> for S where
    S: Default<W>,
    W: Clone
[src]

type Error = <S as FullDuplex<W>>::Error

Error type