[−][src]Struct embedded_spi::wrapper::Wrapper
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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
CsPin: OutputPin<Error = PinError>,
Delay: DelayMs<u32>,
pub fn new(
spi: Spi,
cs: CsPin,
busy: BusyPin,
ready: ReadyPin,
reset: ResetPin,
delay: Delay
) -> Self
[src]
spi: Spi,
cs: CsPin,
busy: BusyPin,
ready: ReadyPin,
reset: ResetPin,
delay: Delay
) -> Self
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]
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
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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
CsPin: OutputPin<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, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> Busy for Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay> where
BusyPin: InputPin<Error = PinError>,
[src]
BusyPin: InputPin<Error = PinError>,
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]
fn clone(
&self
) -> Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>
[src]
&self
) -> Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>
fn clone_from(&mut self, source: &Self)
1.0.0[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]
Delay: DelayMs<u32>,
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]
fn eq(
&self,
other: &Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>
) -> bool
[src]
&self,
other: &Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>
) -> bool
fn ne(
&self,
other: &Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>
) -> bool
[src]
&self,
other: &Wrapper<Spi, SpiError, CsPin, BusyPin, ReadyPin, ResetPin, PinError, Delay>
) -> bool
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]
ReadyPin: InputPin<Error = PinError>,
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]
ResetPin: OutputPin<Error = PinError>,
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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
CsPin: OutputPin<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, 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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
type Error = SpiError
Error type
fn transfer<'w>(&mut self, data: &'w mut [u8]) -> Result<&'w [u8], Self::Error>
[src]
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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
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,
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,
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,
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,
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,
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]
T: 'static + ?Sized,
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> 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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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<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> 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<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