Struct ftd2xx_embedded_hal::FtHal [−][src]
pub struct FtHal<Device: FtdiCommon, INITIALIZED> { /* fields omitted */ }
Expand description
FTxxx device.
Implementations
impl<Device: FtdiCommon + TryFrom<Ftdi, Error = DeviceTypeError> + FtdiMpsse> FtHal<Device, Uninitialized>
impl<Device: FtdiCommon + TryFrom<Ftdi, Error = DeviceTypeError> + FtdiMpsse> FtHal<Device, Uninitialized>
Create a new FTxxx structure.
Example
use ftd2xx_embedded_hal as hal; let ftdi = hal::Ft232hHal::new()?.init_default()?;
Create a new FTxxx structure from a serial number.
Example
use ftd2xx_embedded_hal as hal; let ftdi = hal::Ft232hHal::with_serial_number("FT6ASGXH")?.init_default()?;
pub fn with_description(
description: &str
) -> Result<FtHal<Device, Uninitialized>, DeviceTypeError>
pub fn with_description(
description: &str
) -> Result<FtHal<Device, Uninitialized>, DeviceTypeError>
Open a Ftxxx
device by its device description.
Example
use libftd2xx::Ft4232h; Ft4232h::with_description("FT4232H-56Q MiniModule A")?;
Initialize the FTDI MPSSE with sane defaults.
Default values:
- Reset the FTDI device.
- 4k USB transfer size.
- 1s USB read timeout.
- 1s USB write timeout.
- 16ms latency timer.
- 100kHz clock frequency.
Example
use ftd2xx_embedded_hal as hal; use hal::{Ft232hHal, Initialized, Uninitialized}; let ftdi: Ft232hHal<Uninitialized> = hal::Ft232hHal::new()?; let ftdi: Ft232hHal<Initialized> = ftdi.init_default()?;
pub fn init(
self,
mpsse_settings: &MpsseSettings
) -> Result<FtHal<Device, Initialized>, TimeoutError>
pub fn init(
self,
mpsse_settings: &MpsseSettings
) -> Result<FtHal<Device, Initialized>, TimeoutError>
Initialize the FTDI MPSSE with custom values.
Note: The mask
field of MpsseSettings
is ignored for this function.
Note: The clock frequency will be 2/3 of the specified value when in I2C mode.
Panics
Panics if the clock_frequency
field of MpsseSettings
is None
.
Example
use ftd2xx_embedded_hal as hal; use hal::libftd2xx::MpsseSettings; use hal::{Ft232hHal, Initialized, Uninitialized}; let ftdi: Ft232hHal<Uninitialized> = hal::Ft232hHal::new()?; let ftdi: Ft232hHal<Initialized> = ftdi.init(&MpsseSettings { clock_frequency: Some(500_000), ..MpsseSettings::default() })?;
Aquire the I2C peripheral for the FT232H.
Pin assignments:
- AD0 => SCL
- AD1 => SDA
- AD2 => SDA
Yes, AD1 and AD2 are both SDA. These pins must be shorted together for I2C operation.
Panics
Panics if pin 0, 1, or 2 are already in use.
Example
use ftd2xx_embedded_hal as hal; let ftdi = hal::Ft232hHal::new()?.init_default()?; let mut i2c = ftdi.i2c()?;
Trait Implementations
Create a new FT232H structure from a specific FT232H device.
Examples
Selecting a device with a specific serial number.
use ftd2xx_embedded_hal as hal; use hal::libftd2xx::Ft232h; use hal::Ft232hHal; let ft = Ft232h::with_serial_number("FT59UO4C")?; let ftdi = Ft232hHal::from(ft).init_default()?;
Selecting a device with a specific description.
use ftd2xx_embedded_hal as hal; use hal::libftd2xx::Ft232h; use hal::FtHal; let ft = Ft232h::with_description("My device description")?; let ftdi = FtHal::from(ft).init_default()?;