view fteeprom/fteeprom-erase.c @ 109:4aaf722ab933

fc-simtool: update-bin-imm command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 26 Jan 2021 01:27:58 +0000
parents 4d77c191c034
children
line wrap: on
line source

#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);
}