Spi

Struct Spi 

Source
pub struct Spi<'a, Device: FtdiCommon> { /* private fields */ }
Expand description

FTDI SPI interface.

This is created by calling FtHal::spi.

Implementations§

Source§

impl<'a, Device: FtdiCommon> Spi<'a, Device>

Source

pub fn set_clock_polarity(&mut self, cpol: Polarity)

Set the SPI clock polarity.

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

§Example
use embedded_hal::spi::Polarity;
use ftd2xx_embedded_hal as hal;

let ftdi = hal::Ft232hHal::new()?.init_default()?;
let mut spi = ftdi.spi()?;
spi.set_clock_polarity(Polarity::IdleLow);

Trait Implementations§

Source§

impl<'a, Device: Debug + FtdiCommon> Debug for Spi<'a, Device>

Source§

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

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

impl<'a, Device: FtdiCommon> Transfer<u8> for Spi<'a, Device>

Source§

type Error = TimeoutError

Error type
Source§

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

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

impl<'a, Device: FtdiCommon> Write<u8> for Spi<'a, Device>

Source§

type Error = TimeoutError

Error type
Source§

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

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

impl<'a, Device: FtdiCommon> FullDuplex<u8> for Spi<'a, Device>

Source§

type Error = TimeoutError

An enumeration of SPI errors
Source§

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

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

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

Sends a word to the slave

Auto Trait Implementations§

§

impl<'a, Device> Freeze for Spi<'a, Device>

§

impl<'a, Device> RefUnwindSafe for Spi<'a, Device>

§

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

§

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

§

impl<'a, Device> Unpin for Spi<'a, Device>

§

impl<'a, Device> UnwindSafe for Spi<'a, 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.