f8e4f45f443643882d5f6be1024d8febb27ba574
3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
32 * \brief USB control endpoint request definitions.
34 * This file contains structures and macros for the easy creation and parsing of standard USB control requests.
36 * \note This file should not be included directly. It is automatically included as needed by the USB driver
37 * dispatch header located in LUFA/Drivers/USB/USB.h.
40 /** \ingroup Group_USB
41 * @defgroup Group_StdRequest Standard USB Requests
43 * This module contains definitions for the various control request parameters, so that the request
44 * details (such as data direction, request recipient, etc.) can be extracted via masking.
49 #ifndef __STDREQTYPE_H__
50 #define __STDREQTYPE_H__
55 /* Preprocessor Checks: */
56 #if !defined(__INCLUDE_FROM_USB_DRIVER)
57 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
60 /* Public Interface - May be used in end-application: */
62 /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device
63 * or Device to Host). The result of this mask should then be compared to the request direction masks.
65 * \see REQDIR_* macros for masks indicating the request data direction.
67 #define CONTROL_REQTYPE_DIRECTION 0x80
69 /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor
70 * Specific). The result of this mask should then be compared to the request type masks.
72 * \see REQTYPE_* macros for masks indicating the request type.
74 #define CONTROL_REQTYPE_TYPE 0x60
76 /** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class
77 * or Vendor Specific). The result of this mask should then be compared to the request recipient
80 * \see REQREC_* macros for masks indicating the request recipient.
82 #define CONTROL_REQTYPE_RECIPIENT 0x1F
84 /** Request data direction mask, indicating that the request data will flow from host to device.
86 * \see \ref CONTROL_REQTYPE_DIRECTION macro.
88 #define REQDIR_HOSTTODEVICE (0 << 7)
90 /** Request data direction mask, indicating that the request data will flow from device to host.
92 * \see \ref CONTROL_REQTYPE_DIRECTION macro.
94 #define REQDIR_DEVICETOHOST (1 << 7)
96 /** Request type mask, indicating that the request is a standard request.
98 * \see \ref CONTROL_REQTYPE_TYPE macro.
100 #define REQTYPE_STANDARD (0 << 5)
102 /** Request type mask, indicating that the request is a class-specific request.
104 * \see \ref CONTROL_REQTYPE_TYPE macro.
106 #define REQTYPE_CLASS (1 << 5)
108 /** Request type mask, indicating that the request is a vendor specific request.
110 * \see \ref CONTROL_REQTYPE_TYPE macro.
112 #define REQTYPE_VENDOR (2 << 5)
114 /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
116 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
118 #define REQREC_DEVICE (0 << 0)
120 /** Request recipient mask, indicating that the request is to be issued to an interface in the
121 * currently selected configuration.
123 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
125 #define REQREC_INTERFACE (1 << 0)
127 /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
128 * currently selected configuration.
130 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
132 #define REQREC_ENDPOINT (2 << 0)
134 /** Request recipient mask, indicating that the request is to be issued to an unspecified element
135 * in the currently selected configuration.
137 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
139 #define REQREC_OTHER (3 << 0)
141 /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
142 * request this indicates that an endpoint (whose address is given elsewhere in the request
143 * should have its stall condition cleared. If used in a similar manner inside a Set Feature
144 * request, this stalls an endpoint.
146 #define FEATURE_ENDPOINT_HALT 0x00
148 /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
149 * request this indicates that the remote wakeup enabled device should not issue remote
150 * wakeup requests until further notice. If used in a similar manner inside a Set Feature
151 * request, this re-enabled the remote wakeup feature on the device.
153 #define FEATURE_REMOTE_WAKEUP 0x01
156 /** \brief Standard USB Control Request
158 * Type define for a standard USB control request.
160 * \see The USB 2.0 specification for more information on standard control requests.
164 uint8_t bmRequestType
; /**< Type of the request. */
165 uint8_t bRequest
; /**< Request command code. */
166 uint16_t wValue
; /**< wValue parameter of the request. */
167 uint16_t wIndex
; /**< wIndex parameter of the request. */
168 uint16_t wLength
; /**< Length of the data to transfer in bytes. */
169 } USB_Request_Header_t
;
172 /** Enumeration for the various standard request commands. These commands are applicable when the
173 * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always
174 * handled regardless of the request type value).
176 * \see Chapter 9 of the USB 2.0 Specification.
178 enum USB_Control_Request_t
180 REQ_GetStatus
= 0, /**< Implemented in the library for device, endpoint and interface
181 * recipients. Passed to the user application for other recipients
182 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
184 REQ_ClearFeature
= 1, /**< Implemented in the library for device, endpoint and interface
185 * recipients. Passed to the user application for other recipients
186 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
188 REQ_SetFeature
= 3, /**< Implemented in the library for device, endpoint and interface
189 * recipients. Passed to the user application for other recipients
190 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
192 REQ_SetAddress
= 5, /**< Implemented in the library for the device recipient. Passed
193 * to the user application for other recipients via the
194 * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
196 REQ_GetDescriptor
= 6, /**< Implemented in the library for all recipients and all request
198 REQ_SetDescriptor
= 7, /**< Not implemented in the library, passed to the user application
199 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
201 REQ_GetConfiguration
= 8, /**< Implemented in the library for the device recipient. Passed
202 * to the user application for other recipients via the
203 * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
205 REQ_SetConfiguration
= 9, /**< Implemented in the library for the device recipient. Passed
206 * to the user application for other recipients via the
207 * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
209 REQ_GetInterface
= 10, /**< Not implemented in the library, passed to the user application
210 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
212 REQ_SetInterface
= 11, /**< Not implemented in the library, passed to the user application
213 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
215 REQ_SynchFrame
= 12, /**< Not implemented in the library, passed to the user application
216 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
220 /* Private Interface - For use in library only: */
221 #if !defined(__DOXYGEN__)
223 #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
224 #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)