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