source: mainline/uspace/lib/usb/usb.h@ 7034be15

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 7034be15 was 91db50ac, checked in by Vojtech Horky <vojtechhorky@…>, 15 years ago

USB driver to HC communication uses DDF interfaces

Started work on using interfaces on the background of communication
between HC and USB driver. However, for driver developers, this will
be hidden completely.

  • Property mode set to 100644
File size: 2.9 KB
Line 
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#include <ipc/ipc.h>
40
41/** USB transfer type. */
42typedef enum {
43 USB_TRANSFER_CONTROL = 0,
44 USB_TRANSFER_ISOCHRONOUS = 1,
45 USB_TRANSFER_BULK = 2,
46 USB_TRANSFER_INTERRUPT = 3
47} usb_transfer_type_t;
48
49const char * usb_str_transfer_type(usb_transfer_type_t t);
50
51/** USB data transfer direction. */
52typedef enum {
53 USB_DIRECTION_IN,
54 USB_DIRECTION_OUT
55} usb_direction_t;
56
57/** USB transaction outcome. */
58typedef enum {
59 USB_OUTCOME_OK,
60 USB_OUTCOME_CRCERROR,
61 USB_OUTCOME_BABBLE
62} usb_transaction_outcome_t;
63
64const char * usb_str_transaction_outcome(usb_transaction_outcome_t o);
65
66/** USB address type.
67 * Negative values could be used to indicate error.
68 */
69typedef int usb_address_t;
70
71/** USB endpoint number type.
72 * Negative values could be used to indicate error.
73 */
74typedef int usb_endpoint_t;
75
76/** Maximum endpoint number in USB 1.1.
77 */
78#define USB11_ENDPOINT_MAX 16
79
80
81/** USB complete address type.
82 * Pair address + endpoint is identification of transaction recipient.
83 */
84typedef struct {
85 usb_address_t address;
86 usb_endpoint_t endpoint;
87} usb_target_t;
88
89static inline int usb_target_same(usb_target_t a, usb_target_t b)
90{
91 return (a.address == b.address)
92 && (a.endpoint == b.endpoint);
93}
94
95/** General handle type.
96 * Used by various USB functions as opaque handle.
97 */
98typedef ipcarg_t usb_handle_t;
99
100#endif
101/**
102 * @}
103 */
Note: See TracBrowser for help on using the repository browser.