2 * @brief USB control endpoint request definitions
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * Copyright(C) Dean Camera, 2011, 2012
\r
7 * All rights reserved.
\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
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
34 /** @ingroup Group_USB
\r
35 * @defgroup Group_StdRequest Standard USB Requests
\r
36 * @brief USB control endpoint request definitions.
\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
44 #ifndef __STDREQTYPE_H__
\r
45 #define __STDREQTYPE_H__
\r
48 #include "../../../Common/Common.h"
\r
49 #include "USBMode.h"
\r
51 /* Enable C linkage for C++ Compilers: */
\r
52 #if defined(__cplusplus)
\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
61 /* Public Interface - May be used in end-application: */
\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
66 * @see REQDIR_* macros for masks indicating the request data direction.
\r
68 #define CONTROL_REQTYPE_DIRECTION 0x80
\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
73 * @see REQTYPE_* macros for masks indicating the request type.
\r
75 #define CONTROL_REQTYPE_TYPE 0x60
\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
81 * @see REQREC_* macros for masks indicating the request recipient.
\r
83 #define CONTROL_REQTYPE_RECIPIENT 0x1F
\r
85 /** \name Control Request Data Direction Masks */
\r
87 /** Request data direction mask, indicating that the request data will flow from host to device.
\r
89 * @see @ref CONTROL_REQTYPE_DIRECTION macro.
\r
91 #define REQDIR_HOSTTODEVICE (0 << 7)
\r
93 /** Request data direction mask, indicating that the request data will flow from device to host.
\r
95 * @see @ref CONTROL_REQTYPE_DIRECTION macro.
\r
97 #define REQDIR_DEVICETOHOST (1 << 7)
\r
100 /** \name Control Request Type Masks */
\r
102 /** Request type mask, indicating that the request is a standard request.
\r
104 * @see @ref CONTROL_REQTYPE_TYPE macro.
\r
106 #define REQTYPE_STANDARD (0 << 5)
\r
108 /** Request type mask, indicating that the request is a class-specific request.
\r
110 * @see @ref CONTROL_REQTYPE_TYPE macro.
\r
112 #define REQTYPE_CLASS (1 << 5)
\r
114 /** Request type mask, indicating that the request is a vendor specific request.
\r
116 * @see @ref CONTROL_REQTYPE_TYPE macro.
\r
118 #define REQTYPE_VENDOR (2 << 5)
\r
121 /** \name Control Request Recipient Masks */
\r
123 /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
\r
125 * @see @ref CONTROL_REQTYPE_RECIPIENT macro.
\r
127 #define REQREC_DEVICE (0 << 0)
\r
129 /** Request recipient mask, indicating that the request is to be issued to an interface in the
\r
130 * currently selected configuration.
\r
132 * @see @ref CONTROL_REQTYPE_RECIPIENT macro.
\r
134 #define REQREC_INTERFACE (1 << 0)
\r
136 /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
\r
137 * currently selected configuration.
\r
139 * @see @ref CONTROL_REQTYPE_RECIPIENT macro.
\r
141 #define REQREC_ENDPOINT (2 << 0)
\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
146 * @see @ref CONTROL_REQTYPE_RECIPIENT macro.
\r
148 #define REQREC_OTHER (3 << 0)
\r
151 /* Type Defines: */
\r
152 /** @brief Standard USB Control Request
\r
154 * Type define for a standard USB control request.
\r
156 * @see The USB 2.0 specification for more information on standard control requests.
\r
158 typedef ATTR_IAR_PACKED struct
\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
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
172 * @see Chapter 9 of the USB 2.0 Specification.
\r
174 enum USB_Control_Request_t
\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
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
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
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
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
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
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
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
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
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
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
218 /** Feature Selector values for Set Feature and Clear Feature standard control requests directed to the device, interface
\r
219 * and endpoint recipients.
\r
221 enum USB_Feature_Selectors_t
\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
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
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
238 /* Private Interface - For use in library only: */
\r
239 #if !defined(__DOXYGEN__)
\r
241 #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
\r
242 #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)
\r
245 /* Disable C linkage for C++ Compilers: */
\r
246 #if defined(__cplusplus)
\r