Trait libftd2xx::FtdiMpsse[][src]

pub trait FtdiMpsse: FtdiCommon {
    fn set_clock(&mut self, frequency: u32) -> Result<(), TimeoutError> { ... }
fn initialize_mpsse(
        &mut self,
        settings: &MpsseSettings
    ) -> Result<(), TimeoutError> { ... }
fn initialize_mpsse_default(&mut self) -> Result<(), TimeoutError> { ... }
fn synchronize_mpsse(&mut self) -> Result<(), TimeoutError> { ... }
fn enable_loopback(&mut self) -> Result<(), TimeoutError> { ... }
fn disable_loopback(&mut self) -> Result<(), TimeoutError> { ... }
fn set_gpio_lower(
        &mut self,
        state: u8,
        direction: u8
    ) -> Result<(), TimeoutError> { ... }
fn gpio_lower(&mut self) -> Result<u8, TimeoutError> { ... }
fn set_gpio_upper(
        &mut self,
        state: u8,
        direction: u8
    ) -> Result<(), TimeoutError> { ... }
fn gpio_upper(&mut self) -> Result<u8, TimeoutError> { ... }
fn clock_data_out(
        &mut self,
        mode: ClockDataOut,
        data: &[u8]
    ) -> Result<(), TimeoutError> { ... }
fn clock_data_in(
        &mut self,
        mode: ClockDataIn,
        data: &mut [u8]
    ) -> Result<(), TimeoutError> { ... }
fn clock_data(
        &mut self,
        mode: ClockData,
        data: &mut [u8]
    ) -> Result<(), TimeoutError> { ... } }

FTDI Multi-Protocol Synchronous Serial Engine (MPSSE).

For details about the MPSSE read the FTDI MPSSE Basics.

Provided methods

fn set_clock(&mut self, frequency: u32) -> Result<(), TimeoutError>[src]

Set the clock frequency.

Frequency Limits

Device TypeMinimumMaximum
FT2232D92 Hz6 MHz
FT4232H, FT2232H, FT232H92 Hz30 MHz

Values outside of these limits will result in panic.

Example

use libftd2xx::{Ft4232h, FtdiMpsse};

let mut ft = Ft4232h::with_serial_number("FT4PWSEOA")?;
ft.initialize_mpsse_default()?;
ft.set_clock(100_000)?;

fn initialize_mpsse(
    &mut self,
    settings: &MpsseSettings
) -> Result<(), TimeoutError>
[src]

Initialize the MPSSE.

This method does the following:

  1. Optionally resets the device.
  2. Sets USB transfer sizes using values provided.
  3. Disables special characters.
  4. Sets the transfer timeouts using values provided.
  5. Sets latency timers using values provided.
  6. Sets the flow control to RTS CTS.
  7. Resets the bitmode, then sets it to MPSSE.
  8. Enables loopback.
  9. Synchronizes the MPSSE.
  10. Disables loopback.
  11. Optionally sets the clock frequency.

Upon failure cleanup is not guaranteed.

Example

Initialize the MPSSE with a 5 second read timeout.

use libftd2xx::{Ft232h, FtdiMpsse, MpsseSettings};
use std::time::Duration;

let mut settings = MpsseSettings::default();
settings.read_timeout = Duration::from_secs(5);
let mut ft = Ft232h::with_serial_number("FT59UO4C")?;
ft.initialize_mpsse(&settings)?;

fn initialize_mpsse_default(&mut self) -> Result<(), TimeoutError>[src]

Initializes the MPSSE to default settings.

This simply calles initialize_mpsse with the default MpsseSettings.

Example

use libftd2xx::{Ft232h, FtdiMpsse};

let mut ft = Ft232h::with_serial_number("FT59UO4C")?;
ft.initialize_mpsse_default()?;

fn synchronize_mpsse(&mut self) -> Result<(), TimeoutError>[src]

Synchronize the MPSSE port with the application.

There are various implementations of the synchronization flow, this uses the flow from FTDI MPSSE Basics.

fn enable_loopback(&mut self) -> Result<(), TimeoutError>[src]

Enable the MPSSE loopback state.

Example

use libftd2xx::{Ft4232h, FtdiMpsse};

let mut ft = Ft4232h::with_serial_number("FT4PWSEOA")?;
ft.initialize_mpsse_default()?;
ft.enable_loopback()?;

fn disable_loopback(&mut self) -> Result<(), TimeoutError>[src]

Disable the MPSSE loopback state.

Example

use libftd2xx::{Ft4232h, FtdiMpsse};

let mut ft = Ft4232h::with_serial_number("FT4PWSEOA")?;
ft.initialize_mpsse_default()?;
ft.disable_loopback()?;

fn set_gpio_lower(
    &mut self,
    state: u8,
    direction: u8
) -> Result<(), TimeoutError>
[src]

Set the pin direction and state of the lower byte (0-7) GPIO pins on the MPSSE interface.

The pins that this controls depends on the device.

  • On the FT232H this will control the AD0-AD7 pins.

Arguments

  • state - GPIO state mask, 0 is low (or input pin), 1 is high.
  • direction - GPIO direction mask, 0 is input, 1 is output.

Example

use libftd2xx::{Ft232h, FtdiMpsse};

let mut ft = Ft232h::with_serial_number("FT5AVX6B")?;
ft.initialize_mpsse_default()?;
ft.set_gpio_lower(0xFF, 0xFF)?;
ft.set_gpio_lower(0x00, 0xFF)?;

fn gpio_lower(&mut self) -> Result<u8, TimeoutError>[src]

Get the pin state state of the lower byte (0-7) GPIO pins on the MPSSE interface.

Example

Set the first GPIO, without modify the state of the other GPIOs.

use libftd2xx::{Ft232h, FtdiMpsse};

let mut ft = Ft232h::with_serial_number("FT59UO4C")?;
ft.initialize_mpsse_default()?;
let mut gpio_state: u8 = ft.gpio_lower()?;
gpio_state |= 0x01;
ft.set_gpio_lower(gpio_state, 0xFF)?;

fn set_gpio_upper(
    &mut self,
    state: u8,
    direction: u8
) -> Result<(), TimeoutError>
[src]

Set the pin direction and state of the upper byte (8-15) GPIO pins on the MPSSE interface.

The pins that this controls depends on the device. This method may do nothing for some devices, such as the FT4232H that only have 8 pins per port.

See set_gpio_lower for an example.

Arguments

  • state - GPIO state mask, 0 is low (or input pin), 1 is high.
  • direction - GPIO direction mask, 0 is input, 1 is output.

FT232H Corner Case

On the FT232H only CBUS5, CBUS6, CBUS8, and CBUS9 can be controlled. These pins confusingly map to the first four bits in the direction and state masks.

fn gpio_upper(&mut self) -> Result<u8, TimeoutError>[src]

Get the pin state state of the upper byte (8-15) GPIO pins on the MPSSE interface.

See gpio_lower for an example.

See set_gpio_upper for additional information about physical pin mappings.

fn clock_data_out(
    &mut self,
    mode: ClockDataOut,
    data: &[u8]
) -> Result<(), TimeoutError>
[src]

Clock data out.

This will clock out bytes on TDI/DO. No data is clocked into the device on TDO/DI.

Example

use libftd2xx::{ClockDataOut, Ft232h, FtdiMpsse};

let mut ft = Ft232h::with_serial_number("FT5AVX6B")?;
ft.initialize_mpsse_default()?;
ft.set_clock(100_000)?;
ft.set_gpio_lower(0xFA, 0xFB)?;
ft.set_gpio_lower(0xF2, 0xFB)?;
ft.clock_data_out(ClockDataOut::MsbNeg, &[0x12, 0x34, 0x56])?;
ft.set_gpio_lower(0xFA, 0xFB)?;

fn clock_data_in(
    &mut self,
    mode: ClockDataIn,
    data: &mut [u8]
) -> Result<(), TimeoutError>
[src]

Clock data in.

This will clock in bytes on TDO/DI. No data is clocked out of the device on TDI/DO.

fn clock_data(
    &mut self,
    mode: ClockData,
    data: &mut [u8]
) -> Result<(), TimeoutError>
[src]

Clock data in and out at the same time.

Loading content...

Implementors

impl FtdiMpsse for Ft232h[src]

impl FtdiMpsse for Ft4232h[src]

Loading content...