[−][src]Struct embedded_spi::wrapper::Wrapper
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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
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]
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> 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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
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> 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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
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
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(&self) -> 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]
fn eq(
&self,
other: &Wrapper<Spi, SpiError, OutputPin, InputPin, PinError>
) -> bool
[src]
&self,
other: &Wrapper<Spi, SpiError, OutputPin, InputPin, PinError>
) -> bool
fn ne(
&self,
other: &Wrapper<Spi, SpiError, OutputPin, InputPin, PinError>
) -> bool
[src]
&self,
other: &Wrapper<Spi, SpiError, OutputPin, InputPin, PinError>
) -> bool
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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
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> 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]
Spi: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
Output: OutputPin<Error = PinError>,
Input: InputPin<Error = PinError>,
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,
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,
InputPin: Sync,
OutputPin: Sync,
PinError: Sync,
Spi: Sync,
SpiError: Sync,
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> From<T> for T
[src]
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, 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<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
fn write(&mut self, words: &[W]) -> Result<(), <S as FullDuplex<W>>::Error>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,