FT-2232 Bridges Python And I2C/SPI

You might already have the hardware on hand to easily interface I2C and SPI devices with Python scripts on your computer. The board seen above is an FT-2232 breakout board. These chips are often used to facilitate JTAG programming via USB, but they have other features that might be useful to you as well. The chip has a Multi-Protocol Synchronous Serial Engine (MPSSE) which can speak the I2C and SPI protocols, you just need to know how to active them in your code.

[Craig] makes this easy with his MPSSE Python wrapper. Simply install his module, and you’ll be able to import all the commands you need. He demonstrates reading the data out of a 1 MB SPI flash memory chip. This could be used for a lot more, including debugging peripherals à la the Bus Pirate, or reprogramming chips to add to your projects (we’re thinking font arrays and sprites for displays, or look-up tables).

If you’re not aware, these FTDI chips were the go-to for USB support for a long time. We’ve got a guide for bit-banging using this hardware. Lately more chips have become available with USB hardware built-in. They’re quite useful and cost-effective, especially with the availability of open-source stacks like the LUFA project.

9 thoughts on “FT-2232 Bridges Python And I2C/SPI

  1. The FT-2232 should not be confused with the FT-232R. The FT-2232 actually has native support for JTAG, SPI and I2C protocols. FTA:

    “The FT-2232′s Multi-Protocol Synchronous Serial Engine (MPSSE) also supports the SPI and I2C protocols, clock rates of up to 30MHz, and a full-speed USB interface.”

    So this will be much faster than trying to bit-bang these protocols through a FT-232R, and probably faster than many uC’s too.

    @drew:

    Yes, the busblaster is based on the FT-2232 chip as well, but AFAIK it is targeted primarily at JTAG. With this library you can extend its functionality to support SPI and I2C as well (although you may need to re-program the CPLD too).

    1. FTDI’s libmpsse_spi library does not support SPI modes 1 and 3, but the open source libmpsse library does.

      I have tested mode 3 on an SPI flash chip and it works fine; I don’t have any devices that support mode 1 at the moment, but it looks good on the ‘scope.

  2. FTDI says the LibMPSSE_SPI is supposed to be a good starting point for your development with FT2232H and the like.

    Thanks for the article pointing towards the open libmpsse implementation – will have to give it a go when libmpsse_spi fails to deliver SPI_ReadWrite.

Leave a Reply to CraigCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.