FreeCalypso > hg > fc-usbser-tools
diff fteeprom/fteeprom-erase.c @ 0:11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 03 Sep 2023 18:08:22 +0000 |
parents | |
children | af801ab43a33 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fteeprom/fteeprom-erase.c Sun Sep 03 18:08:22 2023 +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); +}