FreeCalypso > hg > freecalypso-hwlab
changeset 37:4d77c191c034
fteeprom-erase program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 Apr 2019 19:39:50 +0000 |
parents | 899ba273c30a |
children | c0e427a8d2cc |
files | .hgignore fteeprom/Makefile fteeprom/fteeprom-erase.c |
diffstat | 3 files changed, 32 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Apr 21 19:34:05 2019 +0000 +++ b/.hgignore Sun Apr 21 19:39:50 2019 +0000 @@ -8,6 +8,7 @@ ^fteeprom/ftee-gen2232c$ ^fteeprom/ftee-gen232r$ +^fteeprom/fteeprom-erase$ ^fteeprom/fteeprom-prog$ ^fteeprom/fteeprom-read$
--- a/fteeprom/Makefile Sun Apr 21 19:34:05 2019 +0000 +++ b/fteeprom/Makefile Sun Apr 21 19:39:50 2019 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -PROGS= ftee-gen2232c ftee-gen232r fteeprom-prog fteeprom-read +PROGS= ftee-gen2232c ftee-gen232r fteeprom-erase fteeprom-prog fteeprom-read INSTBIN=/opt/freecalypso/bin all: ${PROGS} @@ -11,6 +11,9 @@ ftee-gen232r: ftee-gen232r.c ${CC} ${CFLAGS} -o $@ $@.c +fteeprom-erase: fteeprom-erase.c + ${CC} ${CFLAGS} -o $@ $@.c -lftdi + fteeprom-prog: fteeprom-prog.c ${CC} ${CFLAGS} -o $@ $@.c -lftdi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fteeprom/fteeprom-erase.c Sun Apr 21 19:39:50 2019 +0000 @@ -0,0 +1,27 @@ +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <ftdi.h> + +main(argc, argv) + char **argv; +{ + struct ftdi_context ftdi; + + if (argc != 2) { + fprintf(stderr, "usage: %s device-selector\n"); + exit(1); + } + ftdi_init(&ftdi); + if (ftdi_usb_open_string(&ftdi, argv[1]) < 0) { + fprintf(stderr, "FTDI USB open failed: %s\n", ftdi.error_str); + exit(1); + } + if (ftdi_erase_eeprom(&ftdi) < 0) { + fprintf(stderr, "EEPROM write error: %s\n", ftdi.error_str); + exit(1); + } + ftdi_usb_close(&ftdi); + exit(0); +}