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

pub struct Wrapper<Spi, SpiError, OutputPin, InputPin, PinError> { /* fields omitted */ }

Wrapper wraps an Spi and Pin object to support transactions

Methods

impl<Spi, SpiError, Output, Input, PinError> Wrapper<Spi, SpiError, Output, Input, PinError> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
    Output: OutputPin<Error = PinError>,
    Input: InputPin<Error = PinError>, 
[src]

pub fn new(spi: Spi, cs: Output) -> Self[src]

Create a new wrapper object with the provided SPI and pin

pub fn with_busy(&mut self, busy: Input)[src]

Add a busy input to the wrapper object

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

impl<Spi, SpiError, Output, Input, PinError> Wrapper<Spi, SpiError, Output, Input, PinError> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
    Output: OutputPin<Error = PinError>,
    Input: InputPin<Error = PinError>, 
[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, Output, Input, PinError> Cursed for Wrapper<Spi, SpiError, Output, Input, PinError>[src]

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

impl<Spi, SpiError, Output, Input, PinError> Transactional for Wrapper<Spi, SpiError, Output, Input, PinError> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
    Output: OutputPin<Error = PinError>,
    Input: InputPin<Error = PinError>, 
[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

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

Check if the peripheral is currently busy This will panic if not busy pin is bound

impl<Spi: Clone, SpiError: Clone, OutputPin: Clone, InputPin: Clone, PinError: Clone> Clone for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<Spi: Debug, SpiError: Debug, OutputPin: Debug, InputPin: Debug, PinError: Debug> Debug for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError>[src]

impl<Spi: PartialEq, SpiError: PartialEq, OutputPin: PartialEq, InputPin: PartialEq, PinError: PartialEq> PartialEq<Wrapper<Spi, SpiError, OutputPin, InputPin, PinError>> for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError>[src]

impl<Spi, SpiError, Output, Input, PinError> Transfer<u8> for Wrapper<Spi, SpiError, Output, Input, PinError> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
    Output: OutputPin<Error = PinError>,
    Input: InputPin<Error = PinError>, 
[src]

type Error = SpiError

Error type

impl<Spi, SpiError, Output, Input, PinError> Write<u8> for Wrapper<Spi, SpiError, Output, Input, PinError> where
    Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
    Output: OutputPin<Error = PinError>,
    Input: InputPin<Error = PinError>, 
[src]

type Error = SpiError

Error type

Auto Trait Implementations

impl<Spi, SpiError, OutputPin, InputPin, PinError> Send for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError> where
    InputPin: Send,
    OutputPin: Send,
    PinError: Send,
    Spi: Send,
    SpiError: Send

impl<Spi, SpiError, OutputPin, InputPin, PinError> Sync for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError> where
    InputPin: Sync,
    OutputPin: Sync,
    PinError: Sync,
    Spi: Sync,
    SpiError: Sync

Blanket Implementations

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> 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> Into<U> for T where
    U: From<T>, 
[src]

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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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

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

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

Error type

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

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

Error type

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

type Owned = T

The resulting type after obtaining ownership.