[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 |
|
---|
[3b77628] | 29 | /** @addtogroup libusb
|
---|
[fd17ab5] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
[a6add7a] | 33 | * Common USB functions.
|
---|
[fd17ab5] | 34 | */
|
---|
[4b4c797] | 35 | #include <usb/usb.h>
|
---|
[fd17ab5] | 36 | #include <errno.h>
|
---|
| 37 |
|
---|
[aaff605] | 38 | static const char *str_speed[] = {
|
---|
| 39 | "low",
|
---|
| 40 | "full",
|
---|
| 41 | "high"
|
---|
| 42 | };
|
---|
| 43 | static size_t str_speed_size = sizeof(str_speed)/sizeof(str_speed[0]);
|
---|
[fd17ab5] | 44 |
|
---|
[a6add7a] | 45 | /** String representation for USB transfer type.
|
---|
| 46 | *
|
---|
| 47 | * @param t Transfer type.
|
---|
| 48 | * @return Transfer type as a string (in English).
|
---|
| 49 | */
|
---|
[fd17ab5] | 50 | const char * usb_str_transfer_type(usb_transfer_type_t t)
|
---|
| 51 | {
|
---|
| 52 | switch (t) {
|
---|
| 53 | case USB_TRANSFER_ISOCHRONOUS:
|
---|
| 54 | return "isochronous";
|
---|
| 55 | case USB_TRANSFER_INTERRUPT:
|
---|
| 56 | return "interrupt";
|
---|
| 57 | case USB_TRANSFER_CONTROL:
|
---|
| 58 | return "control";
|
---|
| 59 | case USB_TRANSFER_BULK:
|
---|
| 60 | return "bulk";
|
---|
| 61 | default:
|
---|
| 62 | return "unknown";
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[aaff605] | 66 | /** String representation of USB speed.
|
---|
| 67 | *
|
---|
| 68 | * @param s The speed.
|
---|
| 69 | * @return USB speed as a string (in English).
|
---|
| 70 | */
|
---|
| 71 | const char *usb_str_speed(usb_speed_t s)
|
---|
| 72 | {
|
---|
| 73 | if (s >= str_speed_size) {
|
---|
| 74 | return "invalid";
|
---|
| 75 | }
|
---|
| 76 | return str_speed[s];
|
---|
| 77 | }
|
---|
| 78 |
|
---|
[fd17ab5] | 79 | /**
|
---|
| 80 | * @}
|
---|
| 81 | */
|
---|