libftdi: (tomj) added libusb dependency to configure.in, removed "configure" from CVS
[libftdi] / ftdi / ftdi.h
1 /***************************************************************************
2                           ftdi.h  -  description
3                              -------------------
4     begin                : Fri Apr 4 2003
5     copyright            : (C) 2003 by Intra2net AG
6     email                : info@intra2net.com
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU Lesser General Public License           *
13  *   version 2.1 as published by the Free Software Foundation;             *
14  *                                                                         *
15  ***************************************************************************/
16
17 #ifndef __libftdi_h__
18 #define __libftdi_h__
19
20 struct usb_dev_handle;
21
22 struct ftdi_context {
23     // USB specific
24     struct usb_dev_handle *usb_dev;
25     int usb_timeout;
26
27     // FTDI specific
28     int baudrate;
29     unsigned char bitbang_enabled;
30
31     // misc
32     char *error_str;
33 };
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39     int ftdi_init(struct ftdi_context *ftdi);
40     void ftdi_set_usbdev (struct ftdi_context *ftdi, usb_dev_handle *usbdev);
41     int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product);
42     int ftdi_usb_close(struct ftdi_context *ftdi);
43     int ftdi_usb_reset(struct ftdi_context *ftdi);
44
45     int ftdi_set_baudrate(struct ftdi_context *ftdi, int baudrate);
46     int ftdi_write_data(struct ftdi_context *ftdi, char *buf, int size);
47     int ftdi_read_data(struct ftdi_context *ftdi, char *buf, int size);
48
49     int ftdi_enable_bitbang(struct ftdi_context *ftdi, unsigned char bitmask);
50     int ftdi_disable_bitbang(struct ftdi_context *ftdi);
51     int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins);
52
53     int ftdi_set_latency_timer(struct ftdi_context *ftdi, unsigned char latency);
54     int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency);
55
56     // "eeprom" needs to be valid 128 byte eeprom (generated by the eeprom generator)
57     // the checksum of the eeprom is valided
58     int ftdi_read_eeprom(struct ftdi_context *ftdi, char *eeprom);
59     int ftdi_write_eeprom(struct ftdi_context *ftdi, char *eeprom);
60     int ftdi_erase(struct ftdi_context *ftdi);
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif /* __libftdi_h__ */