Rev 197 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
195 | f9daq | 1 | /********************************************************************\ |
2 | |||
3 | Name: musbstd.h |
||
4 | Created by: Konstantin Olchanski, Stefan Ritt |
||
5 | |||
6 | Contents: Midas USB access |
||
7 | |||
8 | $Id$ |
||
9 | |||
10 | \********************************************************************/ |
||
11 | |||
12 | #ifndef MUSBSTD_H |
||
13 | #define MUSBSTD_H |
||
14 | |||
15 | #if defined(HAVE_LIBUSB) |
||
16 | |||
17 | #include "usb.h" |
||
18 | |||
19 | typedef struct { |
||
20 | usb_dev_handle *dev; |
||
21 | int usb_configuration; |
||
22 | int usb_interface; |
||
23 | int usb_type; |
||
24 | } MUSB_INTERFACE; |
||
25 | |||
26 | #elif defined(HAVE_LIBUSB10) |
||
27 | |||
28 | #include <libusb-1.0/libusb.h> |
||
29 | |||
30 | typedef struct { |
||
31 | libusb_device_handle *dev; |
||
32 | int usb_configuration; |
||
33 | int usb_interface; |
||
34 | int usb_type; |
||
35 | } MUSB_INTERFACE; |
||
36 | |||
37 | #elif defined(_MSC_VER) |
||
38 | |||
39 | #include <windows.h> |
||
40 | |||
41 | typedef struct { |
||
42 | HANDLE rhandle; |
||
43 | HANDLE whandle; |
||
44 | int usb_type; |
||
45 | } MUSB_INTERFACE; |
||
46 | |||
47 | #elif defined(OS_DARWIN) |
||
48 | |||
49 | typedef struct { |
||
50 | void *device; |
||
51 | void *interface; |
||
52 | int usb_configuration; |
||
53 | int usb_interface; |
||
54 | int usb_type; |
||
55 | } MUSB_INTERFACE; |
||
56 | |||
57 | #else |
||
58 | #error Do not know how to access USB devices |
||
59 | #endif |
||
60 | |||
61 | /*---- status codes ------------------------------------------------*/ |
||
62 | |||
63 | #define MUSB_SUCCESS 1 |
||
64 | #define MUSB_NOT_FOUND 2 |
||
65 | #define MUSB_INVALID_PARAM 3 |
||
66 | #define MUSB_NO_MEM 4 |
||
67 | #define MUSB_ACCESS_ERROR 5 |
||
68 | |||
69 | /* make functions callable from a C++ program */ |
||
70 | #ifdef __cplusplus |
||
71 | extern "C" { |
||
72 | #endif |
||
73 | |||
74 | /* make functions under WinNT dll exportable */ |
||
75 | #ifndef EXPRT |
||
76 | #if defined(_MSC_VER) && defined(_USRDLL) |
||
77 | #define EXPRT __declspec(dllexport) |
||
78 | #else |
||
79 | #define EXPRT |
||
80 | #endif |
||
81 | #endif |
||
82 | |||
83 | int EXPRT musb_open(MUSB_INTERFACE **musb_interface, int vendor, int product, int instance, int configuration, int usbinterface); |
||
84 | int EXPRT musb_close(MUSB_INTERFACE *musb_interface); |
||
85 | int EXPRT musb_write(MUSB_INTERFACE *musb_interface,int endpoint,const void *buf,int count,int timeout_ms); |
||
86 | int EXPRT musb_read(MUSB_INTERFACE *musb_interface,int endpoint,void *buf,int count,int timeout_ms); |
||
87 | int EXPRT musb_reset(MUSB_INTERFACE *musb_interface); |
||
88 | int EXPRT musb_set_altinterface(MUSB_INTERFACE *musb_interface, int index); |
||
89 | int EXPRT musb_get_device(MUSB_INTERFACE *musb_interface); |
||
90 | |||
91 | #ifdef __cplusplus |
||
92 | } |
||
93 | #endif |
||
94 | |||
95 | #endif // MUSBSTD_H |