libftdi: (tomj) refactored USB part of libftdi, doesn't depend
[libftdi] / ftdi / ftdi.h
index 6fa8a60..4463fdf 100644 (file)
 #ifndef __libftdi_h__
 #define __libftdi_h__
 
-#include <usb.h>
+#include <sys/types.h>
+#include <limits.h>
+
+/* Kernel USB headers */
+#include <linux/usb.h>
+#include <linux/usbdevice_fs.h>
+
+enum ftdi_chip_type { TYPE_AM=0, TYPE_BM=1, TYPE_2232C=2 };
 
 struct ftdi_context {
     // USB specific
-    struct usb_dev_handle *usb_dev;
+    int usb_fd;
     int usb_read_timeout;
     int usb_write_timeout;
+    struct usbdevfs_urb *urb;
 
     // FTDI specific
+    enum ftdi_chip_type type;
     int baudrate;
     unsigned char bitbang_enabled;
     unsigned char *readbuffer;
@@ -40,8 +49,9 @@ struct ftdi_context {
     // Endpoints
     int in_ep;
     int out_ep;      // 1 or 2
-
-    int reading;     // 0 or 1 - for performance increase in SPI mode
+    
+    /* 1: (default) Normal bitbang mode, 2: FT2232C SPI bitbang mode */
+    unsigned char bitbang_mode;
 
     // misc
     char *error_str;
@@ -75,7 +85,6 @@ extern "C" {
 
     int ftdi_init(struct ftdi_context *ftdi);
     void ftdi_deinit(struct ftdi_context *ftdi);
-    void ftdi_set_usbdev (struct ftdi_context *ftdi, usb_dev_handle *usbdev);
     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);
@@ -98,12 +107,12 @@ 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
+    /* 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
+    /* "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, unsigned char *eeprom);
     int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
     int ftdi_erase_eeprom(struct ftdi_context *ftdi);