X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=ftdi_eeprom%2Fmain.c;fp=ftdi_eeprom%2Fmain.c;h=c19d1113bb3b8118991f65b64fb0964e687024f8;hp=2592796a11d07caa7dc74ba88fecae249634b517;hb=add00ad60e3d942f23233a0a25a39cebfced5c15;hpb=19f1452cde9bfe9da0e2830af128fae958ae877a diff --git a/ftdi_eeprom/main.c b/ftdi_eeprom/main.c index 2592796..c19d111 100644 --- a/ftdi_eeprom/main.c +++ b/ftdi_eeprom/main.c @@ -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;