40 #define LIBUSB_PATH_MAX 512
53 #define USB_CLASS_PER_INTERFACE 0
54 #define USB_CLASS_AUDIO 1
55 #define USB_CLASS_COMM 2
56 #define USB_CLASS_HID 3
57 #define USB_CLASS_PRINTER 7
58 #define USB_CLASS_MASS_STORAGE 8
59 #define USB_CLASS_HUB 9
60 #define USB_CLASS_DATA 10
61 #define USB_CLASS_VENDOR_SPEC 0xff
66 #define USB_DT_DEVICE 0x01
67 #define USB_DT_CONFIG 0x02
68 #define USB_DT_STRING 0x03
69 #define USB_DT_INTERFACE 0x04
70 #define USB_DT_ENDPOINT 0x05
72 #define USB_DT_HID 0x21
73 #define USB_DT_REPORT 0x22
74 #define USB_DT_PHYSICAL 0x23
75 #define USB_DT_HUB 0x29
80 #define USB_DT_DEVICE_SIZE 18
81 #define USB_DT_CONFIG_SIZE 9
82 #define USB_DT_INTERFACE_SIZE 9
83 #define USB_DT_ENDPOINT_SIZE 7
84 #define USB_DT_ENDPOINT_AUDIO_SIZE 9
85 #define USB_DT_HUB_NONVAR_SIZE 7
94 unsigned char bLength;
95 unsigned char bDescriptorType;
100 unsigned char bLength;
101 unsigned char bDescriptorType;
102 unsigned short wData[1];
107 unsigned char bLength;
108 unsigned char bDescriptorType;
109 unsigned short bcdHID;
110 unsigned char bCountryCode;
111 unsigned char bNumDescriptors;
115 #define USB_MAXENDPOINTS 32
117 unsigned char bLength;
118 unsigned char bDescriptorType;
119 unsigned char bEndpointAddress;
120 unsigned char bmAttributes;
121 unsigned short wMaxPacketSize;
122 unsigned char bInterval;
123 unsigned char bRefresh;
124 unsigned char bSynchAddress;
126 unsigned char *extra;
130 #define USB_ENDPOINT_ADDRESS_MASK 0x0f
131 #define USB_ENDPOINT_DIR_MASK 0x80
133 #define USB_ENDPOINT_TYPE_MASK 0x03
134 #define USB_ENDPOINT_TYPE_CONTROL 0
135 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 1
136 #define USB_ENDPOINT_TYPE_BULK 2
137 #define USB_ENDPOINT_TYPE_INTERRUPT 3
140 #define USB_MAXINTERFACES 32
142 unsigned char bLength;
143 unsigned char bDescriptorType;
144 unsigned char bInterfaceNumber;
145 unsigned char bAlternateSetting;
146 unsigned char bNumEndpoints;
147 unsigned char bInterfaceClass;
148 unsigned char bInterfaceSubClass;
149 unsigned char bInterfaceProtocol;
150 unsigned char iInterface;
154 unsigned char *extra;
158 #define USB_MAXALTSETTING 128
167 #define USB_MAXCONFIG 8
169 unsigned char bLength;
170 unsigned char bDescriptorType;
171 unsigned short wTotalLength;
172 unsigned char bNumInterfaces;
173 unsigned char bConfigurationValue;
174 unsigned char iConfiguration;
175 unsigned char bmAttributes;
176 unsigned char MaxPower;
180 unsigned char *extra;
186 unsigned char bLength;
187 unsigned char bDescriptorType;
188 unsigned short bcdUSB;
189 unsigned char bDeviceClass;
190 unsigned char bDeviceSubClass;
191 unsigned char bDeviceProtocol;
192 unsigned char bMaxPacketSize0;
193 unsigned short idVendor;
194 unsigned short idProduct;
195 unsigned short bcdDevice;
196 unsigned char iManufacturer;
197 unsigned char iProduct;
198 unsigned char iSerialNumber;
199 unsigned char bNumConfigurations;
203 unsigned char bRequestType;
204 unsigned char bRequest;
205 unsigned short wValue;
206 unsigned short wIndex;
207 unsigned short wLength;
213 #define USB_REQ_GET_STATUS 0x00
214 #define USB_REQ_CLEAR_FEATURE 0x01
216 #define USB_REQ_SET_FEATURE 0x03
218 #define USB_REQ_SET_ADDRESS 0x05
219 #define USB_REQ_GET_DESCRIPTOR 0x06
220 #define USB_REQ_SET_DESCRIPTOR 0x07
221 #define USB_REQ_GET_CONFIGURATION 0x08
222 #define USB_REQ_SET_CONFIGURATION 0x09
223 #define USB_REQ_GET_INTERFACE 0x0A
224 #define USB_REQ_SET_INTERFACE 0x0B
225 #define USB_REQ_SYNCH_FRAME 0x0C
227 #define USB_TYPE_STANDARD (0x00 << 5)
228 #define USB_TYPE_CLASS (0x01 << 5)
229 #define USB_TYPE_VENDOR (0x02 << 5)
230 #define USB_TYPE_RESERVED (0x03 << 5)
232 #define USB_RECIP_DEVICE 0x00
233 #define USB_RECIP_INTERFACE 0x01
234 #define USB_RECIP_ENDPOINT 0x02
235 #define USB_RECIP_OTHER 0x03
241 #define USB_ENDPOINT_IN 0x80
242 #define USB_ENDPOINT_OUT 0x00
245 #define USB_ERROR_BEGIN 500000
251 #define USB_LE16_TO_CPU(x)
260 char filename[LIBUSB_PATH_MAX];
269 unsigned char devnum;
271 unsigned char num_children;
278 char dirname[LIBUSB_PATH_MAX];
281 unsigned long location;
303 struct usb_dev_handle;
304 typedef struct usb_dev_handle usb_dev_handle;
308 #define usb_busses usb_get_busses()
316 #if defined(__cplusplus) || defined(__XC__)
323 usb_dev_handle *usb_open(
struct usb_device *dev);
324 int usb_close(usb_dev_handle *dev);
325 int usb_get_string(usb_dev_handle *dev,
int index,
int langid,
char *buf,
327 int usb_get_string_simple(usb_dev_handle *dev,
int index,
char *buf,
331 int usb_get_descriptor_by_endpoint(usb_dev_handle *udev,
int ep,
332 unsigned char type,
unsigned char index,
333 void *buf,
int size);
334 int usb_get_descriptor(usb_dev_handle *udev,
unsigned char type,
335 unsigned char index,
void *buf,
int size);
338 int usb_bulk_write(usb_dev_handle *dev,
int ep,
char *bytes,
int size,
340 int usb_bulk_read(usb_dev_handle *dev,
int ep,
char *bytes,
int size,
342 int usb_interrupt_write(usb_dev_handle *dev,
int ep,
char *bytes,
int size,
344 int usb_interrupt_read(usb_dev_handle *dev,
int ep,
char *bytes,
int size,
346 int usb_control_msg(usb_dev_handle *dev,
int requesttype,
int request,
347 int value,
int index,
char *bytes,
int size,
349 int usb_set_configuration(usb_dev_handle *dev,
int configuration);
350 int usb_claim_interface(usb_dev_handle *dev,
int interface);
351 int usb_release_interface(usb_dev_handle *dev,
int interface);
352 int usb_set_altinterface(usb_dev_handle *dev,
int alternate);
353 int usb_resetep(usb_dev_handle *dev,
unsigned int ep);
354 int usb_clear_halt(usb_dev_handle *dev,
unsigned int ep);
355 int usb_reset(usb_dev_handle *dev);
357 char *usb_strerror(
void);
360 void usb_set_debug(
int level);
361 int usb_find_busses(
void);
362 int usb_find_devices(
void);
364 struct usb_bus *usb_get_busses(
void);
369 #define LIBUSB_HAS_INSTALL_SERVICE_NP 1
370 int usb_install_service_np(
void);
371 void CALLBACK usb_install_service_np_rundll(HWND wnd, HINSTANCE instance,
372 LPSTR cmd_line,
int cmd_show);
374 #define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1
375 int usb_uninstall_service_np(
void);
376 void CALLBACK usb_uninstall_service_np_rundll(HWND wnd, HINSTANCE instance,
377 LPSTR cmd_line,
int cmd_show);
379 #define LIBUSB_HAS_INSTALL_DRIVER_NP 1
380 int usb_install_driver_np(
const char *inf_file);
381 void CALLBACK usb_install_driver_np_rundll(HWND wnd, HINSTANCE instance,
382 LPSTR cmd_line,
int cmd_show);
384 #define LIBUSB_HAS_TOUCH_INF_FILE_NP 1
385 int usb_touch_inf_file_np(
const char *inf_file);
386 void CALLBACK usb_touch_inf_file_np_rundll(HWND wnd, HINSTANCE instance,
387 LPSTR cmd_line,
int cmd_show);
389 #define LIBUSB_HAS_INSTALL_NEEDS_RESTART_NP 1
390 int usb_install_needs_restart_np(
void);
394 int usb_isochronous_setup_async(usb_dev_handle *dev,
void **context,
395 unsigned char ep,
int pktsize);
396 int usb_bulk_setup_async(usb_dev_handle *dev,
void **context,
398 int usb_interrupt_setup_async(usb_dev_handle *dev,
void **context,
401 int usb_submit_async(
void *context,
char *bytes,
int size);
402 int usb_reap_async(
void *context,
int timeout);
403 int usb_reap_async_nocancel(
void *context,
int timeout);
404 int usb_cancel_async(
void *context);
405 int usb_free_async(
void **context);
408 #if defined(__cplusplus) || defined(__XC__)