-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusbhelper.h
More file actions
63 lines (49 loc) · 2.25 KB
/
usbhelper.h
File metadata and controls
63 lines (49 loc) · 2.25 KB
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
/*
* USBHELPER.H
* based on vusbdevice.h
*
* This is version 20150808T1200ZSB
*
* Stephan Baerwolf (matrixstorm@gmx.de), Schwansee 2015
* for http://matrixstorm.com/avr/tinyusbboard/
* (please contact me at least before commercial use)
*/
#ifndef __USBHELPER_H_e25922918d5d40bc99895958f02024b4
# define __USBHELPER_H_e25922918d5d40bc99895958f02024b4 1
# if defined(__unix__)
# include <usb.h> /* this is libusb, see http://libusb.sourceforge.net/ */
# else
# if (defined(_WIN32) || defined(_WIN64))
# include <lusb0_usb.h>
# else
# error unknown platform
# endif
# endif
#include <stdint.h>
#include <string.h>
#define USB_ERROR_NOTFOUND 1
#define USB_ERROR_ACCESS 2
#define USB_ERROR_IO 3
#define USB_ERROR_NOINIT 251
#ifdef __USBHELPER_C_e25922918d5d40bc99895958f02024b4
# define USBHELPERPUBLIC
#else
# define USBHELPERPUBLIC extern
#endif
USBHELPERPUBLIC int usbhelper_initialize(void);
USBHELPERPUBLIC int usbhelper_finalize(void);
USBHELPERPUBLIC int usbGetStringAscii(usb_dev_handle *dev, int index, int langid, char *buf, size_t buflen);
typedef int (*usbhelper_devicecallback_t)(const struct usb_bus *bus, const struct usb_device *dev, const usb_dev_handle *handle, const uint16_t vendor, const uint16_t product, const char *vendorName, const char *productName, const char *serial, void* userparameter);
/*
* Scan over all usb devices calling "mapfunc" for each.
* When "mapfunc" returns non-zero the scanning is terminated and the result used as return for "usbScanDevice".
* When "mapfunc" returns positive, device stays open for further use.
*/
USBHELPERPUBLIC int usbScanDevice(usb_dev_handle **device, const uint32_t busID, const uint8_t deviceID, const uint16_t idvendor, const uint16_t idproduct, usbhelper_devicecallback_t mapfunc, void* userparameter);
/*
* "usbOpenDevice" opens a spezial USB device.
* The Device primary is identified by its idVendor:idProduct.
* Because for most VUSB this is the same (free4all) 0x16C0:0x05DC, userdefinable identificationstrings are used here, too.
*/
USBHELPERPUBLIC int usbOpenDevice(usb_dev_handle **device, const uint32_t busID, const uint8_t deviceID, const uint16_t idvendor, const uint16_t idproduct, const char *vendorName, const char *productName, const char *serial);
#endif