[c56dbe0] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Jan Vesely
|
---|
| 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 | /** @addtogroup usb
|
---|
| 29 | * @{
|
---|
| 30 | */
|
---|
| 31 | /** @file
|
---|
| 32 | * @brief UHCI driver
|
---|
| 33 | */
|
---|
[3515533] | 34 | #include <assert.h>
|
---|
| 35 | #include <stdio.h>
|
---|
| 36 |
|
---|
[7ce0fe3] | 37 | #include <usb/debug.h>
|
---|
| 38 |
|
---|
[3515533] | 39 | #include "port_status.h"
|
---|
| 40 |
|
---|
[8f748215] | 41 | struct flag_name
|
---|
[3515533] | 42 | {
|
---|
[4d37c42] | 43 | uint16_t flag;
|
---|
[8f748215] | 44 | const char *name;
|
---|
| 45 | };
|
---|
| 46 |
|
---|
| 47 | static const struct flag_name flags[] =
|
---|
| 48 | {
|
---|
| 49 | { STATUS_SUSPEND, "suspended" },
|
---|
| 50 | { STATUS_IN_RESET, "in reset" },
|
---|
| 51 | { STATUS_LOW_SPEED, "low speed device" },
|
---|
| 52 | { STATUS_ALWAYS_ONE, "always 1 bit" },
|
---|
| 53 | { STATUS_RESUME, "resume" },
|
---|
| 54 | { STATUS_LINE_D_MINUS, "line D- value" },
|
---|
| 55 | { STATUS_LINE_D_PLUS, "line D+ value" },
|
---|
| 56 | { STATUS_ENABLED_CHANGED, "enabled changed" },
|
---|
| 57 | { STATUS_ENABLED, "enabled" },
|
---|
| 58 | { STATUS_CONNECTED_CHANGED, "connected changed" },
|
---|
| 59 | { STATUS_CONNECTED, "connected" }
|
---|
| 60 | };
|
---|
| 61 |
|
---|
[275bf456] | 62 | /** Prints portr status in a human readable way.
|
---|
| 63 | *
|
---|
| 64 | * @param[in] value Port value to print.
|
---|
| 65 | * @return Error code.
|
---|
| 66 | */
|
---|
[8f748215] | 67 | void print_port_status(port_status_t value)
|
---|
| 68 | {
|
---|
| 69 | unsigned i = 0;
|
---|
| 70 | for (;i < sizeof(flags)/sizeof(struct flag_name); ++i) {
|
---|
[1f5c1e61] | 71 | usb_log_debug2("\t%s status: %s.\n", flags[i].name,
|
---|
[4d37c42] | 72 | ((value & flags[i].flag) != 0) ? "YES" : "NO");
|
---|
[8f748215] | 73 | }
|
---|
[3515533] | 74 | }
|
---|
[c56dbe0] | 75 | /**
|
---|
| 76 | * @}
|
---|
| 77 | */
|
---|