27c179497fce4b28456ae0b0feb9b769ef91e267
3 Copyright (C) Dean Camera, 2009.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
31 /** \ingroup Group_USB
32 * @defgroup Group_StdRequest Standard USB Requests
34 * This module contains definitions for the various control request parameters, so that the request
35 * details (such as data direction, request recipient, etc.) can be extracted via masking.
40 #ifndef __STDREQTYPE_H__
41 #define __STDREQTYPE_H__
43 /* Public Interface - May be used in end-application: */
45 /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device
46 * or Device to Host). The result of this mask should then be compared to the request direction masks.
48 * \see REQDIR_* macros for masks indicating the request data direction.
50 #define CONTROL_REQTYPE_DIRECTION 0x80
52 /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor
53 * Specific). The result of this mask should then be compared to the request type masks.
55 * \see REQTYPE_* macros for masks indicating the request type.
57 #define CONTROL_REQTYPE_TYPE 0x60
59 /** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class
60 * or Vendor Specific). The result of this mask should then be compared to the request recipient
63 * \see REQREC_* macros for masks indicating the request recipient.
65 #define CONTROL_REQTYPE_RECIPIENT 0x1F
67 /** Request data direction mask, indicating that the request data will flow from host to device.
69 * \see CONTROL_REQTYPE_DIRECTION macro.
71 #define REQDIR_HOSTTODEVICE (0 << 7)
73 /** Request data direction mask, indicating that the request data will flow from device to host.
75 * \see CONTROL_REQTYPE_DIRECTION macro.
77 #define REQDIR_DEVICETOHOST (1 << 7)
79 /** Request type mask, indicating that the request is a standard request.
81 * \see CONTROL_REQTYPE_TYPE macro.
83 #define REQTYPE_STANDARD (0 << 5)
85 /** Request type mask, indicating that the request is a class-specific request.
87 * \see CONTROL_REQTYPE_TYPE macro.
89 #define REQTYPE_CLASS (1 << 5)
91 /** Request type mask, indicating that the request is a vendor specific request.
93 * \see CONTROL_REQTYPE_TYPE macro.
95 #define REQTYPE_VENDOR (2 << 5)
97 /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
99 * \see CONTROL_REQTYPE_RECIPIENT macro.
101 #define REQREC_DEVICE (0 << 0)
103 /** Request recipient mask, indicating that the request is to be issued to an interface in the
104 * currently selected configuration.
106 * \see CONTROL_REQTYPE_RECIPIENT macro.
108 #define REQREC_INTERFACE (1 << 0)
110 /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
111 * currently selected configuration.
113 * \see CONTROL_REQTYPE_RECIPIENT macro.
115 #define REQREC_ENDPOINT (2 << 0)
117 /** Request recipient mask, indicating that the request is to be issued to an unspecified element
118 * in the currently selected configuration.
120 * \see CONTROL_REQTYPE_RECIPIENT macro.
122 #define REQREC_OTHER (3 << 0)
124 /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
125 * request this indicates that an endpoint (whose address is given elsewhere in the request
126 * should have its stall condition cleared. If used in a similar manner inside a Set Feature
127 * request, this stalls an endpoint.
129 #define FEATURE_ENDPOINT_HALT 0x00
131 /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
132 * request this indicates that the remote wakeup enabled device should not issue remote
133 * wakeup requests until further notice. If used in a similar manner inside a Set Feature
134 * request, this re-enabled the remote wakeup feature on the device.
136 #define FEATURE_REMOTE_WAKEUP 0x01
139 /** Enumeration for the various standard request commands. These commands are applicable when the
140 * request type is REQTYPE_STANDARD (with the exception of REQ_GetDescriptor, which is always
141 * handled regardless of the request type value).
143 * \see Chapter 9 of the USB 2.0 Specification.
145 enum USB_Control_Request_t
147 REQ_GetStatus
= 0, /**< Implemented in the library for device, endpoint and interface
148 * recipients. Passed to the user application for other recipients
149 * via the USB_UnhandledControlPacket() event when received in
151 REQ_ClearFeature
= 1, /**< Implemented in the library for device, endpoint and interface
152 * recipients. Passed to the user application for other recipients
153 * via the USB_UnhandledControlPacket() event when received in
155 REQ_SetFeature
= 3, /**< Implemented in the library for device, endpoint and interface
156 * recipients. Passed to the user application for other recipients
157 * via the USB_UnhandledControlPacket() event when received in
159 REQ_SetAddress
= 5, /**< Implemented in the library for the device recipient. Passed
160 * to the user application for other recipients via the
161 * USB_UnhandledControlPacket() event when received in
163 REQ_GetDescriptor
= 6, /**< Implemented in the library for all recipients and all request
165 REQ_SetDescriptor
= 7, /**< Not implemented in the library, passed to the user application
166 * via the USB_UnhandledControlPacket() event when received in
168 REQ_GetConfiguration
= 8, /**< Implemented in the library for the device recipient. Passed
169 * to the user application for other recipients via the
170 * USB_UnhandledControlPacket() event when received in
172 REQ_SetConfiguration
= 9, /**< Implemented in the library for the device recipient. Passed
173 * to the user application for other recipients via the
174 * USB_UnhandledControlPacket() event when received in
176 REQ_GetInterface
= 10, /**< Not implemented in the library, passed to the user application
177 * via the USB_UnhandledControlPacket() event when received in
179 REQ_SetInterface
= 11, /**< Not implemented in the library, passed to the user application
180 * via the USB_UnhandledControlPacket() event when received in
182 REQ_SynchFrame
= 12, /**< Not implemented in the library, passed to the user application
183 * via the USB_UnhandledControlPacket() event when received in
187 /* Private Interface - For use in library only: */
188 #if !defined(__DOXYGEN__)
190 #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
191 #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)