libftdi, display, lcdproc: (gerd) fix async usb writes, fix write timing & concurrency
[libftdi] / src / ftdi.h
index fd0d357..ff72d05 100644 (file)
@@ -20,7 +20,7 @@
 #include <usb.h>
 
 /// FTDI chip type
-enum ftdi_chip_type { TYPE_AM=0, TYPE_BM=1, TYPE_2232C=2 };
+enum ftdi_chip_type { TYPE_AM=0, TYPE_BM=1, TYPE_2232C=2, TYPE_R=3 };
 /// 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()
@@ -113,6 +113,10 @@ enum ftdi_interface {
 
 #define SIO_RTS_CTS_HS (0x1 << 8)
 
+/* marker for unused usb urb structures
+   (taken from libusb) */
+#define FTDI_URB_USERCONTEXT_COOKIE ((void *)0x1)
+
 /**
     \brief Main context structure for all libftdi functions.
 
@@ -160,6 +164,11 @@ struct ftdi_context {
 
     /// String representation of last error
     char *error_str;
+
+    /// Buffer needed for async communication
+    char *async_usb_buffer;
+    /// Number of URB-structures we can buffer
+    unsigned int async_usb_buffer_size;
 };
 
 /**
@@ -251,6 +260,9 @@ extern "C" {
     int ftdi_write_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize);
     int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize);
 
+    int ftdi_write_data_async(struct ftdi_context *ftdi, unsigned char *buf, int size);
+    void ftdi_async_complete(struct ftdi_context *ftdi, int wait_for_more);
+
     int ftdi_enable_bitbang(struct ftdi_context *ftdi, unsigned char bitmask);
     int ftdi_disable_bitbang(struct ftdi_context *ftdi);
     int ftdi_set_bitmode(struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode);
@@ -266,6 +278,7 @@ extern "C" {
     // "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_read_chipid(struct ftdi_context *ftdi, unsigned int *chipid);
     int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
     int ftdi_erase_eeprom(struct ftdi_context *ftdi);