Skip to content

A .NET library to talk all sort of external devices from Windows using the FTDI chip FT232H.

License

Notifications You must be signed in to change notification settings

MindfireTechnology/FT232H.NET

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MadeInTheUSB FT232H NET Library

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.

External components supported or Chip

  • 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

FT232H with 64x8 LED Matrix

Samples

GPIOs

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);
}

SPI

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);
}

Breakouts available

References Links

SPI, I2C, GPIO Wiring

  • 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

.NET Compilation

  • x64 : This code must be compiled in 64 bit mode

Dll dependency and drivers

  • 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.

About

A .NET library to talk all sort of external devices from Windows using the FTDI chip FT232H.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%