A hardware developer utility that allows you to control an FT2232H - turned - SPI master through a serial connection. Send binary data, receive a matching number of bytes.
Once set up using FT_PROG, an FTDI chip with one or more Multi-Protocol Synchronous Serial Engine ports can act as an SPI master USB peripheral, which at its core would otherwise involve the use of libMPSSE or its higher-level wrappers, like libMPSSE_SPI.
A particularly convenient way to use COMSPI during the development of SPI slave devices turned out to be defining Sequences
in HTerm - with both HTerm and COMSPI connected through a com0com bridge.
For more advanced projects, please consider using devttys0/libmpsse, which is based on libFTDI. See also FTD2XX vs. libFTDI.
You'll need an FTDI device that features one or more MPSSE ports (FT2232H or similar).
Download / install the the following applications and drivers:
- FTDI D2XX device driver
- FT_PROG from the FTDI Utilities section (as of writing: Rev. 2.8.2), you will need this tool to select "245 FIFO" mode and the "D2XX" driver for individual MPSSE ports
- Serial Port null-modem bridge: com2com Rev. 2.2.2 or newer. (current version with signed drivers)
- a serial port terminal like HTerm
Find your device and read its EEPROM. For a given Port
, select
- Hardware: 245FIFO
- Driver: D2XX
Subsequently, write back the updated configuration.
It may be necessary to deactivate the VCP driver in devmgmt.msc
for a given port that has already been installed and won't go away even when the FT_PROG tool has been used to change the driver mode. I guess that is because The Vendor ID: Product ID of the enumerated USB device is already registered and drivers are loaded.
The following parameters are currently supported:
COMSPI flag | mandatory? | default value | description |
-COM | yes | - | com0com virtual COM port to connect to |
-CHAN | yes *) | - | an available MPSSE channel. Start COMSPI without parameters to get an enumeration. |
-ID | yes **) | - | VID:PID identifier (see enumeration), e.g. 0x04036010. You can also modify these values in FT_PROG. |
-LOCID | yes **) | - | see -ID, e.g. 0x0821 |
-MODE | 0 | one of {0, 1, 2, 3}. See AN178, Mode1 and Mode3 are not fully functional | |
-CSEL | active low (0) | one of {0,1}, "0" for Active Low mode | |
-READ | 1 (Byte) | number of bytes to be read after a write operation | |
-CLK | 5000 (Bit/s) | serial clock speed in bit/sec. |
For use with FT2232H (VID 0x0403 PID 0x6010):
@START comspi.exe -COM 20 -CHAN 1 -MODE 0 -READ 10 -CLK 6000
@START comspi.exe -COM 20 -ID 0x04036010 -LOCID 0x0822
There is also a pair of numbers in the window title expressing | to show info when minimized. To just send out data you may want to set -READ 0.
- com0com COM20 <-> COM21
- MISO connected to a signal generator producing a square wave
- "hey, SPI!" -> 9 bytes read back
- the libMPSSE-SPI code and examples
- AN135: MPSSE Basics
- GCC GNU compiler collection for g++