Struct ftdi_embedded_hal::SpiDevice
source · pub struct SpiDevice<Device: MpsseCmdExecutor> { /* private fields */ }
Expand description
FTDI SPI device, a SPI bus with chip select pin.
This is created by calling FtHal::spi_device
.
This is specific to embedded-hal version 1.
Implementations§
source§impl<Device, E> SpiDevice<Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
impl<Device, E> SpiDevice<Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
sourcepub fn set_clock_polarity<P: Into<Polarity>>(&mut self, cpol: P)
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_device(3)?;
spi.set_clock_polarity(Polarity::IdleLow);
Trait Implementations§
source§impl<'a, Device, E> ErrorType for &'a SpiDevice<Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
impl<'a, Device, E> ErrorType for &'a SpiDevice<Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
source§impl<'a, Device, E> SpiDevice for &'a SpiDevice<Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
impl<'a, Device, E> SpiDevice for &'a SpiDevice<Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
source§fn transaction<R>(
&mut self,
f: impl FnOnce(&mut Self::Bus) -> Result<R, <Self::Bus as ErrorType>::Error>
) -> Result<R, Self::Error>
fn transaction<R>(
&mut self,
f: impl FnOnce(&mut Self::Bus) -> Result<R, <Self::Bus as ErrorType>::Error>
) -> Result<R, Self::Error>
Perform a transaction against the device. Read more
source§fn write<Word>(&mut self, buf: &[Word]) -> Result<(), Self::Error>where
Self::Bus: SpiBusWrite<Word>,
Word: Copy,
fn write<Word>(&mut self, buf: &[Word]) -> Result<(), Self::Error>where
Self::Bus: SpiBusWrite<Word>,
Word: Copy,
Do a write within a transaction. Read more
source§fn read<Word>(&mut self, buf: &mut [Word]) -> Result<(), Self::Error>where
Self::Bus: SpiBusRead<Word>,
Word: Copy,
fn read<Word>(&mut self, buf: &mut [Word]) -> Result<(), Self::Error>where
Self::Bus: SpiBusRead<Word>,
Word: Copy,
Do a read within a transaction. Read more