c8238795943738f614d32adf9f61a655d47cd6f7
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__
52 /* Preprocessor Checks: */
53 #if !defined(__INCLUDE_FROM_USB_DRIVER)
54 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
57 /* Public Interface - May be used in end-application: */
59 /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device
60 * or Device to Host). The result of this mask should then be compared to the request direction masks.
62 * \see REQDIR_* macros for masks indicating the request data direction.
64 #define CONTROL_REQTYPE_DIRECTION 0x80
66 /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor
67 * Specific). The result of this mask should then be compared to the request type masks.
69 * \see REQTYPE_* macros for masks indicating the request type.
71 #define CONTROL_REQTYPE_TYPE 0x60
73 /** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class
74 * or Vendor Specific). The result of this mask should then be compared to the request recipient
77 * \see REQREC_* macros for masks indicating the request recipient.
79 #define CONTROL_REQTYPE_RECIPIENT 0x1F
81 /** Request data direction mask, indicating that the request data will flow from host to device.
83 * \see \ref CONTROL_REQTYPE_DIRECTION macro.
85 #define REQDIR_HOSTTODEVICE (0 << 7)
87 /** Request data direction mask, indicating that the request data will flow from device to host.
89 * \see \ref CONTROL_REQTYPE_DIRECTION macro.
91 #define REQDIR_DEVICETOHOST (1 << 7)
93 /** Request type mask, indicating that the request is a standard request.
95 * \see \ref CONTROL_REQTYPE_TYPE macro.
97 #define REQTYPE_STANDARD (0 << 5)
99 /** Request type mask, indicating that the request is a class-specific request.
101 * \see \ref CONTROL_REQTYPE_TYPE macro.
103 #define REQTYPE_CLASS (1 << 5)
105 /** Request type mask, indicating that the request is a vendor specific request.
107 * \see \ref CONTROL_REQTYPE_TYPE macro.
109 #define REQTYPE_VENDOR (2 << 5)
111 /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
113 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
115 #define REQREC_DEVICE (0 << 0)
117 /** Request recipient mask, indicating that the request is to be issued to an interface in the
118 * currently selected configuration.
120 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
122 #define REQREC_INTERFACE (1 << 0)
124 /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
125 * currently selected configuration.
127 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
129 #define REQREC_ENDPOINT (2 << 0)
131 /** Request recipient mask, indicating that the request is to be issued to an unspecified element
132 * in the currently selected configuration.
134 * \see \ref CONTROL_REQTYPE_RECIPIENT macro.
136 #define REQREC_OTHER (3 << 0)
138 /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
139 * request this indicates that an endpoint (whose address is given elsewhere in the request
140 * should have its stall condition cleared. If used in a similar manner inside a Set Feature
141 * request, this stalls an endpoint.
143 #define FEATURE_ENDPOINT_HALT 0x00
145 /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
146 * request this indicates that the remote wakeup enabled device should not issue remote
147 * wakeup requests until further notice. If used in a similar manner inside a Set Feature
148 * request, this re-enabled the remote wakeup feature on the device.
150 #define FEATURE_REMOTE_WAKEUP 0x01
153 /** Type define for a standard USB control request.
155 * \see The USB 2.0 specification for more information on standard control requests.
159 uint8_t bmRequestType
; /**< Type of the request. */
160 uint8_t bRequest
; /**< Request command code. */
161 uint16_t wValue
; /**< wValue parameter of the request. */
162 uint16_t wIndex
; /**< wIndex parameter of the request. */
163 uint16_t wLength
; /**< Length of the data to transfer in bytes. */
164 } USB_Request_Header_t
;
167 /** Enumeration for the various standard request commands. These commands are applicable when the
168 * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always
169 * handled regardless of the request type value).
171 * \see Chapter 9 of the USB 2.0 Specification.
173 enum USB_Control_Request_t
175 REQ_GetStatus
= 0, /**< Implemented in the library for device, endpoint and interface
176 * recipients. Passed to the user application for other recipients
177 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
179 REQ_ClearFeature
= 1, /**< Implemented in the library for device, endpoint and interface
180 * recipients. Passed to the user application for other recipients
181 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
183 REQ_SetFeature
= 3, /**< Implemented in the library for device, endpoint and interface
184 * recipients. Passed to the user application for other recipients
185 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
187 REQ_SetAddress
= 5, /**< Implemented in the library for the device recipient. Passed
188 * to the user application for other recipients via the
189 * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
191 REQ_GetDescriptor
= 6, /**< Implemented in the library for all recipients and all request
193 REQ_SetDescriptor
= 7, /**< Not implemented in the library, passed to the user application
194 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
196 REQ_GetConfiguration
= 8, /**< Implemented in the library for the device recipient. Passed
197 * to the user application for other recipients via the
198 * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
200 REQ_SetConfiguration
= 9, /**< Implemented in the library for the device recipient. Passed
201 * to the user application for other recipients via the
202 * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
204 REQ_GetInterface
= 10, /**< Not implemented in the library, passed to the user application
205 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
207 REQ_SetInterface
= 11, /**< Not implemented in the library, passed to the user application
208 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
210 REQ_SynchFrame
= 12, /**< Not implemented in the library, passed to the user application
211 * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in
215 /* Private Interface - For use in library only: */
216 #if !defined(__DOXYGEN__)
218 #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
219 #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)