The .NET/Windows library MadeInTheUSB.FT232H provides an abstraction to program
- The SPI protocol
- The GPIOs
for break out based on the FTDI chip FT232H.
Not supported yet:
- I2C
- With the FT232H it is not possible to used I2C and SPI at the same time, because the 2 protocols use the same clock and data pins.
- To support I2C and SPI at the same time you can use the FT2232H or the FT4222H.
- RGB LED strip of type
APA102
are supported with examples - 8x8, 32x8 and 64x8 LED matrix based on the
MAX7219
chip are supported with examples - Any EPPROM and NOR and NAND Flash memory using the SPI protocol should be supported
- ADC MCP3008 and MCP3004 are supported with examples
static void GpioSample(IDigitalWriteRead gpios, bool oneLoopOnly = false)
{
var waitTime = 100;
for(var i=0; i < gpios.MaxGpio; i++)
{
gpios.DigitalWrite(i, PinState.High);
}
Thread.Sleep(waitTime);
for(var i=0; i < gpios.MaxGpio; i++)
{
gpios.DigitalWrite(i, PinState.Low);
}
Thread.Sleep(waitTime);
}
static void Main(string[] args)
{
var ft232Device = FT232HDetector.Detect();
if(ft232Device.Ok)
System.Console.WriteLine(ft232Device.ToString());
var ft232hGpioSpiDevice = new GpioSpiDevice(MpsseSpiConfig.GetDefault());
var gpios = ft232hGpioSpiDevice.GPIO;
GpioSample(gpios, true);
}
static void CypressFlashMemorySample(ISPI spi)
{
const int EEPROM_READ_IDENTIFICATION = 0x9F;
byte [] buffer = new byte [18];
if(spi.Ok(spi.Query(new byte [] { EEPROM_READ_IDENTIFICATION }, buffer))) {
var manufacturer = (Manufacturers)buffer[0];
var deviceID = (CYPRESS_S25FLXXX_DEVICE_ID)((buffer[1] << 8) + buffer[2]);
var sectorArchitecture = (CYPRESS_SECTOR_ARCHITECTURE)buffer[4];
var familyID = (CYPRESS_FAMILIY_ID)buffer[5];
var packageModel = string.Empty;
packageModel += ((char)buffer[6]).ToString();
packageModel += ((char)buffer[7]).ToString();
System.Console.WriteLine($"FLASH Memory manufacturer:{manufacturer}, deviceID:{deviceID}, sectorArchitecture:{sectorArchitecture}, familyID:{familyID}, packageModel:{packageModel}");
}
}
static void Main(string[] args)
{
var ft232Device = FT232HDetector.Detect();
if(ft232Device.Ok)
System.Console.WriteLine(ft232Device.ToString());
var ft232hGpioSpiDevice = new GpioSpiDevice(MpsseSpiConfig.GetDefault());
var spi = ft232hGpioSpiDevice.SPI;
CypressFlashMemorySample(spi);
}
-
The Adafruit breakout: Adafruit FT232H Breakout General Purpose USB to GPIO+SPI+I2C
-
This breakout does contains an EEPROM therefore it is possible to program the device id or description.
-
Images
- Adafruit FT232 with 16x4 matrix -> https://bit.ly/2RgmvAl
- Adafruit FT232 with 4x4 matrix -> https://bit.ly/2DYEkRd
-
-
- This breakout does not contains an EEPROM therefore it is not possible to program the device id or description.
- SPI and GPIOs are working fine.
- Images
- Chinese FT232H Breakout with 8 GPIOs and 1 APA 102 RGB LED connected -> https://bit.ly/2RhpmZA
-
Chinese/eBay FT 2 232H breakout
- I never tested this breakout, but seems interesting
-
SPI
- CLOCK AD0
- MOSI AD1
- MISO AD2
- CS 5 Chip selects are available. CS0:AD3, CS1:AD4, CS2:AD5, CS3:AD6, CS4:AD7. The library is configured to use CS0:AD3 as the default.
-
I2C
- CLOCK AD0
- SDA OUT AD1
- SDA IN AD2
- SDA OUT and SDA IN need to be connected because in I2C there is only one data write.
- The data and clock wire each requires a pull up resistor (Not sure what value probably 4.7k).
-
GPIOS
- GPIO 0..7: AC0..C7.
- AC8, AC9 are special and not supported yet by the lirbary
- x64 : This code must be compiled in 64 bit mode
-
The dll FTD2XX.DLL, must be in the path. The dll should be installed by the FTDI driver. The driver should automatically be installed by Windows 10 on the first time the FT232H or FT232RL is connected to the machine. For Windows 7 install the driver manually.
-
This library contains the source code of the .NET wrapper for the dll FTD2XX.DLL. The file is called FTD2XX_NET.cs. This is the last version from FTDT as 2018, that support the FT4222H.
-
The dll libMPSSE.dll from FTDT must be in the current folder. It is part of the source code.