changeset 5:a85b6b7398bc

ee2232-prog: actual EEPROM write implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Apr 2018 22:36:51 +0000
parents 02ea5dbdf84b
children e01f4a81bebf
files ee2232/ee2232-prog.c
diffstat 1 files changed, 14 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ee2232/ee2232-prog.c	Thu Apr 05 22:30:38 2018 +0000
+++ b/ee2232/ee2232-prog.c	Thu Apr 05 22:36:51 2018 +0000
@@ -65,31 +65,29 @@
 	}
 }
 
-test_output()
-{
-	unsigned n, col;
-
-	for (n = 0; n < eeprom_size; n++) {
-		col = n & 7;
-		if (col == 0)
-			printf("%02X:", n * 2);
-		printf(" %04X", eeprom[n]);
-		if (col == 7)
-			putchar('\n');
-	}
-}
-
 main(argc, argv)
 	char **argv;
 {
 	struct ftdi_context ftdi;
+	unsigned n;
 
 	process_cmdline(argc, argv);
 	if (erase)
 		memset(eeprom, 0xFF, eeprom_size * 2);
 	else
 		read_eeprom_from_stdin();
-	test_output();
+	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_write_eeprom_location(&ftdi, n, eeprom[n]) < 0) {
+			fprintf(stderr, "EEPROM write error: %s\n",
+				ftdi.error_str);
+			exit(1);
+		}
+	}
+	ftdi_usb_close(&ftdi);
 	exit(0);
-
 }