X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=ftdi_eeprom%2Fmain.c;h=c19d1113bb3b8118991f65b64fb0964e687024f8;hp=c7db6e82558a88d642388448dc3905489b0415f8;hb=add00ad60e3d942f23233a0a25a39cebfced5c15;hpb=048eb722b34cb824009db072a0fff9ecd9c84da9 diff --git a/ftdi_eeprom/main.c b/ftdi_eeprom/main.c index c7db6e8..c19d111 100644 --- a/ftdi_eeprom/main.c +++ b/ftdi_eeprom/main.c @@ -2,7 +2,7 @@ main.c - description ------------------- begin : Mon Apr 7 12:05:22 CEST 2003 - copyright : (C) 2003-2013 by Intra2net AG and the libftdi developers + copyright : (C) 2003-2014 by Intra2net AG and the libftdi developers email : opensource@intra2net.com ***************************************************************************/ @@ -41,27 +41,72 @@ #include #include -static int str_to_cbus(char *str, int max_allowed) +static int parse_cbus(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result) { -#define MAX_OPTION 14 - const char* options[MAX_OPTION] = + static const char* options[] = { - "TXDEN", "PWREN", "RXLED", "TXLED", "TXRXLED", "SLEEP", - "CLK48", "CLK24", "CLK12", "CLK6", - "IO_MODE", "BITBANG_WR", "BITBANG_RD", "SPECIAL" + "TXDEN", "PWREN", "RXLED", "TXLED", "TXRXLED", "SLEEP", "CLK48", + "CLK24", "CLK12", "CLK6", "IOMODE", "BB_WR", "BB_RD" }; + int i; - max_allowed += 1; - if (max_allowed > MAX_OPTION) max_allowed = MAX_OPTION; - for (i=0; itype == TYPE_R) + { + if (cfg_getint(cfg, "cbus0") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_0, cfg_getint(cfg, "cbus0")); + if (cfg_getint(cfg, "cbus1") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_1, cfg_getint(cfg, "cbus1")); + if (cfg_getint(cfg, "cbus2") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_2, cfg_getint(cfg, "cbus2")); + if (cfg_getint(cfg, "cbus3") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_3, cfg_getint(cfg, "cbus3")); + if (cfg_getint(cfg, "cbus4") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_4, cfg_getint(cfg, "cbus4")); + } + else if (ftdi->type == TYPE_232H) + { + if (cfg_getint(cfg, "cbush0") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_0, cfg_getint(cfg, "cbush0")); + if (cfg_getint(cfg, "cbush1") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_1, cfg_getint(cfg, "cbush1")); + if (cfg_getint(cfg, "cbush2") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_2, cfg_getint(cfg, "cbush2")); + if (cfg_getint(cfg, "cbush3") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_3, cfg_getint(cfg, "cbush3")); + if (cfg_getint(cfg, "cbush4") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_4, cfg_getint(cfg, "cbush4")); + if (cfg_getint(cfg, "cbush5") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_5, cfg_getint(cfg, "cbush5")); + if (cfg_getint(cfg, "cbush6") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_6, cfg_getint(cfg, "cbush6")); + if (cfg_getint(cfg, "cbush7") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_7, cfg_getint(cfg, "cbush7")); + if (cfg_getint(cfg, "cbush8") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_8, cfg_getint(cfg, "cbush8")); + if (cfg_getint(cfg, "cbush9") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_9, cfg_getint(cfg, "cbush9")); + } + else if (ftdi->type == TYPE_230X) + { + if (cfg_getint(cfg, "cbusx0") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_0, cfg_getint(cfg, "cbusx0")); + if (cfg_getint(cfg, "cbusx1") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_1, cfg_getint(cfg, "cbusx1")); + if (cfg_getint(cfg, "cbusx2") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_2, cfg_getint(cfg, "cbusx2")); + if (cfg_getint(cfg, "cbusx3") != -1) + eeprom_set_value(ftdi, CBUS_FUNCTION_3, cfg_getint(cfg, "cbusx3")); + } + int invert = 0; if (cfg_getbool(cfg, "invert_rxd")) invert |= INVERT_RXD; if (cfg_getbool(cfg, "invert_txd")) invert |= INVERT_TXD;