The branch, master has been updated
via 13ea50d2302a8740d964ed50eb7906f349198e1a (commit)
via 347d87e5ed745614c05e784facb449a9e3615cde (commit)
from a1b2db22abd6fbc134238952c84122ea8b11b856 (commit)
- Log -----------------------------------------------------------------
commit 13ea50d2302a8740d964ed50eb7906f349198e1a
Author: Florian Preinstorfer <fp@xxxxxxx>
Date: Thu Oct 23 08:14:03 2014 +0200
Add print_inverted_bits() to replace a duplicated code block.
commit 347d87e5ed745614c05e784facb449a9e3615cde
Author: Florian Preinstorfer <fp@xxxxxxx>
Date: Thu Oct 23 08:08:07 2014 +0200
Replace eeprom->rs232_inversion with eeprom->invert.
Summary:
* The field eeprom->rs232_inversion reads and writes to the same
location as eeprom->invert already does.
* The configuration values invert_*, as read by ftdi_eeprom, are
working ootb with FT230X chips. No configuration values were
available for rs232_inversion.
I tested this commit with FT231X which identifies itself as VID 0x0403
and PID 0x6015.
-----------------------------------------------------------------------
Summary of changes:
src/ftdi.c | 60 ++++++++++++++++-----------------------------------------
src/ftdi.h | 3 +-
src/ftdi_i.h | 5 ----
3 files changed, 19 insertions(+), 49 deletions(-)
diff --git a/src/ftdi.c b/src/ftdi.c
index ad9e20e..bad338d 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -3065,7 +3065,7 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
{
output[0x1a + j] = eeprom->cbus_function[j];
}
- output[0x0b] = eeprom->rs232_inversion;
+ output[0x0b] = eeprom->invert;
break;
}
@@ -3391,7 +3391,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int
verbose)
eeprom->group1_schmitt = (buf[0x0c] >> 4) & IS_SCHMITT;
eeprom->group1_slew = (buf[0x0c] >> 4) & SLOW_SLEW;
- eeprom->rs232_inversion = buf[0xb];
+ eeprom->invert = buf[0xb];
}
if (verbose)
@@ -3515,33 +3515,8 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int
verbose)
if (eeprom->cbus_function[i]<= CBUSH_AWAKE)
fprintf(stdout,"CBUS%d Function: %s\n", i,
cbush_mux[eeprom->cbus_function[i]]);
}
- if(eeprom->rs232_inversion ) {
- struct bitnames {
- int mask;
- char *name;
- };
-
- struct bitnames invbitlist[] = {
- {INVERT_TXD, "TXD"},
- {INVERT_RXD, "RXD"},
- {INVERT_RTS, "RTS"},
- {INVERT_CTS, "CTS"},
- {INVERT_DTR, "DTR"},
- {INVERT_DSR, "DSR"},
- {INVERT_DCD, "DCD"},
- {INVERT_RI, "RI"},
- {0, NULL},
- };
- int n = 0;
- printf("Inversion on ");
- for (i=0; invbitlist[i].mask;i++) {
- if(eeprom->rs232_inversion & invbitlist[i].mask) {
- if (n++) printf (",");
- printf (" %s", invbitlist[i].name);
- }
- }
- printf (" Pin%s\n",(n==1)?"":"s");
- }
+ if(eeprom->invert )
+ print_inverted_bits(eeprom->invert);
}
if (ftdi->type == TYPE_R)
@@ -3553,14 +3528,8 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int
verbose)
char *cbus_BB[] = {"RXF","TXE","RD", "WR"};
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<<i)) == (1<<i))
- fprintf(stdout," %s",r_bits[i]);
- fprintf(stdout,"\n");
- }
+ print_inverted_bits(eeprom->invert);
+
for (i=0; i<5; i++)
{
if (eeprom->cbus_function[i]<CBUS_BB)
@@ -3764,9 +3733,6 @@ int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum
ftdi_eeprom_value valu
case CHIP_SIZE:
*value = ftdi->eeprom->size;
break;
- case RS232_INVERSION:
- *value = ftdi->eeprom->rs232_inversion;
- break;
default:
ftdi_error_return(-1, "Request for unknown EEPROM value");
}
@@ -3957,9 +3923,6 @@ int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum
ftdi_eeprom_value valu
case CHIP_SIZE:
ftdi_error_return(-2, "EEPROM Value can't be changed");
break;
- case RS232_INVERSION:
- ftdi->eeprom->rs232_inversion = value;
- break;
default :
ftdi_error_return(-1, "Request to unknown EEPROM value");
@@ -4327,4 +4290,15 @@ char *ftdi_get_error_string (struct ftdi_context *ftdi)
return ftdi->error_str;
}
+void print_inverted_bits(int invert)
+{
+ int i;
+ char *r_bits[] = {"TXD","RXD","RTS","CTS","DTR","DSR","DCD","RI"};
+ fprintf(stdout,"Inverted bits:");
+ for (i=0; i<8; i++)
+ if ((invert & (1<<i)) == (1<<i))
+ fprintf(stdout," %s",r_bits[i]);
+ fprintf(stdout,"\n");
+}
+
/* @} end of doxygen libftdi group */
diff --git a/src/ftdi.h b/src/ftdi.h
index e192a66..66ad7bc 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -332,7 +332,6 @@ enum ftdi_eeprom_value
CHANNEL_C_RS485 = 53,
CHANNEL_D_RS485 = 54,
RELEASE_NUMBER = 55,
- RS232_INVERSION = 56,
};
/**
@@ -555,6 +554,8 @@ extern "C"
char *ftdi_get_error_string(struct ftdi_context *ftdi);
+ void print_inverted_bits(int inverted);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/ftdi_i.h b/src/ftdi_i.h
index 066790b..19d8dd5 100644
--- a/src/ftdi_i.h
+++ b/src/ftdi_i.h
@@ -123,11 +123,6 @@ struct ftdi_eeprom
int data_order;
int flow_control;
- /* FT-X Device and Peripheral control
- * Fixme: Decode byte[0xa]
- */
- int rs232_inversion;
-
/** eeprom size in bytes. This doesn't get stored in the eeprom
but is the only way to pass it to ftdi_eeprom_build. */
int size;
hooks/post-receive
--
A library to talk to FTDI chips
--
libftdi-git - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|