herosdevices.hardware.ftdi ========================== .. py:module:: herosdevices.hardware.ftdi .. autoapi-nested-parse:: 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 --------------- .. py:class:: GPIO Bases: :py:obj:`enum.Enum` Provide Rpi.GPIO like API. .. py:attribute:: IN :value: 0 .. py:attribute:: OUT :value: 1 .. py:attribute:: LOW .. py:attribute:: HIGH .. py:class:: 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) .. py:attribute:: PINMAP .. py:attribute:: device_sn :value: 'QAO201901' .. py:attribute:: spi_master .. py:attribute:: gpio :value: None .. py:method:: teardown() -> None Close down spi controller. .. py:method:: get_slave(cs: int = 0, freq: float = 12000000.0, mode: int = 0) -> int Get a slave aka. what you use to communicate. :param cs: chip-select 0 <= cs <= 4 (default CS0/ADBUS3/D3) :param freq: spi frequency (default 12MHz) :param mode: spi mode (default 0) :return: exposed spi slave .. py:method:: gpio_setup(pin: str = 'C0', mode: GPIO = GPIO.OUT, initial_value: GPIO = GPIO.LOW) -> None Set up a single GPIO pin. :param pin: name according to pinmap :param mode: GPIO.IN or GPIO.OUT :param initial_value: GPIO.LOW or GPIO.HIGH :return: .. py:method:: gpio_set_output(pin: str = 'C0', initial_value: GPIO = GPIO.LOW) -> None Set one pin as output. :param pin: str pin descriptor :param initial_value: initial value default GPIO.LOW :return: .. py:method:: gpio_set_input(pin: str = 'C0', initial_value: GPIO = GPIO.LOW) -> None Set one pin as output. :param pin: str pin descriptor :param initial_value: initial value default GPIO.LOW (not used) :return: .. py:method:: gpio_write(pin: str = 'C0', value: GPIO = GPIO.LOW, write: bool = True) -> None Write pin level. :param pin: :param value: :return: .. py:method:: gpio_writeall() -> None Write the configured pins to device. .. py:method:: gpio_read(pin: str = 'C0') -> int Read gpio pin and report state. .. py:method:: setHigh(pin: str = 'C0') -> None Deprecated alias for set_high. .. py:method:: set_high(pin: str = 'C0') -> None Set a single pin to high. .. py:method:: setLow(pin: str = 'C0') -> None Deprecated alias for set_low. .. py:method:: set_low(pin: str = 'C0') -> None Set a single pin to low. .. py:data:: ftdi