libftdi-git Archives

Subject: port libftdi to libusb-1.0 branch, master, updated. v0.17-208-g18199b7

From: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 28 Jun 2011 16:32:38 +0200 (CEST)
The branch, master has been updated
       via  18199b76ecd68cee86b71111fe1a8af77e0631e3 (commit)
      from  837a71d6c580972b9638588a50cec5fbb035add6 (commit)


- Log -----------------------------------------------------------------
commit 18199b76ecd68cee86b71111fe1a8af77e0631e3
Author: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date:   Fri Jun 17 20:11:43 2011 +0200

    FT232h: Handle the FT1284 Mode bits

-----------------------------------------------------------------------

Summary of changes:
 src/ftdi.c |   43 +++++++++++++++++++++++++++++++++++++++++--
 src/ftdi.h |   13 +++++++++++--
 2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index ed2bbe0..b6dba79 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -2667,7 +2667,18 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
                 output[0x01] |= POWER_SAVE_DISABLE_H;
             else
                 output[0x01] &= ~POWER_SAVE_DISABLE_H;
-
+            if (eeprom->clock_polarity)
+                output[0x01] |= FT1284_CLK_IDLE_STATE;
+            else
+                output[0x01] &= ~FT1284_CLK_IDLE_STATE;
+            if (eeprom->data_order)
+                output[0x01] |= FT1284_DATA_LSB;
+            else
+                output[0x01] &= ~FT1284_DATA_LSB;
+            if (eeprom->flow_control)
+                output[0x01] |= FT1284_FLOW_CONTROL;
+            else
+                output[0x01] &= ~FT1284_FLOW_CONTROL;
             if (eeprom->group0_drive > DRIVE_16MA)
                 output[0x0c] |= DRIVE_16MA;
             else
@@ -2929,6 +2940,9 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int 
verbose)
     {
         eeprom->channel_a_type   = buf[0x00] & 0xf;
         eeprom->channel_a_driver = (buf[0x00] & DRIVER_VCPH)?DRIVER_VCP:0;
+        eeprom->clock_polarity =  buf[0x01]       & FT1284_CLK_IDLE_STATE;
+        eeprom->data_order     =  buf[0x01]       & FT1284_DATA_LSB;
+        eeprom->flow_control   =  buf[0x01]       & FT1284_FLOW_CONTROL;
         eeprom->powersave      =  buf[0x01]       & POWER_SAVE_DISABLE_H;
         eeprom->group0_drive   =  buf[0x0c]       & DRIVE_16MA;
         eeprom->group0_schmitt =  buf[0x0c]       & IS_SCHMITT;
@@ -2981,6 +2995,13 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int 
verbose)
                     channel_mode[eeprom->channel_a_type],
                     (eeprom->channel_a_driver)?" VCP":"",
                     (eeprom->high_current_a)?" High Current IO":"");
+        if (ftdi->type >= TYPE_232H)
+        {
+            fprintf(stdout,"FT1284 Mode Clock is idle %s, %s first, %sFlow 
Control\n",
+                    (eeprom->clock_polarity)?"HIGH":"LOW",
+                    (eeprom->data_order)?"LSB":"MSB",
+                    (eeprom->flow_control)?"":"No ");
+        }        
         if ((ftdi->type >= TYPE_2232C) && (ftdi->type != TYPE_R) && 
(ftdi->type != TYPE_232H))
             fprintf(stdout,"Channel B has Mode %s%s%s\n",
                     channel_mode[eeprom->channel_b_type],
@@ -3188,7 +3209,16 @@ int ftdi_get_eeprom_value(struct ftdi_context *ftdi, 
enum ftdi_eeprom_value valu
          case POWER_SAVE:
             *value = ftdi->eeprom->powersave;
             break;
-        case CHIP_TYPE:
+          case CLOCK_POLARITY:
+            *value = ftdi->eeprom->clock_polarity;
+            break;
+         case DATA_ORDER:
+            *value = ftdi->eeprom->data_order;
+            break;
+         case FLOW_CONTROL:
+            *value = ftdi->eeprom->flow_control;
+            break;
+       case CHIP_TYPE:
             *value = ftdi->eeprom->chip;
             break;
         case CHIP_SIZE:
@@ -3330,6 +3360,15 @@ int ftdi_set_eeprom_value(struct ftdi_context *ftdi, 
enum ftdi_eeprom_value valu
          case POWER_SAVE:
             ftdi->eeprom->powersave = value;
             break;
+         case CLOCK_POLARITY:
+            ftdi->eeprom->clock_polarity = value;
+            break;
+         case DATA_ORDER:
+            ftdi->eeprom->data_order = value;
+            break;
+         case FLOW_CONTROL:
+            ftdi->eeprom->flow_control = value;
+            break;
         case CHIP_SIZE:
             ftdi_error_return(-2, "EEPROM Value can't be changed");
         default :
diff --git a/src/ftdi.h b/src/ftdi.h
index dd442df..22e1197 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -273,6 +273,10 @@ struct ftdi_eeprom
     int group3_slew;
 
     int powersave;
+    
+    int clock_polarity;
+    int data_order;
+    int flow_control;
 
     /** eeprom size in bytes. This doesn't get stored in the eeprom
         but is the only way to pass it to ftdi_eeprom_build. */
@@ -387,7 +391,10 @@ enum ftdi_eeprom_value
     GROUP3_SLEW        = 37,
     CHIP_SIZE          = 38,
     CHIP_TYPE          = 39,
-    POWER_SAVE         = 40
+    POWER_SAVE         = 40,
+    CLOCK_POLARITY     = 41,
+    DATA_ORDER         = 42,
+    FLOW_CONTROL       = 43
 };
 
 /**
@@ -400,7 +407,9 @@ struct ftdi_device_list
     /** pointer to libusb's usb_device */
     struct libusb_device *dev;
 };
-
+#define FT1284_CLK_IDLE_STATE 0x01
+#define FT1284_DATA_LSB       0x02
+#define FT1284_FLOW_CONTROL   0x04
 #define POWER_SAVE_DISABLE_H 0x80
 
 #define USE_SERIAL_NUM 0x08


hooks/post-receive
-- 
port libftdi to libusb-1.0

--
libftdi-git - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread
  • port libftdi to libusb-1.0 branch, master, updated. v0.17-208-g18199b7, libftdi-git <=