# HG changeset patch # User Mychaela Falconia # Date 1695688738 0 # Node ID 957fb6e085771d93c190e91484162924032f5fc0 # Parent 7ff9b4857aaf60abcee03861440be22c0045e94d ftee-gen232r: add ftdi-chip setting diff -r 7ff9b4857aaf -r 957fb6e08577 fteeprom/ftee-gen232r.c --- 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 #include #include @@ -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;