Struct ftdi_embedded_hal::I2c
source · [−]pub struct I2c<'a, Device: MpsseCmdExecutor> { /* private fields */ }
Expand description
FTDI I2C interface.
This is created by calling FtHal::i2c
.
Implementations
sourceimpl<'a, Device, E> I2c<'a, Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
impl<'a, Device, E> I2c<'a, Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
sourcepub fn set_stop_start_len(&mut self, start_stop_cmds: u8)
pub fn set_stop_start_len(&mut self, start_stop_cmds: u8)
Set the length of start and stop conditions.
This is an advanced feature that most people will not need to touch. I2C start and stop conditions are generated with a number of MPSSE commands. This sets the number of MPSSE command generated for each stop and start condition. An increase in the number of MPSSE commands roughtly correlates to an increase in the duration.
Example
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 i2c = hal.i2c()?;
i2c.set_stop_start_len(10);
sourcepub fn set_fast(&mut self, fast: bool)
pub fn set_fast(&mut self, fast: bool)
Enable faster I2C transactions by sending commands in a single write.
This is disabled by default.
Normally the I2C methods will send commands with a delay after each
slave ACK to read from the USB device.
Enabling this will send I2C commands without a delay, but slave ACKs
will only be checked at the end of each call to read
, write
, or
write_read
.
Example
use ftdi_embedded_hal as hal;
let device = ftdi::find_by_vid_pid(0x0403, 0x6014)
.interface(ftdi::Interface::A)
.open()?;
let hal = hal::FtHal::init_freq(device, 3_000_000)?;
let mut i2c = hal.i2c()?;
i2c.set_fast(true);
Trait Implementations
sourceimpl<'a, Device: Debug + MpsseCmdExecutor> Debug for I2c<'a, Device>
impl<'a, Device: Debug + MpsseCmdExecutor> Debug for I2c<'a, Device>
sourceimpl<'a, Device, E> Read<u8> for I2c<'a, Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
impl<'a, Device, E> Read<u8> for I2c<'a, Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
sourceimpl<'a, Device, E> Write<u8> for I2c<'a, Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
impl<'a, Device, E> Write<u8> for I2c<'a, Device>where
Device: MpsseCmdExecutor<Error = E>,
E: Error,
Error<E>: From<E>,
Auto Trait Implementations
impl<'a, Device> RefUnwindSafe for I2c<'a, Device>
impl<'a, Device> Send for I2c<'a, Device>where
Device: Send,
impl<'a, Device> Sync for I2c<'a, Device>where
Device: Send,
impl<'a, Device> Unpin for I2c<'a, Device>
impl<'a, Device> UnwindSafe for I2c<'a, Device>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more