Giter Site home page Giter Site logo

phylumchordata / ft232h.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twhidden/ft232h.net

0.0 1.0 0.0 561 KB

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

License: MIT License

C# 99.72% Batchfile 0.01% PowerShell 0.27%

ft232h.net's Introduction

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.

ft232h.net's People

Contributors

fredericaltorres avatar madeintheusb avatar

Watchers

James Cloos avatar

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.