Struct Spi

Source
pub struct Spi<Device: MpsseCmdExecutor> { /* private fields */ }
Expand description

FTDI SPI bus.

In embedded-hal version 1 this represents an exclusive SPI bus.

This is created by calling FtHal::spi.

Implementations§

Source§

impl<Device, E> Spi<Device>
where Device: MpsseCmdExecutor<Error = E>, E: Error, Error<E>: From<E>,

Source

pub fn set_clock_polarity<P: Into<Polarity>>(&mut self, cpol: P)

Set the SPI clock polarity.

FTD2XX devices only supports SPI mode 0 and 2, clock phase is fixed.

§Example
use eh1::spi::Polarity;
use ftdi_embedded_hal as hal;

let device = libftd2xx::Ft2232h::with_description("Dual RS232-HS A")?;
let hal = hal::FtHal::init_freq(device, 3_000_000)?;
let mut spi = hal.spi()?;
spi.set_clock_polarity(Polarity::IdleLow);

Trait Implementations§

Source§

impl<Device: Debug + MpsseCmdExecutor> Debug for Spi<Device>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Device, E> ErrorType for Spi<Device>
where Device: MpsseCmdExecutor<Error = E>, E: Error, Error<E>: From<E>,

Source§

type Error = Error<E>

Error type.
Source§

impl<Device, E> FullDuplex for Spi<Device>
where Device: MpsseCmdExecutor<Error = E>, E: Error, Error<E>: From<E>,

Source§

fn read(&mut self) -> Result<u8, Error<E>>

Reads the word stored in the shift register Read more
Source§

fn write(&mut self, byte: u8) -> Result<(), Error<E>>

Writes a word to the slave
Source§

impl<Device, E> SpiBus for Spi<Device>
where Device: MpsseCmdExecutor<Error = E>, E: Error, Error<E>: From<E>,

Source§

fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error>

Read words from the slave. Read more
Source§

fn write(&mut self, words: &[u8]) -> Result<(), Error<E>>

Write words to the slave, ignoring all the incoming words. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Wait until all operations have completed and the bus is idle. Read more
Source§

fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Error<E>>

Write and read simultaneously. The contents of words are written to the slave, and the received words are stored into the same words buffer, overwriting it. Read more
Source§

fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Error<E>>

Write and read simultaneously. write is written to the slave on MOSI and words received on MISO are stored in read. Read more
Source§

impl<Device, E> Transfer<u8> for Spi<Device>
where Device: MpsseCmdExecutor<Error = E>, E: Error, Error<E>: From<E>,

Source§

type Error = Error<E>

Error type
Source§

fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Error<E>>

Sends words to the slave. Returns the words received from the slave
Source§

impl<Device, E> Write<u8> for Spi<Device>
where Device: MpsseCmdExecutor<Error = E>, E: Error, Error<E>: From<E>,

Source§

type Error = Error<E>

Error type
Source§

fn write(&mut self, words: &[u8]) -> Result<(), Error<E>>

Sends words to the slave, ignoring all the incoming words
Source§

impl<Device, E> FullDuplex<u8> for Spi<Device>
where Device: MpsseCmdExecutor<Error = E>, E: Error, Error<E>: From<E>,

Source§

type Error = Error<E>

An enumeration of SPI errors
Source§

fn read(&mut self) -> Result<u8, Error<E>>

Reads the word stored in the shift register Read more
Source§

fn send(&mut self, byte: u8) -> Result<(), Error<E>>

Sends a word to the slave

Auto Trait Implementations§

§

impl<Device> Freeze for Spi<Device>

§

impl<Device> RefUnwindSafe for Spi<Device>

§

impl<Device> Send for Spi<Device>
where Device: Send,

§

impl<Device> Sync for Spi<Device>
where Device: Send,

§

impl<Device> Unpin for Spi<Device>

§

impl<Device> UnwindSafe for Spi<Device>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.