herosdevices.hardware.ftdi - Heros Devices 0.7.1 documentation

Skip to content
Back to top
View this page

# herosdevices.hardware.ftdi

Implements a wrapper for FT232H devices.

https://www.adafruit.com/product/2264

The implementation https://github.com/eblot/pyftdi supports simultaneous use of SPI and GPIO pins. Unfortunately it is based on using bitmasks for everything.

## Module Contents

class herosdevices.hardware.ftdi.GPIO

  Bases: `enum.Enum`

  Provide Rpi.GPIO like API.

  IN = 0
  OUT = 1
  LOW
  HIGH

class herosdevices.hardware.ftdi.FT232H(device_sn: str = 'QAO201901')

  Provide pin wrapping and GPIO abstraction.

  see http://eblot.github.io/pyftdi/pinout.html

  The device sn is written to the eeprom of the Adafruit FT232H chips. To do that follow this description: https://cdn-learn.adafruit.com/downloads/pdf/adafruit-ft232h-breakout.pdf?timestamp=1550211653 (section Erase EEPROM For Programming With FT_PROG)

  PINMAP
  device_sn = 'QAO201901'
  spi_master
  gpio = None
  teardown() → None

    Close down spi controller.

  get_slave(cs: int = 0, freq: float = 12000000.0, mode: int = 0) → int

    Get a slave aka. what you use to communicate.

    Parameters:

      - cs – chip-select 0 <= cs <= 4 (default CS0/ADBUS3/D3)

      - freq – spi frequency (default 12MHz)

      - mode – spi mode (default 0)

    Returns:

      exposed spi slave

  gpio_setup(pin: str = 'C0', mode: GPIO = GPIO.OUT, initial_value: GPIO = GPIO.LOW) → None

    Set up a single GPIO pin.

    Parameters:

      - pin – name according to pinmap

      - mode – GPIO.IN or GPIO.OUT

      - initial_value – GPIO.LOW or GPIO.HIGH

    Returns:

  gpio_set_output(pin: str = 'C0', initial_value: GPIO = GPIO.LOW) → None

    Set one pin as output.

    Parameters:

      - pin – str pin descriptor

      - initial_value – initial value default GPIO.LOW

    Returns:

  gpio_set_input(pin: str = 'C0', initial_value: GPIO = GPIO.LOW) → None

    Set one pin as output.

    Parameters:

      - pin – str pin descriptor

      - initial_value – initial value default GPIO.LOW (not used)

    Returns:

  gpio_write(pin: str = 'C0', value: GPIO = GPIO.LOW, write: bool = True) → None

    Write pin level.

    Parameters:

      - pin

      - value

    Returns:

  gpio_writeall() → None

    Write the configured pins to device.

  gpio_read(pin: str = 'C0') → int

    Read gpio pin and report state.

  setHigh(pin: str = 'C0') → None

    Deprecated alias for set_high.

  set_high(pin: str = 'C0') → None

    Set a single pin to high.

  setLow(pin: str = 'C0') → None

    Deprecated alias for set_low.

  set_low(pin: str = 'C0') → None

    Set a single pin to low.

herosdevices.hardware.ftdi.ftdi