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

FTxxx device.

Implementations§

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 ftdi_embedded_hal as hal;

let device = libftd2xx::Ft232h::with_description("Single RS232-HS")?;
let hal = hal::FtHal::init_default(device)?;

Initialize the FTDI MPSSE with sane defaults and custom frequency

Example
use ftdi_embedded_hal as hal;

let device = libftd2xx::Ft232h::with_description("Single RS232-HS")?;
let hal = hal::FtHal::init_freq(device, 3_000_000)?;

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 ftdi_embedded_hal as hal;
use ftdi_mpsse::MpsseSettings;
use std::time::Duration;

let mpsse = MpsseSettings {
    reset: false,
    in_transfer_size: 4096,
    read_timeout: Duration::from_secs(5),
    write_timeout: Duration::from_secs(5),
    latency_timer: Duration::from_millis(32),
    mask: 0x00,
    clock_frequency: Some(400_000),
};

let device = libftd2xx::Ft232h::with_description("Single RS232-HS")?;
let hal = hal::FtHal::init(device, &mpsse)?;

Aquire the SPI peripheral for the FT232H.

Pin assignments:

  • AD0 => SCK
  • AD1 => MOSI
  • AD2 => MISO
Panics

Panics if pin 0, 1, or 2 are already in use.

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 spi = hal.spi()?;

Aquire the SPI peripheral with a chip select pin.

This is specific to embedded-hal version 1.

Pin assignments:

  • AD0 => SCK
  • AD1 => MOSI
  • AD2 => MISO
Panics

Panics if pin 0, 1, 2 or the CS pin are already in use.

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 spi = hal.spi_device(3)?;

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 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 i2c = hal.i2c()?;

Aquire the digital output pin 0 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital input pin 0 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital output pin 1 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital input pin 1 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital output pin 2 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital input pin 2 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital output pin 3 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital input pin 3 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital output pin 4 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital input pin 4 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital output pin 5 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital input pin 5 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital output pin 6 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital input pin 6 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital output pin 7 for the FT232H.

Panics

Panics if the pin is already in-use.

Aquire the digital input pin 7 for the FT232H.

Panics

Panics if the pin is already in-use.

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.