--
Uwe Bonnes bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
>From a46f14fe54ced21564794603954abf859d9d98cb Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 17 Jun 2011 21:41:32 +0200
Subject: Backport basic FT232H support
---
src/ftdi.c | 25 +++++++++++++++++++++++--
src/ftdi.h | 2 +-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/ftdi.c b/src/ftdi.c
index e7e91f9..56516d8 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -412,7 +412,7 @@ static unsigned int _ftdi_determine_max_packet_size(struct
ftdi_context *ftdi, s
// Determine maximum packet size. Init with default value.
// New hi-speed devices from FTDI use a packet size of 512 bytes
// but could be connected to a normal speed USB hub -> 64 bytes packet
size.
- if (ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H)
+ if (ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H || ftdi->type ==
TYPE_232H)
packet_size = 512;
else
packet_size = 64;
@@ -536,6 +536,8 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct
usb_device *dev)
ftdi->type = TYPE_2232H;
else if (dev->descriptor.bcdDevice == 0x800)
ftdi->type = TYPE_4232H;
+ else if (dev->descriptor.bcdDevice == 0x900)
+ ftdi->type = TYPE_232H;
// Set default interface on dual/quad type chips
switch(ftdi->type)
@@ -1067,7 +1069,8 @@ static int ftdi_convert_baudrate(int baudrate, struct
ftdi_context *ftdi,
}
// Split into "value" and "index" values
*value = (unsigned short)(encoded_divisor & 0xFFFF);
- if (ftdi->type == TYPE_2232C || ftdi->type == TYPE_2232H || ftdi->type ==
TYPE_4232H)
+ if (ftdi->type == TYPE_2232C || ftdi->type == TYPE_2232H || ftdi->type ==
TYPE_4232H
+ || ftdi->type == TYPE_232H)
{
*index = (unsigned short)(encoded_divisor >> 8);
*index &= 0xFF00;
@@ -2259,6 +2262,15 @@ int ftdi_eeprom_build(struct ftdi_eeprom *eeprom,
unsigned char *output)
case TYPE_R:
output[0x07] = 0x06;
break;
+ case TYPE_2232H:
+ output[0x07] = 0x07;
+ break;
+ case TYPE_4232H:
+ output[0x07] = 0x08;
+ break;
+ case TYPE_232H:
+ output[0x07] = 0x09;
+ break;
default:
output[0x07] = 0x00;
}
@@ -2448,6 +2460,15 @@ int ftdi_eeprom_decode(struct ftdi_eeprom *eeprom,
unsigned char *buf, int size)
value = buf[0x06] + (buf[0x07]<<8);
switch (value)
{
+ case 0x0900:
+ eeprom->chip_type = TYPE_232H;
+ break;
+ case 0x0800:
+ eeprom->chip_type = TYPE_4232H;
+ break;
+ case 0x0700:
+ eeprom->chip_type = TYPE_2232H;
+ break;
case 0x0600:
eeprom->chip_type = TYPE_R;
break;
diff --git a/src/ftdi.h b/src/ftdi.h
index 0d94526..6253d6c 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -22,7 +22,7 @@
#define FTDI_DEFAULT_EEPROM_SIZE 128
/** FTDI chip type */
-enum ftdi_chip_type { TYPE_AM=0, TYPE_BM=1, TYPE_2232C=2, TYPE_R=3,
TYPE_2232H=4, TYPE_4232H=5 };
+enum ftdi_chip_type { TYPE_AM=0, TYPE_BM=1, TYPE_2232C=2, TYPE_R=3,
TYPE_2232H=4, TYPE_4232H=5, TYPE_232H = 6 };
/** Parity mode for ftdi_set_line_property() */
enum ftdi_parity_type { NONE=0, ODD=1, EVEN=2, MARK=3, SPACE=4 };
/** Number of stop bits for ftdi_set_line_property() */
--
1.7.3.4
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|