3 Copyright (C) Dean Camera, 2011.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2011 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.
33 * \copydetails Group_StdRequest
35 * \note This file should not be included directly. It is automatically included as needed by the USB driver
36 * dispatch header located in LUFA/Drivers/USB/USB.h.
39 /** \ingroup Group_USB
40 * \defgroup Group_StdRequest Standard USB Requests
41 * \brief USB control endpoint request definitions.
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__
53 #include "../../../Common/Common.h"
56 /* Enable C linkage for C++ Compilers: */
57 #if defined(__cplusplus)
61 /* Preprocessor Checks: */
62 #if !defined(__INCLUDE_FROM_USB_DRIVER)
63 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
66 /* Public Interface - May be used in end-application: */
68 /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device
69 * or Device to Host). The result of this mask should then be compared to the request direction masks.
71 * \see REQDIR_* macros for masks indicating the request data direction.
73 #define CONTROL_REQTYPE_DIRECTION 0x80
75 /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor
76 * Specific). The result of this mask should then be compared to the request type masks.
78 * \see REQTYPE_* macros for masks indicating the request type.
80 #define CONTROL_REQTYPE_TYPE 0x60
82 /** Mask for the request type parameter, to indicate the recipient of the request (Device, Interface
83 * Endpoint or Other). The result of this mask should then be compared to the request recipient
86 * \see REQREC_* macros for masks indicating the request recipient.
88 #define CONTROL_REQTYPE_RECIPIENT 0x1F
90 /** \name Control Request Data Direction Masks */
92 /** Request data direction mask, indicating that the request data will flow from host to device.
94 * \see \ref CONTROL_REQTYPE_DIRECTION macro.
96 #define REQDIR_HOSTTODEVICE (0 << 7)
98 /** Request data direction mask, indicating that the request data will flow from device to host.
100 * \see \ref CONTROL_REQTYPE_DIRECTION macro.
102 #define REQDIR_DEVICETOHOST (1 << 7)
105 /** \name Control Request Type Masks */
107 /** Request type mask, indicating that the request is a standard request.
109 * \see \ref CONTROL_REQTYPE_TYPE macro.
111 #define REQTYPE_STANDARD (0 << 5)
113 /** Request type mask, indicating that the request is a class-specific request.
115 * \see \ref CONTROL_REQTYPE_TYPE macro.
117 #define REQTYPE_CLASS (1 << 5)
119 /** Request type mask, indicating that the request is a vendor specific request.
121 * \see \ref CONTROL_REQTYPE_TYPE macro.
123 #define REQTYPE_VENDOR (2 << 5)
126 /** \name Control Request Recipient Masks */
128 /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
130 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
132 #define REQREC_DEVICE (0 << 0)
134 /** Request recipient mask, indicating that the request is to be issued to an interface in the
135 * currently selected configuration.
137 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
139 #define REQREC_INTERFACE (1 << 0)
141 /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
142 * currently selected configuration.
144 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
146 #define REQREC_ENDPOINT (2 << 0)
148 /** Request recipient mask, indicating that the request is to be issued to an unspecified element
149 * in the currently selected configuration.
151 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
153 #define REQREC_OTHER (3 << 0)
157 /** \brief Standard USB Control Request
159 * Type define for a standard USB control request.
161 * \see The USB 2.0 specification for more information on standard control requests.
165 uint8_t bmRequestType
; /**< Type of the request. */
166 uint8_t bRequest
; /**< Request command code. */
167 uint16_t wValue
; /**< wValue parameter of the request. */
168 uint16_t wIndex
; /**< wIndex parameter of the request. */
169 uint16_t wLength
; /**< Length of the data to transfer in bytes. */
170 } ATTR_PACKED USB_Request_Header_t
;
173 /** Enumeration for the various standard request commands. These commands are applicable when the
174 * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always
175 * handled regardless of the request type value).
177 * \see Chapter 9 of the USB 2.0 Specification.
179 enum USB_Control_Request_t
181 REQ_GetStatus
= 0, /**< Implemented in the library for device and endpoint recipients. Passed
182 * to the user application for other recipients via the
183 * \ref EVENT_USB_Device_ControlRequest() event when received in
185 REQ_ClearFeature
= 1, /**< Implemented in the library for device and endpoint recipients. Passed
186 * to the user application for other recipients via the
187 * \ref EVENT_USB_Device_ControlRequest() event when received in
189 REQ_SetFeature
= 3, /**< Implemented in the library for device and endpoint recipients. Passed
190 * to the user application for other recipients via the
191 * \ref EVENT_USB_Device_ControlRequest() event when received in
193 REQ_SetAddress
= 5, /**< Implemented in the library for the device recipient. Passed
194 * to the user application for other recipients via the
195 * \ref EVENT_USB_Device_ControlRequest() event when received in
197 REQ_GetDescriptor
= 6, /**< Implemented in the library for device and interface recipients. Passed to the
198 * user application for other recipients via the
199 * \ref EVENT_USB_Device_ControlRequest() event when received in
201 REQ_SetDescriptor
= 7, /**< Not implemented in the library, passed to the user application
202 * via the \ref EVENT_USB_Device_ControlRequest() event when received in
204 REQ_GetConfiguration
= 8, /**< Implemented in the library for the device recipient. Passed
205 * to the user application for other recipients via the
206 * \ref EVENT_USB_Device_ControlRequest() event when received in
208 REQ_SetConfiguration
= 9, /**< Implemented in the library for the device recipient. Passed
209 * to the user application for other recipients via the
210 * \ref EVENT_USB_Device_ControlRequest() event when received in
212 REQ_GetInterface
= 10, /**< Not implemented in the library, passed to the user application
213 * via the \ref EVENT_USB_Device_ControlRequest() event when received in
215 REQ_SetInterface
= 11, /**< Not implemented in the library, passed to the user application
216 * via the \ref EVENT_USB_Device_ControlRequest() event when received in
218 REQ_SynchFrame
= 12, /**< Not implemented in the library, passed to the user application
219 * via the \ref EVENT_USB_Device_ControlRequest() event when received in
223 /** Feature Selector values for Set Feature and Clear Feature standard control requests directed to the device, interface
224 * and endpoint recipients.
226 enum USB_Feature_Selectors_t
228 FEATURE_SEL_EndpointHalt
= 0x00, /**< Feature selector for Clear Feature or Set Feature commands. When
229 * used in a Set Feature or Clear Feature request this indicates that an
230 * endpoint (whose address is given elsewhere in the request) should have
231 * its stall condition changed.
233 FEATURE_SEL_DeviceRemoteWakeup
= 0x01, /**< Feature selector for Device level Remote Wakeup enable set or clear.
234 * This feature can be controlled by the host on devices which indicate
235 * remote wakeup support in their descriptors to selectively disable or
236 * enable remote wakeup.
238 FEATURE_SEL_TestMode
= 0x02, /**< Feature selector for Test Mode features, used to test the USB controller
239 * to check for incorrect operation.
243 /* Private Interface - For use in library only: */
244 #if !defined(__DOXYGEN__)
246 #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
247 #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)
250 /* Disable C linkage for C++ Compilers: */
251 #if defined(__cplusplus)