]> git.donarmstrong.com Git - qmk_firmware.git/blob - protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/StdRequestType.h
Squashed 'tmk_core/' content from commit 05caacc
[qmk_firmware.git] / protocol / lufa / LUFA-120730 / LUFA / Drivers / USB / Core / StdRequestType.h
1 /*\r
2              LUFA Library\r
3      Copyright (C) Dean Camera, 2012.\r
4 \r
5   dean [at] fourwalledcubicle [dot] com\r
6            www.lufa-lib.org\r
7 */\r
8 \r
9 /*\r
10   Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
11 \r
12   Permission to use, copy, modify, distribute, and sell this\r
13   software and its documentation for any purpose is hereby granted\r
14   without fee, provided that the above copyright notice appear in\r
15   all copies and that both that the copyright notice and this\r
16   permission notice and warranty disclaimer appear in supporting\r
17   documentation, and that the name of the author not be used in\r
18   advertising or publicity pertaining to distribution of the\r
19   software without specific, written prior permission.\r
20 \r
21   The author disclaim all warranties with regard to this\r
22   software, including all implied warranties of merchantability\r
23   and fitness.  In no event shall the author be liable for any\r
24   special, indirect or consequential damages or any damages\r
25   whatsoever resulting from loss of use, data or profits, whether\r
26   in an action of contract, negligence or other tortious action,\r
27   arising out of or in connection with the use or performance of\r
28   this software.\r
29 */\r
30 \r
31 /** \file\r
32  *  \brief USB control endpoint request definitions.\r
33  *  \copydetails Group_StdRequest\r
34  *\r
35  *  \note This file should not be included directly. It is automatically included as needed by the USB driver\r
36  *        dispatch header located in LUFA/Drivers/USB/USB.h.\r
37  */\r
38 \r
39 /** \ingroup Group_USB\r
40  *  \defgroup Group_StdRequest Standard USB Requests\r
41  *  \brief USB control endpoint request definitions.\r
42  *\r
43  *  This module contains definitions for the various control request parameters, so that the request\r
44  *  details (such as data direction, request recipient, etc.) can be extracted via masking.\r
45  *\r
46  *  @{\r
47  */\r
48 \r
49 #ifndef __STDREQTYPE_H__\r
50 #define __STDREQTYPE_H__\r
51 \r
52         /* Includes: */\r
53                 #include "../../../Common/Common.h"\r
54                 #include "USBMode.h"\r
55 \r
56         /* Enable C linkage for C++ Compilers: */\r
57                 #if defined(__cplusplus)\r
58                         extern "C" {\r
59                 #endif\r
60 \r
61         /* Preprocessor Checks: */\r
62                 #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
63                         #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
64                 #endif\r
65 \r
66         /* Public Interface - May be used in end-application: */\r
67                 /* Macros: */\r
68                         /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device\r
69                          *  or Device to Host). The result of this mask should then be compared to the request direction masks.\r
70                          *\r
71                          *  \see \c REQDIR_* macros for masks indicating the request data direction.\r
72                          */\r
73                         #define CONTROL_REQTYPE_DIRECTION  0x80\r
74 \r
75                         /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor\r
76                          *  Specific). The result of this mask should then be compared to the request type masks.\r
77                          *\r
78                          *  \see \c REQTYPE_* macros for masks indicating the request type.\r
79                          */\r
80                         #define CONTROL_REQTYPE_TYPE       0x60\r
81 \r
82                         /** Mask for the request type parameter, to indicate the recipient of the request (Device, Interface\r
83                          *  Endpoint or Other). The result of this mask should then be compared to the request recipient\r
84                          *  masks.\r
85                          *\r
86                          *  \see \c REQREC_* macros for masks indicating the request recipient.\r
87                          */\r
88                         #define CONTROL_REQTYPE_RECIPIENT  0x1F\r
89 \r
90                         /** \name Control Request Data Direction Masks */\r
91                         //@{\r
92                         /** Request data direction mask, indicating that the request data will flow from host to device.\r
93                          *\r
94                          *  \see \ref CONTROL_REQTYPE_DIRECTION macro.\r
95                          */\r
96                         #define REQDIR_HOSTTODEVICE        (0 << 7)\r
97 \r
98                         /** Request data direction mask, indicating that the request data will flow from device to host.\r
99                          *\r
100                          *  \see \ref CONTROL_REQTYPE_DIRECTION macro.\r
101                          */\r
102                         #define REQDIR_DEVICETOHOST        (1 << 7)\r
103                         //@}\r
104 \r
105                         /** \name Control Request Type Masks */\r
106                         //@{\r
107                         /** Request type mask, indicating that the request is a standard request.\r
108                          *\r
109                          *  \see \ref CONTROL_REQTYPE_TYPE macro.\r
110                          */\r
111                         #define REQTYPE_STANDARD           (0 << 5)\r
112 \r
113                         /** Request type mask, indicating that the request is a class-specific request.\r
114                          *\r
115                          *  \see \ref CONTROL_REQTYPE_TYPE macro.\r
116                          */\r
117                         #define REQTYPE_CLASS              (1 << 5)\r
118 \r
119                         /** Request type mask, indicating that the request is a vendor specific request.\r
120                          *\r
121                          *  \see \ref CONTROL_REQTYPE_TYPE macro.\r
122                          */\r
123                         #define REQTYPE_VENDOR             (2 << 5)\r
124                         //@}\r
125 \r
126                         /** \name Control Request Recipient Masks */\r
127                         //@{\r
128                         /** Request recipient mask, indicating that the request is to be issued to the device as a whole.\r
129                          *\r
130                          *  \see \ref CONTROL_REQTYPE_RECIPIENT macro.\r
131                          */\r
132                         #define REQREC_DEVICE              (0 << 0)\r
133 \r
134                         /** Request recipient mask, indicating that the request is to be issued to an interface in the\r
135                          *  currently selected configuration.\r
136                          *\r
137                          *  \see \ref CONTROL_REQTYPE_RECIPIENT macro.\r
138                          */\r
139                         #define REQREC_INTERFACE           (1 << 0)\r
140 \r
141                         /** Request recipient mask, indicating that the request is to be issued to an endpoint in the\r
142                          *  currently selected configuration.\r
143                          *\r
144                          *  \see \ref CONTROL_REQTYPE_RECIPIENT macro.\r
145                          */\r
146                         #define REQREC_ENDPOINT            (2 << 0)\r
147 \r
148                         /** Request recipient mask, indicating that the request is to be issued to an unspecified element\r
149                          *  in the currently selected configuration.\r
150                          *\r
151                          *  \see \ref CONTROL_REQTYPE_RECIPIENT macro.\r
152                          */\r
153                         #define REQREC_OTHER               (3 << 0)\r
154                         //@}\r
155 \r
156                 /* Type Defines: */\r
157                         /** \brief Standard USB Control Request\r
158                          *\r
159                          *  Type define for a standard USB control request.\r
160                          *\r
161                          *  \see The USB 2.0 specification for more information on standard control requests.\r
162                          */\r
163                         typedef struct\r
164                         {\r
165                                 uint8_t  bmRequestType; /**< Type of the request. */\r
166                                 uint8_t  bRequest; /**< Request command code. */\r
167                                 uint16_t wValue; /**< wValue parameter of the request. */\r
168                                 uint16_t wIndex; /**< wIndex parameter of the request. */\r
169                                 uint16_t wLength; /**< Length of the data to transfer in bytes. */\r
170                         } ATTR_PACKED USB_Request_Header_t;\r
171 \r
172                 /* Enums: */\r
173                         /** Enumeration for the various standard request commands. These commands are applicable when the\r
174                          *  request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always\r
175                          *  handled regardless of the request type value).\r
176                          *\r
177                          *  \see Chapter 9 of the USB 2.0 Specification.\r
178                          */\r
179                         enum USB_Control_Request_t\r
180                         {\r
181                                 REQ_GetStatus           = 0, /**< Implemented in the library for device and endpoint recipients. Passed\r
182                                                               *   to the user application for other recipients via the\r
183                                                               *   \ref EVENT_USB_Device_ControlRequest() event when received in\r
184                                                               *   device mode. */\r
185                                 REQ_ClearFeature        = 1, /**< Implemented in the library for device and endpoint recipients. Passed\r
186                                                               *   to the user application for other recipients via the\r
187                                                               *   \ref EVENT_USB_Device_ControlRequest() event when received in\r
188                                                               *   device mode. */\r
189                                 REQ_SetFeature          = 3, /**< Implemented in the library for device and endpoint recipients. Passed\r
190                                                               *   to the user application for other recipients via the\r
191                                                               *   \ref EVENT_USB_Device_ControlRequest() event when received in\r
192                                                               *   device mode. */\r
193                                 REQ_SetAddress          = 5, /**< Implemented in the library for the device recipient. Passed\r
194                                                               *   to the user application for other recipients via the\r
195                                                               *   \ref EVENT_USB_Device_ControlRequest() event when received in\r
196                                                               *   device mode. */\r
197                                 REQ_GetDescriptor       = 6, /**< Implemented in the library for device and interface recipients. Passed to the\r
198                                                               *   user application for other recipients via the\r
199                                                               *   \ref EVENT_USB_Device_ControlRequest() event when received in\r
200                                                               *   device mode. */\r
201                                 REQ_SetDescriptor       = 7, /**< Not implemented in the library, passed to the user application\r
202                                                               *   via the \ref EVENT_USB_Device_ControlRequest() event when received in\r
203                                                               *   device mode. */\r
204                                 REQ_GetConfiguration    = 8, /**< Implemented in the library for the device recipient. Passed\r
205                                                               *   to the user application for other recipients via the\r
206                                                               *   \ref EVENT_USB_Device_ControlRequest() event when received in\r
207                                                               *   device mode. */\r
208                                 REQ_SetConfiguration    = 9, /**< Implemented in the library for the device recipient. Passed\r
209                                                               *   to the user application for other recipients via the\r
210                                                               *   \ref EVENT_USB_Device_ControlRequest() event when received in\r
211                                                               *   device mode. */\r
212                                 REQ_GetInterface        = 10, /**< Not implemented in the library, passed to the user application\r
213                                                               *   via the \ref EVENT_USB_Device_ControlRequest() event when received in\r
214                                                               *   device mode. */\r
215                                 REQ_SetInterface        = 11, /**< Not implemented in the library, passed to the user application\r
216                                                               *   via the \ref EVENT_USB_Device_ControlRequest() event when received in\r
217                                                               *   device mode. */\r
218                                 REQ_SynchFrame          = 12, /**< Not implemented in the library, passed to the user application\r
219                                                               *   via the \ref EVENT_USB_Device_ControlRequest() event when received in\r
220                                                               *   device mode. */\r
221                         };\r
222 \r
223                         /** Feature Selector values for Set Feature and Clear Feature standard control requests directed to the device, interface\r
224                          *  and endpoint recipients.\r
225                          */\r
226                         enum USB_Feature_Selectors_t\r
227                         {\r
228                                 FEATURE_SEL_EndpointHalt       = 0x00, /**< Feature selector for Clear Feature or Set Feature commands. When\r
229                                                                         *   used in a Set Feature or Clear Feature request this indicates that an\r
230                                                                         *   endpoint (whose address is given elsewhere in the request) should have\r
231                                                                         *   its stall condition changed.\r
232                                                                         */\r
233                                 FEATURE_SEL_DeviceRemoteWakeup = 0x01, /**< Feature selector for Device level Remote Wakeup enable set or clear.\r
234                                                                     *   This feature can be controlled by the host on devices which indicate\r
235                                                                     *   remote wakeup support in their descriptors to selectively disable or\r
236                                                                     *   enable remote wakeup.\r
237                                                                     */\r
238                                 FEATURE_SEL_TestMode           = 0x02, /**< Feature selector for Test Mode features, used to test the USB controller\r
239                                                                     *   to check for incorrect operation.\r
240                                                                     */\r
241                         };\r
242 \r
243         /* Private Interface - For use in library only: */\r
244                 #if !defined(__DOXYGEN__)\r
245                         /* Macros: */\r
246                                 #define FEATURE_SELFPOWERED_ENABLED     (1 << 0)\r
247                                 #define FEATURE_REMOTE_WAKEUP_ENABLED   (1 << 1)\r
248                 #endif\r
249 \r
250         /* Disable C linkage for C++ Compilers: */\r
251                 #if defined(__cplusplus)\r
252                         }\r
253                 #endif\r
254 \r
255 #endif\r
256 \r
257 /** @} */\r
258 \r