[fd17ab5] | 1 | /*
|
---|
| 2 | * Copyright (c) 2010 Vojtech Horky
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup libusb usb
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * @brief Base USB types.
|
---|
| 34 | */
|
---|
| 35 | #ifndef LIBUSB_USB_H_
|
---|
| 36 | #define LIBUSB_USB_H_
|
---|
| 37 |
|
---|
| 38 | #include <sys/types.h>
|
---|
| 39 |
|
---|
| 40 | /** USB transfer type. */
|
---|
| 41 | typedef enum {
|
---|
| 42 | USB_TRANSFER_CONTROL = 0,
|
---|
| 43 | USB_TRANSFER_ISOCHRONOUS = 1,
|
---|
| 44 | USB_TRANSFER_BULK = 2,
|
---|
| 45 | USB_TRANSFER_INTERRUPT = 3
|
---|
| 46 | } usb_transfer_type_t;
|
---|
| 47 |
|
---|
| 48 | const char * usb_str_transfer_type(usb_transfer_type_t t);
|
---|
| 49 |
|
---|
| 50 | /** USB data transfer direction. */
|
---|
| 51 | typedef enum {
|
---|
| 52 | USB_DIRECTION_IN,
|
---|
| 53 | USB_DIRECTION_OUT
|
---|
| 54 | } usb_direction_t;
|
---|
| 55 |
|
---|
| 56 | /** USB address type.
|
---|
| 57 | * Negative values could be used to indicate error.
|
---|
| 58 | */
|
---|
| 59 | typedef int usb_address_t;
|
---|
| 60 |
|
---|
| 61 | /** USB endpoint number type.
|
---|
| 62 | * Negative values could be used to indicate error.
|
---|
| 63 | */
|
---|
| 64 | typedef int usb_endpoint_t;
|
---|
| 65 |
|
---|
[7a7bfeb3] | 66 | /** Maximum endpoint number in USB 1.1.
|
---|
| 67 | */
|
---|
| 68 | #define USB11_ENDPOINT_MAX 16
|
---|
| 69 |
|
---|
| 70 |
|
---|
[fd17ab5] | 71 | /** USB complete address type.
|
---|
| 72 | * Pair address + endpoint is identification of transaction recipient.
|
---|
| 73 | */
|
---|
| 74 | typedef struct {
|
---|
| 75 | usb_address_t address;
|
---|
| 76 | usb_endpoint_t endpoint;
|
---|
| 77 | } usb_target_t;
|
---|
| 78 |
|
---|
| 79 | static inline int usb_target_same(usb_target_t a, usb_target_t b)
|
---|
| 80 | {
|
---|
| 81 | return (a.address == b.address)
|
---|
| 82 | && (a.endpoint == b.endpoint);
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | #endif
|
---|
| 86 | /**
|
---|
| 87 | * @}
|
---|
| 88 | */
|
---|