3 * Output a (stream of) byte(s) in bitbang mode to the
4 * ftdi245 chip that is (hopefully) attached.
6 * We have a little board that has a FT245BM chip and
7 * the 8 outputs are connected to several different
8 * things that we can turn on and off with this program.
10 * If you have an idea about hardware that can easily
11 * interface onto an FTDI chip, I'd like to collect
12 * ideas. If I find it worthwhile to make, I'll consider
13 * making it, I'll even send you a prototype (against
14 * cost-of-material) if you want.
16 * At "harddisk-recovery.nl" they have a little board that
17 * controls the power to two harddrives and two fans.
19 * -- REW R.E.Wolff@BitWizard.nl
23 * This program was based on libftdi_example_bitbang2232.c
24 * which doesn't carry an author or attribution header.
27 * This program is distributed under the GPL, version 2.
28 * Millions copies of the GPL float around the internet.
36 void ftdi_fatal (struct ftdi_context *ftdi, char *str)
38 fprintf (stderr, "%s: %s\n",
39 str, ftdi_get_error_string (ftdi));
43 int main(int argc, char **argv)
45 struct ftdi_context ftdic;
48 int delay = 100000; /* 100 thousand microseconds: 1 tenth of a second */
50 while ((t = getopt (argc, argv, "d:")) != -1)
55 delay = atoi (optarg);
62 if (ftdi_usb_open(&ftdic, 0x0403, 0x6001) < 0)
63 ftdi_fatal (&ftdic, "Can't open ftdi device");
65 if (ftdi_enable_bitbang(&ftdic, 0xFF) < 0)
66 ftdi_fatal (&ftdic, "Can't enable bitbang");
68 for (i=optind; i < argc ; i++)
70 sscanf (argv[i], "%x", &t);
72 if (ftdi_write_data(&ftdic, &data, 1) < 0)
74 fprintf(stderr,"write failed for 0x%x: %s\n",
75 data, ftdi_get_error_string(&ftdic));
80 ftdi_usb_close(&ftdic);