arre
Hi all,
I've used my TIAO already extensively for JTAG debugging, and this worked very well. Even though building the correct openocd scripts can take some time, there is good documentation available online of how to use the TIAO with JTAG.
However, for SPI, documentation is pretty sparse. Hence, I thought I'd share some experiences for anyone else who googles TIAO SPI (in C#).
I can now send 750kBps and receive 2.5MBps through it, in a C# program.
Libraries
Turns out FTDI (the chip on the TIAO that does everything), have two libraries to avoid having to directly use their D2XX library for SPI (which is cumbersome):
- LibMPSSE-SPI
- FTCSPI
The LibMPSSE-SPI is newer, but does not have a C# interface
FTCSPI is older (and e.g. does not support duplex operation), but has some nice testprograms you can find on their site. (If you google FTDI SPI C# you'll get there).
> You need FTCSPI V2 for FT2232H support (which we need)
Configuring Visual Studio correctly
I downloaded the visual studio projects CSHARP_200 and FTCSPI_SOURCE, and opened them with visual studio community.
> You'll need to fix the paths in the project settings for the debug workspace
> You want to disable "enable native debugging" unless you have configured windows to do so.
Then, if you try to run their CSHARP_200 program, it tries to load the dll. The ftcspi.dll is not a com object, and hence cannot be added as a reference to the project. Instead, place it in the build directly, in lowercase, and it should find it. Make sure you use the correct architecture one! (I needed the 64bit one)
Recompiling FTCSPI to find the TIAO
Even when you use the DLL, the CSHARP_200 application fails to find the TIAO as a highspeed device. The reason is that the device name programmed in the EEPROM of the TIAO differes from what the DLL expects.
You can fix this by forcing returning 0 in FTC_STATUS FT2232h::FTC_IsDeviceHiSpeedType in the FTCSPI project, rebuilding the DLL, and placing it in the folder again.
=> Now your CSHARP_200 program should detect the hardware, and you should be able to see SPI coming through. At this point is just a matter of reading the documentation of the FTCSPI library, to figure out how to set the clock, send or read, etc. (and you have an example program ready).
Hope this helps someone