]>
Commit | Line | Data |
---|---|---|
3608c106 UH |
1 | /** |
2 | * Copyright (C) 2009 Ubixum, Inc. | |
3 | * | |
4 | * This library is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU Lesser General Public | |
6 | * License as published by the Free Software Foundation; either | |
7 | * version 2.1 of the License, or (at your option) any later version. | |
8 | * | |
9 | * This library is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | * Lesser General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU Lesser General Public | |
15 | * License along with this library; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | **/ | |
18 | ||
19 | #ifndef FX2_H | |
20 | #define FX2_H | |
21 | ||
22 | #include <libusb-1.0/libusb.h> | |
23 | ||
24 | const int VID=0x04b4; | |
25 | const int PID=0x0082; | |
26 | ||
27 | class fx2 { | |
28 | ||
29 | private: | |
30 | libusb_context* libusb_ctx; | |
31 | libusb_device_handle* dev_handle; | |
32 | int interface,alt_setting; | |
33 | ||
34 | public: | |
35 | fx2(); | |
36 | ~fx2(); | |
37 | /** | |
38 | * open | |
39 | * vid = vendor id | |
40 | * pid = product id | |
41 | * idx = nth device if there are more than one. | |
42 | * | |
43 | * Opens device with vid,pid and claims alt 0 of interface 0 | |
44 | **/ | |
45 | void open(int vid=VID,int pid=PID, int idx=0); | |
46 | void set_interface(int interface, int alt_setting); | |
47 | bool isopen() { return dev_handle != NULL; } | |
48 | void close(); | |
49 | /** | |
50 | * level n = 0-3 | |
51 | */ | |
52 | void set_debug_level(int n); | |
53 | int do_usb_command(char* buf, int size, unsigned char type, unsigned char request, unsigned short value, unsigned short index, unsigned short length, int timeout=1000 ); | |
54 | int clear_halt(char ep); | |
55 | int reset(); | |
56 | int set_configuration(int config); | |
57 | bool ep_bulk(char* buf, int size, unsigned char ep, int timeout); | |
58 | ||
59 | }; | |
60 | ||
61 | #endif |