libftdi, ftdi_eeprom: (tomj) changed all email addresses to opensource@intra2net.com
[libftdi] / ftdi / ftdi.h
index 911bee0..9a025b8 100644 (file)
@@ -3,7 +3,7 @@
                              -------------------
     begin                : Fri Apr 4 2003
     copyright            : (C) 2003 by Intra2net AG
-    email                : info@intra2net.com
+    email                : opensource@intra2net.com
  ***************************************************************************/
 
 /***************************************************************************
@@ -17,7 +17,7 @@
 #ifndef __libftdi_h__
 #define __libftdi_h__
 
-struct usb_dev_handle;
+#include <usb.h>
 
 struct ftdi_context {
     // USB specific
@@ -32,6 +32,28 @@ struct ftdi_context {
     char *error_str;
 };
 
+struct ftdi_eeprom {
+    int        vendor_id;
+    int product_id;
+
+    int        self_powered;
+    int remote_wakeup;
+    int BM_type_chip;
+
+    int in_is_isochronous;
+    int out_is_isochronous;
+    int suspend_pull_downs;
+
+    int use_serial;
+    int change_usb_version;
+    int usb_version;
+    int max_power;
+    
+    char *manufacturer;
+    char *product;
+    char *serial;
+};
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -41,10 +63,11 @@ extern "C" {
     int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product);
     int ftdi_usb_close(struct ftdi_context *ftdi);
     int ftdi_usb_reset(struct ftdi_context *ftdi);
+    int ftdi_usb_purge_buffers(struct ftdi_context *ftdi);
 
     int ftdi_set_baudrate(struct ftdi_context *ftdi, int baudrate);
-    int ftdi_write_data(struct ftdi_context *ftdi, char *buf, int size);
-    int ftdi_read_data(struct ftdi_context *ftdi, char *buf, int size);
+    int ftdi_write_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
+    int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
 
     int ftdi_enable_bitbang(struct ftdi_context *ftdi, unsigned char bitmask);
     int ftdi_disable_bitbang(struct ftdi_context *ftdi);
@@ -53,11 +76,15 @@ extern "C" {
     int ftdi_set_latency_timer(struct ftdi_context *ftdi, unsigned char latency);
     int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency);
 
+    // init and build eeprom from ftdi_eeprom structure
+    void ftdi_eeprom_initdefaults(struct ftdi_eeprom *eeprom);
+    int  ftdi_eeprom_build(struct ftdi_eeprom *eeprom, unsigned char *output);
+
     // "eeprom" needs to be valid 128 byte eeprom (generated by the eeprom generator)
     // the checksum of the eeprom is valided
-    int ftdi_read_eeprom(struct ftdi_context *ftdi, char *eeprom);
-    int ftdi_write_eeprom(struct ftdi_context *ftdi, char *eeprom);
-    int ftdi_erase(struct ftdi_context *ftdi);
+    int ftdi_read_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
+    int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
+    int ftdi_erase_eeprom(struct ftdi_context *ftdi);
 
 #ifdef __cplusplus
 }