loading

Setting Up the GCC Compiler

I setup a C environment as basic I could. There may be easier ways to go about this, but I wanted to use GCC to compile.

To setup the environment:

  1. I downloaded and setup MinGW32.
  2. I then downloaded FTD2XX libraries. This included the ftd2xx.h file and ftd2xx.lib.
  3. I then stole the test code from Hack-a-Day's article on bitbanging with the FTDI.
  4. I modified the code as they suggested by including, in this order, the Windows compatibility files:
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h> 
#include <windows.h>
#include <windef.h>
#include <winnt.h>
#include <winbase.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include "ftd2xx.h"
#include <sys/time.h>

Code Link

I used this line to build it:

$ gcc -o main main.c -L./ -lftd2xx 

You must have both the ftd2xx.h and ftd2xx.lib in the same directory as you attempt to build.

As for editing, I've really grown to love Sublime Text 2.

If you have issues, make sure directory containing your files is in your PATH environment variable (I go over how to add the directory to your environment variables in this post).

Step 1: D2XX

D2XX -- FTDI Support

The FTDI chips are highly controversial chips in the embedded world. I will not begin the debate on their efficacy. I chose this particular serializer since I felt most roboticist would have at least one, making software released using the chips reach a greater range of people on the spectrum of hobbyist to professional.

There are two basic interfaces for the FTDI chips:

  1. Virtual COM port.
  2. FTD2XX.DLL

I will be using the DLL. This is what the "-L./ -lftd2xx" part of our compile command is referring. It is including the ftd2xx library found in working directory.

The D2XX library is pretty nifty. It provides a collections of C++ functions to interact with the FTDI chip, and thereby, anything speaking UART. A full list of the commands and C code examples may be found in the,

One last caveat regarding the reason I selected using the D2XX libraries instead of using the chip as a virtual COM port. I wanted as much control over the metal of the chip is possible. Originally, I had set out to write a downloader that'd use the already existing Sparkfun FTDI breakout, meant to program the Arduino Pro Mini and LilyPad, as no-need-to-modify programmer for my LPC1114 board. To accomplish this, I needed bit level control over all of the pins of the FTDI chip, which the D2XX has, but the COM port does not.

Post a comment

"I Made It" comments require images. Uncheck for normal comment.
Be nice!

We have a be nice comment policy.
Please be positive and constructive.

About This Instructable

1,614 views

14 favorites

License:

Bio: I'm a homeless outreach worker in Fort Worth, Texas. I hack away on electronics as a way to deal with the stress; a type ... More »
More by Ladvien: IPhone to Arduino using Bluetooth 4.0  -- UUEncoding in C HEX File to Array in C
Add instructable to: