source: mainline/uspace/lib/usb/include/usb/usb.h@ 3b77628

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

Doxygen comment fixes

Mainly proper subgrouping and some missing @param comments.

  • Property mode set to 100644
File size: 4.0 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
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 request type target. */
58typedef enum {
59 USB_REQUEST_TYPE_STANDARD = 0,
60 USB_REQUEST_TYPE_CLASS = 1,
61 USB_REQUEST_TYPE_VENDOR = 2
62} usb_request_type_t;
63
64/** USB request recipient. */
65typedef enum {
66 USB_REQUEST_RECIPIENT_DEVICE = 0,
67 USB_REQUEST_RECIPIENT_INTERFACE = 1,
68 USB_REQUEST_RECIPIENT_ENDPOINT = 2
69} usb_request_recipient_t;
70
71/** USB transaction outcome. */
72typedef enum {
73 USB_OUTCOME_OK,
74 USB_OUTCOME_CRCERROR,
75 USB_OUTCOME_BABBLE
76} usb_transaction_outcome_t;
77
78const char * usb_str_transaction_outcome(usb_transaction_outcome_t o);
79
80/** USB address type.
81 * Negative values could be used to indicate error.
82 */
83typedef int usb_address_t;
84
85/** Default USB address. */
86#define USB_ADDRESS_DEFAULT 0
87/** Maximum address number in USB 1.1. */
88#define USB11_ADDRESS_MAX 128
89
90/** USB endpoint number type.
91 * Negative values could be used to indicate error.
92 */
93typedef int usb_endpoint_t;
94
95/** Maximum endpoint number in USB 1.1.
96 */
97#define USB11_ENDPOINT_MAX 16
98
99
100/** USB complete address type.
101 * Pair address + endpoint is identification of transaction recipient.
102 */
103typedef struct {
104 usb_address_t address;
105 usb_endpoint_t endpoint;
106} usb_target_t;
107
108static inline int usb_target_same(usb_target_t a, usb_target_t b)
109{
110 return (a.address == b.address)
111 && (a.endpoint == b.endpoint);
112}
113
114/** General handle type.
115 * Used by various USB functions as opaque handle.
116 */
117typedef sysarg_t usb_handle_t;
118
119/** USB packet identifier. */
120typedef enum {
121#define _MAKE_PID_NIBBLE(tag, type) \
122 ((uint8_t)(((tag) << 2) | (type)))
123#define _MAKE_PID(tag, type) \
124 ( \
125 _MAKE_PID_NIBBLE(tag, type) \
126 | ((~_MAKE_PID_NIBBLE(tag, type)) << 4) \
127 )
128 USB_PID_OUT = _MAKE_PID(0, 1),
129 USB_PID_IN = _MAKE_PID(2, 1),
130 USB_PID_SOF = _MAKE_PID(1, 1),
131 USB_PID_SETUP = _MAKE_PID(3, 1),
132
133 USB_PID_DATA0 = _MAKE_PID(0 ,3),
134 USB_PID_DATA1 = _MAKE_PID(2 ,3),
135
136 USB_PID_ACK = _MAKE_PID(0 ,2),
137 USB_PID_NAK = _MAKE_PID(2 ,2),
138 USB_PID_STALL = _MAKE_PID(3 ,2),
139
140 USB_PID_PRE = _MAKE_PID(3 ,0),
141 /* USB_PID_ = _MAKE_PID( ,), */
142#undef _MAKE_PID
143#undef _MAKE_PID_NIBBLE
144} usb_packet_id;
145
146#endif
147/**
148 * @}
149 */
Note: See TracBrowser for help on using the repository browser.