a887b5cdcc0d0677a26ea00103cf1031f0d07046
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / StdRequestType.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all 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 /** \ingroup Group_USB
32 * @defgroup Group_StdRequest Standard USB Requests
33 *
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.
36 *
37 * @{
38 */
39
40 #ifndef __STDREQTYPE_H__
41 #define __STDREQTYPE_H__
42
43 /* Public Interface - May be used in end-application: */
44 /* Macros: */
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.
47 *
48 * \see REQDIR_* macros for masks indicating the request data direction.
49 */
50 #define CONTROL_REQTYPE_DIRECTION 0x80
51
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.
54 *
55 * \see REQTYPE_* macros for masks indicating the request type.
56 */
57 #define CONTROL_REQTYPE_TYPE 0x60
58
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
61 * masks.
62 *
63 * \see REQREC_* macros for masks indicating the request recipient.
64 */
65 #define CONTROL_REQTYPE_RECIPIENT 0x1F
66
67 /** Request data direction mask, indicating that the request data will flow from host to device.
68 *
69 * \see \ref CONTROL_REQTYPE_DIRECTION macro.
70 */
71 #define REQDIR_HOSTTODEVICE (0 << 7)
72
73 /** Request data direction mask, indicating that the request data will flow from device to host.
74 *
75 * \see \ref CONTROL_REQTYPE_DIRECTION macro.
76 */
77 #define REQDIR_DEVICETOHOST (1 << 7)
78
79 /** Request type mask, indicating that the request is a standard request.
80 *
81 * \see \ref CONTROL_REQTYPE_TYPE macro.
82 */
83 #define REQTYPE_STANDARD (0 << 5)
84
85 /** Request type mask, indicating that the request is a class-specific request.
86 *
87 * \see \ref CONTROL_REQTYPE_TYPE macro.
88 */
89 #define REQTYPE_CLASS (1 << 5)
90
91 /** Request type mask, indicating that the request is a vendor specific request.
92 *
93 * \see \ref CONTROL_REQTYPE_TYPE macro.
94 */
95 #define REQTYPE_VENDOR (2 << 5)
96
97 /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
98 *
99 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
100 */
101 #define REQREC_DEVICE (0 << 0)
102
103 /** Request recipient mask, indicating that the request is to be issued to an interface in the
104 * currently selected configuration.
105 *
106 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
107 */
108 #define REQREC_INTERFACE (1 << 0)
109
110 /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
111 * currently selected configuration.
112 *
113 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
114 */
115 #define REQREC_ENDPOINT (2 << 0)
116
117 /** Request recipient mask, indicating that the request is to be issued to an unspecified element
118 * in the currently selected configuration.
119 *
120 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
121 */
122 #define REQREC_OTHER (3 << 0)
123
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.
128 */
129 #define FEATURE_ENDPOINT_HALT 0x00
130
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.
135 */
136 #define FEATURE_REMOTE_WAKEUP 0x01
137
138 /* Type Defines: */
139 /** Type define for a standard USB control request.
140 *
141 * \see The USB 2.0 specification for more information on standard control requests.
142 */
143 typedef struct
144 {
145 uint8_t bmRequestType; /**< Type of the request. */
146 uint8_t bRequest; /**< Request command code. */
147 uint16_t wValue; /**< wValue parameter of the request. */
148 uint16_t wIndex; /**< wIndex parameter of the request. */
149 uint16_t wLength; /**< Length of the data to transfer in bytes. */
150 } USB_Request_Header_t;
151
152 /* Enums: */
153 /** Enumeration for the various standard request commands. These commands are applicable when the
154 * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always
155 * handled regardless of the request type value).
156 *
157 * \see Chapter 9 of the USB 2.0 Specification.
158 */
159 enum USB_Control_Request_t
160 {
161 REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface
162 * recipients. Passed to the user application for other recipients
163 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
164 * device mode. */
165 REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface
166 * recipients. Passed to the user application for other recipients
167 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
168 * device mode. */
169 REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface
170 * recipients. Passed to the user application for other recipients
171 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
172 * device mode. */
173 REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed
174 * to the user application for other recipients via the
175 * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
176 * device mode. */
177 REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request
178 * types. */
179 REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application
180 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
181 * device mode. */
182 REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed
183 * to the user application for other recipients via the
184 * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
185 * device mode. */
186 REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed
187 * to the user application for other recipients via the
188 * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
189 * device mode. */
190 REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application
191 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
192 * device mode. */
193 REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application
194 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
195 * device mode. */
196 REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application
197 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
198 * device mode. */
199 };
200
201 /* Private Interface - For use in library only: */
202 #if !defined(__DOXYGEN__)
203 /* Macros: */
204 #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
205 #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)
206 #endif
207
208 #endif
209
210 /** @} */