From a49800437bffd7b155971f0a51316644deee8ba5 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Fri, 10 Sep 2010 22:40:29 +0200 Subject: [PATCH] Fix and verbose decode of TYPE_R CBUS functions and pin inversion --- src/ftdi.c | 57 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/ftdi.c b/src/ftdi.c index 297fa28..8610857 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -2206,7 +2206,15 @@ void ftdi_eeprom_initdefaults(struct ftdi_context *ftdi) eeprom->serial = NULL; if(ftdi->type == TYPE_R) + { + eeprom->max_power = 45; eeprom->size = 0x80; + eeprom->cbus_function[0] = CBUS_TXLED; + eeprom->cbus_function[1] = CBUS_RXLED; + eeprom->cbus_function[2] = CBUS_TXDEN; + eeprom->cbus_function[3] = CBUS_PWREN; + eeprom->cbus_function[4] = CBUS_SLEEP; + } else eeprom->size = -1; } @@ -2521,29 +2529,29 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi, unsigned char *output) output[0x0D] = (eeprom->usb_version>>8) & 0xff; if(eeprom->cbus_function[0] > CBUS_BB) - output[0x14] = CBUS_BB; + output[0x14] = CBUS_TXLED; else output[0x14] = eeprom->cbus_function[0]; if(eeprom->cbus_function[1] > CBUS_BB) - output[0x14] |= CBUS_BB<<4; + output[0x14] |= CBUS_RXLED<<4; else - output[0x14] |= eeprom->cbus_function[1]; + output[0x14] |= eeprom->cbus_function[1]<<4; if(eeprom->cbus_function[2] > CBUS_BB) - output[0x15] |= CBUS_BB<<4; + output[0x15] = CBUS_TXDEN; else - output[0x15] |= eeprom->cbus_function[2]; + output[0x15] = eeprom->cbus_function[2]; if(eeprom->cbus_function[3] > CBUS_BB) - output[0x15] |= CBUS_BB<<4; + output[0x15] |= CBUS_PWREN<<4; else - output[0x15] |= eeprom->cbus_function[3]; + output[0x15] |= eeprom->cbus_function[3]<<4; - if(eeprom->cbus_function[5] > CBUS_BB) - output[0x16] = CBUS_BB; + if(eeprom->cbus_function[4] > CBUS_CLK6) + output[0x16] = CBUS_SLEEP; else - output[0x16] = eeprom->cbus_function[0]; + output[0x16] = eeprom->cbus_function[4]; break; case TYPE_2232H: output[0x00] = (eeprom->channel_a_type); @@ -2901,9 +2909,34 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, unsigned char *buf, int size, (eeprom->group3_schmitt)?" Schmitt Input":"", (eeprom->group3_slew)?" Slow Slew":""); } - + if (ftdi->type == TYPE_R) + { + char *cbus_mux[] = {"TXDEN","PWREN","RXLED", "TXLED","TX+RXLED", + "SLEEP","CLK48","CLK24R","CLK122","CLK6", + "IOMODE","BB_WR","BB_RD"}; + char *cbus_BB[] = {"RXF","TXE","WR", "RD"}; + int i; + + if(eeprom->invert) + { + char *r_bits[] = {"TXD","RXD","RTS", "CTS","DTR","DSR","DCD","RI"}; + fprintf(stdout,"Inverted bits:"); + for (i=0; i<8; i++) + if((eeprom->invert & (1<cbus_function[i]cbus_function[i]]); + else + fprintf(stdout,"C%d BB Function: %s\n", i, + cbus_BB[i]); + } + } } - return 0; } -- 1.7.1