changeset 76:957fb6e08577

ftee-gen232r: add ftdi-chip setting
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 26 Sep 2023 00:38:58 +0000
parents 7ff9b4857aaf
children 66cbbd7d85cf
files fteeprom/ftee-gen232r.c
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/fteeprom/ftee-gen232r.c	Tue Sep 26 00:25:41 2023 +0000
+++ b/fteeprom/ftee-gen232r.c	Tue Sep 26 00:38:58 2023 +0000
@@ -1,3 +1,8 @@
+/*
+ * This program constructs a configuration EEPROM image for an FT232R chip
+ * based on a configuration source file giving various settings.
+ */
+
 #include <sys/types.h>
 #include <ctype.h>
 #include <string.h>
@@ -18,6 +23,18 @@
 u_short eeprom[64];
 unsigned eeprom_string_ptr = 0x0C;
 
+static void
+ftdi_chip_setting(arg, filename_for_errs, lineno)
+	char *arg, *filename_for_errs;
+{
+	if (!strcasecmp(arg, "FT232R"))
+		return;
+	fprintf(stderr, "%s line %d: config is for wrong FTDI chip\n",
+		filename_for_errs, lineno);
+	exit(1);
+}
+
+static void
 read_config_file(filename)
 	char *filename;
 {
@@ -88,6 +105,8 @@
 			cbusconf[3] = strtoul(cp, 0, 16);
 		else if (!strcmp(np, "cbus4"))
 			cbusconf[4] = strtoul(cp, 0, 16);
+		else if (!strcmp(np, "ftdi-chip"))
+			ftdi_chip_setting(cp, filename, lineno);
 		else {
 			fprintf(stderr, "%s line %d: unknown \"%s\" setting\n",
 				filename, lineno, np);
@@ -105,6 +124,7 @@
 	}
 }
 
+static int
 write_string(str)
 	char *str;
 {
@@ -122,6 +142,7 @@
 	return (longlen << 8) | 0x80 | (startptr << 1);
 }
 
+static void
 fill_eeprom(serial)
 	char *serial;
 {
@@ -150,6 +171,7 @@
 	eeprom[11] = cbusconf[4];
 }
 
+static void
 do_checksum()
 {
 	u_short chksum = 0xAAAA;
@@ -162,6 +184,7 @@
 	eeprom[63] = chksum;
 }
 
+static void
 emit_output()
 {
 	unsigned n, col;