[−][src]Struct embedded_spi::wrapper::Wrapper
Wrapper wraps an Spi and Pin object to support transactions
Methods
impl<Spi, SpiError, Output, Input, PinError, Delay> Wrapper<Spi, SpiError, Output, Input, PinError, Delay> where
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
[src]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
pub fn new(spi: Spi, cs: Output, delay: Delay) -> 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 with_ready(&mut self, ready: Input)
[src]
Add a ready input to the wrapper object
pub fn with_reset(&mut self, reset: Output)
[src]
Add a reset output to the wrapper object
pub fn pin_write<P>(&mut self, pin: &mut P, value: bool) -> i32 where
P: OutputPin<Error = PinError>,
[src]
P: OutputPin<Error = PinError>,
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]
P: InputPin<Error = PinError>,
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, Delay> Wrapper<Spi, SpiError, Output, Input, PinError, Delay> where
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
[src]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
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]
ctx: *mut c_void,
prefix: *mut u8,
prefix_len: u16,
data: *mut u8,
data_len: u16
) -> isize
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]
ctx: *mut c_void,
prefix: *mut u8,
prefix_len: u16,
data: *mut u8,
data_len: u16
) -> isize
C FFI compatible spi_read function for dependency injection
Trait Implementations
impl<Spi, SpiError, Output, Input, PinError, Delay> Cursed for Wrapper<Spi, SpiError, Output, Input, PinError, Delay>
[src]
Mark Wrapper as a c u r s e d type to allow C coercion
impl<Spi, SpiError, Output, Input, PinError, Delay> Transactional for Wrapper<Spi, SpiError, Output, Input, PinError, Delay> where
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
[src]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
type Error = Error<SpiError, PinError>
fn spi_read<'a>(
&mut self,
prefix: &[u8],
data: &'a mut [u8]
) -> Result<(), Self::Error>
[src]
&mut self,
prefix: &[u8],
data: &'a mut [u8]
) -> Result<(), Self::Error>
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]
&mut self,
transactions: &mut [Transaction]
) -> Result<(), Self::Error>
Execute the provided transactions
impl<Spi, SpiError, Output, Input, PinError, Delay> Busy for Wrapper<Spi, SpiError, Output, Input, PinError, Delay> where
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
[src]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
type Error = Error<SpiError, PinError>
fn get_busy(&mut self) -> Result<PinState, Self::Error>
[src]
Fetch the busy pin state
impl<Spi, SpiError, Output, Input, PinError, Delay> Reset for Wrapper<Spi, SpiError, Output, Input, PinError, Delay> where
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
[src]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
type Error = Error<SpiError, PinError>
fn set_reset(&mut self, state: PinState) -> Result<(), Self::Error>
[src]
Set the reset pin state
impl<Spi, SpiError, Output, Input, PinError, Delay> Ready for Wrapper<Spi, SpiError, Output, Input, PinError, Delay> where
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
[src]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
type Error = Error<SpiError, PinError>
fn get_ready(&mut self) -> Result<PinState, Self::Error>
[src]
Fetch the ready pin state
impl<Spi: PartialEq, SpiError: PartialEq, OutputPin: PartialEq, InputPin: PartialEq, PinError: PartialEq, Delay: PartialEq> PartialEq<Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay>> for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay>
[src]
fn eq(
&self,
other: &Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay>
) -> bool
[src]
&self,
other: &Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay>
) -> bool
fn ne(
&self,
other: &Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay>
) -> bool
[src]
&self,
other: &Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay>
) -> bool
impl<Spi: Debug, SpiError: Debug, OutputPin: Debug, InputPin: Debug, PinError: Debug, Delay: Debug> Debug for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay>
[src]
impl<Spi: Clone, SpiError: Clone, OutputPin: Clone, InputPin: Clone, PinError: Clone, Delay: Clone> Clone for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay>
[src]
fn clone(&self) -> Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<Spi, SpiError, Output, Input, PinError, Delay> DelayMs<u32> for Wrapper<Spi, SpiError, Output, Input, PinError, Delay> where
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
[src]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
impl<Spi, SpiError, Output, Input, PinError, Delay> Transfer<u8> for Wrapper<Spi, SpiError, Output, Input, PinError, Delay> where
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
[src]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
type Error = SpiError
Error type
fn transfer<'w>(&mut self, data: &'w mut [u8]) -> Result<&'w [u8], Self::Error>
[src]
impl<Spi, SpiError, Output, Input, PinError, Delay> Write<u8> for Wrapper<Spi, SpiError, Output, Input, PinError, Delay> where
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
[src]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
Delay: DelayMs<u32>,
Auto Trait Implementations
impl<Spi, SpiError, OutputPin, InputPin, PinError, Delay> Send for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay> where
Delay: Send,
InputPin: Send,
OutputPin: Send,
PinError: Send,
Spi: Send,
SpiError: Send,
Delay: Send,
InputPin: Send,
OutputPin: Send,
PinError: Send,
Spi: Send,
SpiError: Send,
impl<Spi, SpiError, OutputPin, InputPin, PinError, Delay> Sync for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay> where
Delay: Sync,
InputPin: Sync,
OutputPin: Sync,
PinError: Sync,
Spi: Sync,
SpiError: Sync,
Delay: Sync,
InputPin: Sync,
OutputPin: Sync,
PinError: Sync,
Spi: Sync,
SpiError: Sync,
impl<Spi, SpiError, OutputPin, InputPin, PinError, Delay> Unpin for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay> where
Delay: Unpin,
InputPin: Unpin,
OutputPin: Unpin,
PinError: Unpin,
Spi: Unpin,
SpiError: Unpin,
Delay: Unpin,
InputPin: Unpin,
OutputPin: Unpin,
PinError: Unpin,
Spi: Unpin,
SpiError: Unpin,
impl<Spi, SpiError, OutputPin, InputPin, PinError, Delay> UnwindSafe for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay> where
Delay: UnwindSafe,
InputPin: UnwindSafe,
OutputPin: UnwindSafe,
PinError: UnwindSafe,
Spi: UnwindSafe,
SpiError: UnwindSafe,
Delay: UnwindSafe,
InputPin: UnwindSafe,
OutputPin: UnwindSafe,
PinError: UnwindSafe,
Spi: UnwindSafe,
SpiError: UnwindSafe,
impl<Spi, SpiError, OutputPin, InputPin, PinError, Delay> RefUnwindSafe for Wrapper<Spi, SpiError, OutputPin, InputPin, PinError, Delay> where
Delay: RefUnwindSafe,
InputPin: RefUnwindSafe,
OutputPin: RefUnwindSafe,
PinError: RefUnwindSafe,
Spi: RefUnwindSafe,
SpiError: RefUnwindSafe,
Delay: RefUnwindSafe,
InputPin: RefUnwindSafe,
OutputPin: RefUnwindSafe,
PinError: RefUnwindSafe,
Spi: RefUnwindSafe,
SpiError: RefUnwindSafe,
Blanket Implementations
impl<T> Conv for T where
T: Cursed,
[src]
T: Cursed,
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, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<W, S> Transfer<W> for S where
S: Default<W>,
W: Clone,
[src]
S: Default<W>,
W: Clone,
type Error = <S as FullDuplex<W>>::Error
Error type
fn transfer(
&mut self,
words: &'w mut [W]
) -> Result<&'w [W], <S as FullDuplex<W>>::Error>
[src]
&mut self,
words: &'w mut [W]
) -> Result<&'w [W], <S as FullDuplex<W>>::Error>
impl<W, S> Write<W> for S where
S: Default<W>,
W: Clone,
[src]
S: Default<W>,
W: Clone,
type Error = <S as FullDuplex<W>>::Error
Error type