Giter Site home page Giter Site logo

Comments (6)

cospan avatar cospan commented on August 19, 2024

That's a pretty cool board!

I've been using this library for a while now, specifically to toggle GPIOs, program SPI flash chips and send data to and from my FPGA using the synchronous FIFOs. I would like to help you out but unfortunately I don't have the time to read through all the documentation for that board.

If any of your needs are related to anything above I can help out with an example or two.

from pyftdi.

eblot avatar eblot commented on August 19, 2024

I'm not sure what is a "generic FTDI device" here?
Could you provide the kind of FTDI device you use, and how they are reported on the USB bus? (vendor ID, product ID, ...)

from pyftdi.

karelv avatar karelv commented on August 19, 2024

@cospan, As you stated, that you use this lib for GPIO, may you be so kind to share a basic example about how to:

  1. Configure the CBUS0&1 to be output and CBUS2&3 to be input (as GPIO)
  2. demo program to write CBUS0 to 'zero', CBUS1 to 'one'.
  3. demo program to read CBUS2&3.

This would be very helpful for me!

Thanks in advance,
Karel.

from pyftdi.

cospan avatar cospan commented on August 19, 2024

Here's a simple python module and command line tool I wrote to control GPIOs for a FT2232H on one of my boards.

https://github.com/CospanDesign/python/tree/master/ftdi/gpio

There are two files:
gpio_controller.py: Python module that controls GPIOs
ftdi-gpio: Command Line Interface to test things out.

Currently the default setting is for my board, it has a custom product ID of 8350, I don't remember what the default product ID is bu it would be good to change the default settings to it (I think it's 0603??)

The 'interface' value specifies the 'bank', since the FT2232H has two 'banks' and the GPIOs for my device is on the 2nd bank then I put the default interface value as 2

The CLI looks like this:

usage: ftdi-gpio [-h] [--vendor VENDOR] [--product PRODUCT]
                 [--interface INTERFACE] [-b WRBIT] [-m WRMASK] [-t RDBIT]
                 [-s DIRMASK] [-v VALUE] [-d]

Read and Write GPIOs with FTDI chip
Default Behavior is to read the GPIOs from the specified interface
usage: ftdi-gpio [options]

optional arguments:
  -h, --help            show this help message and exit
  --vendor VENDOR       Specify USB Vendor ID (Default: 0403)
  --product PRODUCT     Specify USB Product ID (Default: 8530)
  --interface INTERFACE
                        Specify USB Interface (Default: 2)
  -b WRBIT, --wrbit WRBIT
                        Specify the bit to set (Example: 6)
  -m WRMASK, --wrmask WRMASK
                        Specify a bitmask value to write (Example: 0x40)
  -t RDBIT, --rdbit RDBIT
                        Read back the mask and compare it with index (Example:
                        40)
  -s DIRMASK, --dirmask DIRMASK
                        Configure bit mask of the chip, will be default the
                        values associated with output
  -v VALUE, --value VALUE
                        For write set this to 1 or 0 for high or low
  -d, --debug           Enable Debug Messages

Examples:
    Something

Examples

Example: Reading all the GPIO for the lower section of the second bank:

$ ./ftdi-gpio 
Pins: 0xFF

Example: Reading the value of one pin (bit 6), specifically a bit attached to a button:

Not Pressed (Button is high when not pressed)

$ ./ftdi-gpio --rdbit 6
Pins 6: True
Pins: 0xFF

Pressed
$ ./ftdi-gpio --rdbit 6
Pins 6: False
Pins: 0xBF

Example: Writing a one to another pin (bit 4), specifically the signal to reprogram my FPGA

Set GPIO 4 to an output and set that value high
$ ./ftdi-gpio --wrbit 4 --value 1
Pins: 0xFF

Set GPIO 4 to an output and set that output low
$ ./ftdi-gpio --wrbit 4 --value 0
Pins: 0xEF

Example: Explicitly declaring vendor id, product id and interface and then reading all the GPIOs

$ ./ftdi-gpio --vendor 0403 --product 8530 --interface 2
Pins: 0xFF

from pyftdi.

eblot avatar eblot commented on August 19, 2024

Sorry, I had no HW to test GPIO for a while (and provide examples) but I should definitely work on this long-lasting issue.

from pyftdi.

eblot avatar eblot commented on August 19, 2024

The latest version of PyFtdi (0.13.2) comes with GPIO examples. Hope this help.

from pyftdi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.