eXpand your USB potential
|
Macros | |
#define | LIBUSB_CALL |
libusbx's Windows calling convention. | |
#define | LIBUSBX_API_VERSION 0x010000FF |
libusbx's API version. | |
#define | libusb_le16_to_cpu libusb_cpu_to_le16 |
Convert a 16-bit value from little-endian to host-endian format. | |
Functions | |
int | libusb_has_capability (uint32_t capability) |
Check at runtime if the loaded library has a given capability. | |
const char * | libusb_error_name (int error_code) |
Returns a constant NULL-terminated string with the ASCII name of a libusb error or transfer status code. | |
struct libusb_version * | libusb_get_version (void) |
Returns a pointer to const struct libusb_version with the version (major, minor, micro, nano and rc) of the running library. | |
#define LIBUSB_CALL |
libusbx's Windows calling convention.
Under Windows, the selection of available compilers and configurations means that, unlike other platforms, there is not one true calling convention (calling convention: the manner in which parameters are passed to funcions in the generated assembly code).
Matching the Windows API itself, libusbx uses the WINAPI convention (which translates to the stdcall
convention) and guarantees that the library is compiled in this way. The public header file also includes appropriate annotations so that your own software will use the right convention, even if another convention is being used by default within your codebase.
The one consideration that you must apply in your software is to mark all functions which you use as libusbx callbacks with this LIBUSB_CALL annotation, so that they too get compiled for the correct calling convention.
On non-Windows operating systems, this macro is defined as nothing. This means that you can apply it to your code without worrying about cross-platform compatibility.
#define LIBUSBX_API_VERSION 0x010000FF |
libusbx's API version.
Since version 1.0.13, to help with feature detection, libusbx defines a LIBUSBX_API_VERSION macro that gets increased every time there is a significant change to the API, such as the introduction of a new call, the definition of a new macro/enum member, or any other element that libusbx applications may want to detect at compilation time.
The macro is typically used in an application as follows:
Another feature of LIBUSBX_API_VERSION is that it can be used to detect whether you are compiling against the libusb or the libusbx library.
Internally, LIBUSBX_API_VERSION is defined as follows: (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental)
#define libusb_le16_to_cpu libusb_cpu_to_le16 |
Convert a 16-bit value from little-endian to host-endian format.
On little endian systems, this function does nothing. On big endian systems, the bytes are swapped.
x | the little-endian value to convert |
Standard requests, as defined in table 9-5 of the USB 3.0 specifications.
enum libusb_request_type |
Request type bits of the bmRequestType field in control transfers.
Enumerator | |
---|---|
LIBUSB_REQUEST_TYPE_STANDARD |
Standard. |
LIBUSB_REQUEST_TYPE_CLASS |
Class. |
LIBUSB_REQUEST_TYPE_VENDOR |
Vendor. |
LIBUSB_REQUEST_TYPE_RESERVED |
Reserved. |
Recipient bits of the bmRequestType field in control transfers.
Values 4 through 31 are reserved.
Enumerator | |
---|---|
LIBUSB_RECIPIENT_DEVICE |
Device. |
LIBUSB_RECIPIENT_INTERFACE |
Interface. |
LIBUSB_RECIPIENT_ENDPOINT |
Endpoint. |
LIBUSB_RECIPIENT_OTHER |
Other. |
enum libusb_error |
Error codes.
Most libusbx functions return 0 on success or one of these codes on failure. You can call libusb_error_name() to retrieve a string representation of an error code.
enum libusb_capability |
Capabilities supported by this instance of libusb.
Test if the loaded library supports a given capability by calling libusb_has_capability().
Enumerator | |
---|---|
LIBUSB_CAP_HAS_CAPABILITY |
The libusb_has_capability() API is available. |
int libusb_has_capability | ( | uint32_t | capability | ) |
Check at runtime if the loaded library has a given capability.
capability | the libusb_capability to check for |
const char* libusb_error_name | ( | int | error_code | ) |
Returns a constant NULL-terminated string with the ASCII name of a libusb error or transfer status code.
The caller must not free() the returned string.
error_code | The libusb_error or libusb_transfer_status code to return the name of. |