libftdi: (tomj) applied vala bindings, always document async mode
[libftdi] / src / ftdi.c
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