# HG changeset patch # User Mychaela Falconia # Date 1522964885 0 # Node ID ef43bbfa8d160ae27a42cb5ad4b231232dd500c7 # Parent 252e3d37b9e5daf2921b14bbd43024fd34f782d4 ee2232-read program written, compiles diff -r 252e3d37b9e5 -r ef43bbfa8d16 .hgignore --- a/.hgignore Thu Apr 05 10:20:43 2018 +0000 +++ b/.hgignore Thu Apr 05 21:48:05 2018 +0000 @@ -3,3 +3,4 @@ \.[oa]$ ^ee2232/ee2232-gen$ +^ee2232/ee2232-read$ diff -r 252e3d37b9e5 -r ef43bbfa8d16 ee2232/Makefile --- a/ee2232/Makefile Thu Apr 05 10:20:43 2018 +0000 +++ b/ee2232/Makefile Thu Apr 05 21:48:05 2018 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -PROGS= ee2232-gen +PROGS= ee2232-gen ee2232-read INSTBIN=/opt/freecalypso/bin all: ${PROGS} @@ -8,6 +8,9 @@ ee2232-gen: ee2232-gen.c ${CC} ${CFLAGS} -o $@ $@.c +ee2232-read: ee2232-read.c + ${CC} ${CFLAGS} -o $@ $@.c -lftdi + install: mkdir -p ${INSTBIN} install -c ${PROGS} ${INSTBIN} diff -r 252e3d37b9e5 -r ef43bbfa8d16 ee2232/ee2232-read.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ee2232/ee2232-read.c Thu Apr 05 21:48:05 2018 +0000 @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include +#include +#include + +char *device_selector = "i:0x0403:0x6010"; +unsigned eeprom_size = 64; + +process_cmdline(argc, argv) + char **argv; +{ + int c; + extern char *optarg; + + while ((c = getopt(argc, argv, "d:t:")) != EOF) { + switch (c) { + case 'd': + device_selector = optarg; + continue; + case 't': + if (!strcmp(optarg, "46")) + eeprom_size = 64; + else if (!strcmp(optarg, "56")) + eeprom_size = 128; + else if (!strcmp(optarg, "66")) + eeprom_size = 256; + else { + fprintf(stderr, + "error: -t option invalid value \"%s\"\n", + optarg); + exit(1); + } + continue; + default: + /* error msg already printed */ + exit(1); + } + } +} + +main(argc, argv) + char **argv; +{ + struct ftdi_context ftdi; + u_short word; + unsigned n, col; + + process_cmdline(argc, argv); + ftdi_init(&ftdi); + if (ftdi_usb_open_string(&ftdi, device_selector) < 0) { + fprintf(stderr, "FTDI USB open failed: %s\n", ftdi.error_str); + exit(1); + } + for (n = 0; n < eeprom_size; n++) { + if (ftdi_read_eeprom_location(&ftdi, n, &word) < 0) { + fprintf(stderr, "EEPROM read error: %s\n", + ftdi.error_str); + exit(1); + } + col = n & 7; + if (col == 0) + printf("%02X:", n * 2); + printf(" %04X", word); + if (col == 7) + putchar('\n'); + } + ftdi_usb_close(&ftdi); + exit(0); +}