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