bf9ef8aeeab3f42924af06c4de69e42a6c6f146a
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / StdRequestType.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
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.
20
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
28 this software.
29 */
30
31 /** \file
32 *
33 * Contains definitions for the various control request parameters, so that the request details (such as data
34 * direction, request recipient, etc.) can be extracted via masking.
35 */
36
37 /** \ingroup Group_USB
38 * @defgroup Group_StdRequest Standard USB Requests
39 *
40 * Functions, macros, variables, enums and types related to standard USB requests to USB devices.
41 *
42 * @{
43 */
44
45 #ifndef __STDREQTYPE_H__
46 #define __STDREQTYPE_H__
47
48 /* Public Interface - May be used in end-application: */
49 /* Macros: */
50 /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device
51 * or Device to Host). The result of this mask should then be compared to the request direction masks.
52 *
53 * \see REQDIR_* macros for masks indicating the request data direction.
54 */
55 #define CONTROL_REQTYPE_DIRECTION 0x80
56
57 /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor
58 * Specific). The result of this mask should then be compared to the request type masks.
59 *
60 * \see REQTYPE_* macros for masks indicating the request type.
61 */
62 #define CONTROL_REQTYPE_TYPE 0x60
63
64 /** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class
65 * or Vendor Specific). The result of this mask should then be compared to the request recipient
66 * masks.
67 *
68 * \see REQREC_* macros for masks indicating the request recipient.
69 */
70 #define CONTROL_REQTYPE_RECIPIENT 0x1F
71
72 /** Request data direction mask, indicating that the request data will flow from host to device.
73 *
74 * \see CONTROL_REQTYPE_DIRECTION macro.
75 */
76 #define REQDIR_HOSTTODEVICE (0 << 7)
77
78 /** Request data direction mask, indicating that the request data will flow from device to host.
79 *
80 * \see CONTROL_REQTYPE_DIRECTION macro.
81 */
82 #define REQDIR_DEVICETOHOST (1 << 7)
83
84 /** Request type mask, indicating that the request is a standard request.
85 *
86 * \see CONTROL_REQTYPE_TYPE macro.
87 */
88 #define REQTYPE_STANDARD (0 << 5)
89
90 /** Request type mask, indicating that the request is a class-specific request.
91 *
92 * \see CONTROL_REQTYPE_TYPE macro.
93 */
94 #define REQTYPE_CLASS (1 << 5)
95
96 /** Request type mask, indicating that the request is a vendor specific request.
97 *
98 * \see CONTROL_REQTYPE_TYPE macro.
99 */
100 #define REQTYPE_VENDOR (2 << 5)
101
102 /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
103 *
104 * \see CONTROL_REQTYPE_RECIPIENT macro.
105 */
106 #define REQREC_DEVICE (0 << 0)
107
108 /** Request recipient mask, indicating that the request is to be issued to an interface in the
109 * currently selected configuration.
110 *
111 * \see CONTROL_REQTYPE_RECIPIENT macro.
112 */
113 #define REQREC_INTERFACE (1 << 0)
114
115 /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
116 * currently selected configuration.
117 *
118 * \see CONTROL_REQTYPE_RECIPIENT macro.
119 */
120 #define REQREC_ENDPOINT (2 << 0)
121
122 /** Request recipient mask, indicating that the request is to be issued to an unspecified element
123 * in the currently selected configuration.
124 *
125 * \see CONTROL_REQTYPE_RECIPIENT macro.
126 */
127 #define REQREC_OTHER (3 << 0)
128
129 /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
130 * request this indicates that an endpoint (whose address is given elsewhere in the request
131 * should have its stall condition cleared. If used in a similar manner inside a Set Feature
132 * request, this stalls an endpoint.
133 */
134 #define FEATURE_ENDPOINT_HALT 0x00
135
136 /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
137 * request this indicates that the remote wakeup enabled device should not issue remote
138 * wakeup requests until further notice. If used in a similar manner inside a Set Feature
139 * request, this re-enabled the remote wakeup feature on the device.
140 */
141 #define FEATURE_REMOTE_WAKEUP 0x01
142
143 /* Enums: */
144 /** Enumeration for the various standard request commands. These commands are applicable when the
145 * request type is REQTYPE_STANDARD (with the exception of REQ_GetDescriptor, which is always
146 * handled regardless of the request type value).
147 *
148 * \see Chapter 9 of the USB 2.0 Specification.
149 */
150 enum USB_Control_Request_t
151 {
152 REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface
153 * recipients. Passed to the user application for other recipients
154 * via the USB_UnhandledControlPacket() event when received in
155 * device mode. */
156 REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface
157 * recipients. Passed to the user application for other recipients
158 * via the USB_UnhandledControlPacket() event when received in
159 * device mode. */
160 REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface
161 * recipients. Passed to the user application for other recipients
162 * via the USB_UnhandledControlPacket() event when received in
163 * device mode. */
164 REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed
165 * to the user application for other recipients via the
166 * USB_UnhandledControlPacket() event when received in
167 * device mode. */
168 REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request
169 * types. */
170 REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application
171 * via the USB_UnhandledControlPacket() event when received in
172 * device mode. */
173 REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed
174 * to the user application for other recipients via the
175 * USB_UnhandledControlPacket() event when received in
176 * device mode. */
177 REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed
178 * to the user application for other recipients via the
179 * USB_UnhandledControlPacket() event when received in
180 * device mode. */
181 REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application
182 * via the USB_UnhandledControlPacket() event when received in
183 * device mode. */
184 REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application
185 * via the USB_UnhandledControlPacket() event when received in
186 * device mode. */
187 REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application
188 * via the USB_UnhandledControlPacket() event when received in
189 * device mode. */
190 };
191
192 /* Private Interface - For use in library only: */
193 #if !defined(__DOXYGEN__)
194 /* Macros: */
195 #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
196 #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)
197 #endif
198
199 #endif
200
201 /** @} */