libftdi: (tomj) applied vala bindings, always document async mode
authorThomas Jarosch <opensource@intra2net.com>
Sat, 1 Mar 2008 09:36:22 +0000 (09:36 +0000)
committerThomas Jarosch <opensource@intra2net.com>
Sat, 1 Mar 2008 09:36:22 +0000 (09:36 +0000)
ChangeLog
doc/Doxyfile.in
src/ftdi.c
src/ftdi.h

index 1b92cc8..b01901d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 New in 0.11
 -----------
+* Vala bindings helper functions (ftdi_new, ftdi_free, ftdi_list_free2) (Even Nermerson)
 * Support for different EEPROM sizes (Andrew John Rogers, andrew@rogerstech.co.uk)
 * Async write support. Linux only and no error handling.
   You have to enable it via --with-async-code.
index f21766e..f455bca 100644 (file)
@@ -1012,7 +1012,7 @@ INCLUDE_FILE_PATTERNS  =
 # undefined via #undef or recursively expanded use the := operator 
 # instead of the = operator.
 
-PREDEFINED             = 
+PREDEFINED             = LIBFTDI_LINUX_ASYNC_MODE
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
 # this tag can be used to specify a list of macro names that should be expanded. 
index 16d86d1..9a80d7f 100644 (file)
@@ -105,6 +105,27 @@ int ftdi_init(struct ftdi_context *ftdi)
 }
 
 /**
+    Allocate and initialize a new ftdi_context
+
+    \return a pointer to a new ftdi_context, or NULL on failure
+*/
+struct ftdi_context *ftdi_new()
+{
+    struct ftdi_context * ftdi = (struct ftdi_context *)malloc(sizeof(struct ftdi_context));
+
+    if (ftdi == NULL) {
+        return NULL;
+    }
+
+    if (ftdi_init(ftdi) != 0) {
+        free(ftdi);
+       return NULL;
+    }
+
+    return ftdi;
+}
+
+/**
     Open selected channels on a chip, otherwise use first channel.
 
     \param ftdi pointer to ftdi_context
@@ -151,6 +172,17 @@ void ftdi_deinit(struct ftdi_context *ftdi)
 }
 
 /**
+    Deinitialize and free an ftdi_context.
+
+    \param ftdi pointer to ftdi_context
+*/
+void ftdi_free(struct ftdi_context *ftdi)
+{
+    ftdi_deinit(ftdi);
+    free(ftdi);
+}
+
+/**
     Use an already open libusb device.
 
     \param ftdi pointer to ftdi_context
@@ -231,6 +263,16 @@ void ftdi_list_free(struct ftdi_device_list **devlist)
 }
 
 /**
+    Frees a usb device list.
+
+    \param devlist USB device list created by ftdi_usb_find_all()
+*/
+void ftdi_list_free2(struct ftdi_device_list *devlist)
+{
+    ftdi_list_free(&devlist);
+}
+
+/**
     Return device ID strings from the usb device.
 
     The parameters manufacturer, description and serial may be NULL
@@ -903,6 +945,7 @@ static int _usb_bulk_write_async(struct ftdi_context *ftdi, int ep, char *bytes,
     caller of completion or error - but this is not done yet, volunteers welcome.
 
     Works around libusb and directly accesses functions only available on Linux.
+    Only available if compiled with --with-async-mode.
 
     \param ftdi pointer to ftdi_context
     \param buf Buffer with the data
index 7d5c212..e72cad2 100644 (file)
@@ -235,14 +235,17 @@ extern "C" {
 #endif
 
     int ftdi_init(struct ftdi_context *ftdi);
+    struct ftdi_context *ftdi_new();
     int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface);
 
     void ftdi_deinit(struct ftdi_context *ftdi);
+    void ftdi_free(struct ftdi_context *ftdi);
     void ftdi_set_usbdev (struct ftdi_context *ftdi, usb_dev_handle *usbdev);
 
     int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devlist,
                           int vendor, int product);
     void ftdi_list_free(struct ftdi_device_list **devlist);
+    void ftdi_list_free2(struct ftdi_device_list *devlist);
     int ftdi_usb_get_strings(struct ftdi_context *ftdi, struct usb_device *dev,
                              char * manufacturer, int mnf_len,
                              char * description, int desc_len,