libftdi: (tomj) first shot at doxygen documentation
[libftdi] / src / ftdi.h
index 4134351..1603dd4 100644 (file)
 #include <usb.h>
 
 enum ftdi_chip_type { TYPE_AM=0, TYPE_BM=1, TYPE_2232C=2 };
+enum ftdi_parity_type { NONE=0, ODD=1, EVEN=2, MARK=3, SPACE=4 };
+enum ftdi_stopbits_type { STOP_BIT_1=0, STOP_BIT_15=1, STOP_BIT_2=2 };
+enum ftdi_bits_type { BITS_7=7, BITS_8=8 };
+
 enum ftdi_mpsse_mode {
     BITMODE_RESET  = 0x00,
     BITMODE_BITBANG= 0x01,
@@ -78,6 +82,36 @@ enum ftdi_interface {
 /* Address High */
 /* Address Low  */
 
+/* Definitions for flow control */
+/*
+ * Flow control code adapted from Linux kernel sources
+ * by Lorenz Moesenlechner (lorenz@hcilab.org) and 
+ * Matthias Kranz  (matthias@hcilab.org)
+ * */
+#define SIO_MODEM_CTRL     1 /* Set the modem control register */
+#define SIO_SET_FLOW_CTRL  2 /* Set flow control register */
+
+#define SIO_SET_FLOW_CTRL_REQUEST_TYPE 0x40
+#define SIO_SET_FLOW_CTRL_REQUEST SIO_SET_FLOW_CTRL
+
+#define SIO_DISABLE_FLOW_CTRL 0x0 
+#define SIO_RTS_CTS_HS (0x1 << 8)
+#define SIO_DTR_DSR_HS (0x2 << 8)
+#define SIO_XON_XOFF_HS (0x4 << 8)
+
+#define SIO_SET_MODEM_CTRL_REQUEST_TYPE 0x40
+#define SIO_SET_MODEM_CTRL_REQUEST SIO_MODEM_CTRL
+
+#define SIO_SET_DTR_MASK 0x1
+#define SIO_SET_DTR_HIGH ( 1 | ( SIO_SET_DTR_MASK  << 8))
+#define SIO_SET_DTR_LOW  ( 0 | ( SIO_SET_DTR_MASK  << 8))
+#define SIO_SET_RTS_MASK 0x2
+#define SIO_SET_RTS_HIGH ( 2 | ( SIO_SET_RTS_MASK << 8 ))
+#define SIO_SET_RTS_LOW ( 0 | ( SIO_SET_RTS_MASK << 8 ))
+
+#define SIO_RTS_CTS_HS (0x1 << 8)
+
+
 struct ftdi_context {
     // USB specific
     struct usb_dev_handle *usb_dev;
@@ -108,6 +142,11 @@ struct ftdi_context {
     char *error_str;
 };
 
+struct ftdi_device_list {
+    struct ftdi_device_list *next;
+    struct usb_device *dev;
+};
+
 struct ftdi_eeprom {
     int vendor_id;
     int product_id;
@@ -135,18 +174,27 @@ extern "C" {
 #endif
 
     int ftdi_init(struct ftdi_context *ftdi);
-    int ftdi_select_interfae(struct ftdi_context *ftdi, enum ftdi_interface interface);
+    int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface);
 
     void ftdi_deinit(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);
+
     int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product);
     int ftdi_usb_open_desc(struct ftdi_context *ftdi, int vendor, int product,
                            const char* description, const char* serial);
+    int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct usb_device *dev);
+
     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_set_line_property(struct ftdi_context *ftdi, enum ftdi_bits_type bits,
+                               enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity);
 
     int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
     int ftdi_read_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize);
@@ -176,6 +224,15 @@ extern "C" {
 
     char *ftdi_get_error_string(struct ftdi_context *ftdi);
 
+    /*
+     * Flow control code adapted from Linux kernel sources
+     * by Lorenz Moesenlechner (lorenz@hcilab.org) and 
+     * Matthias Kranz  (matthias@hcilab.org)
+     * */
+    int ftdi_setflowctrl(struct ftdi_context *ftdi, int flowctrl);
+    int ftdi_setdtr(struct ftdi_context *ftdi, int state);
+    int ftdi_setrts(struct ftdi_context *ftdi, int state);
+
 #ifdef __cplusplus
 }
 #endif