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