+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Contains definitions for the various control request parameters, so that the request details (such as data\r
+ * direction, request recipient, etc.) can be extracted via masking.\r
+ */\r
+ \r
+#ifndef __STDREQTYPE_H__\r
+#define __STDREQTYPE_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device\r
+ * or Device to Host). The result of this mask should then be compared to the request direction masks.\r
+ *\r
+ * \see REQDIR_* macros for masks indicating the request data direction.\r
+ */\r
+ #define CONTROL_REQTYPE_DIRECTION 0b10000000\r
+\r
+ /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor\r
+ * Specific). The result of this mask should then be compared to the request type masks.\r
+ *\r
+ * \see REQTYPE_* macros for masks indicating the request type.\r
+ */\r
+ #define CONTROL_REQTYPE_TYPE 0b01100000\r
+\r
+ /** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class\r
+ * or Vendor Specific). The result of this mask should then be compared to the request recipient\r
+ * masks.\r
+ *\r
+ * \see REQREC_* macros for masks indicating the request recipient.\r
+ */\r
+ #define CONTROL_REQTYPE_RECIPIENT 0b00011111\r
+\r
+ /** Request data direction mask, indicating that the request data will flow from host to device.\r
+ *\r
+ * \see CONTROL_REQTYPE_DIRECTION macro.\r
+ */\r
+ #define REQDIR_HOSTTODEVICE (0 << 7)\r
+\r
+ /** Request data direction mask, indicating that the request data will flow from device to host.\r
+ *\r
+ * \see CONTROL_REQTYPE_DIRECTION macro.\r
+ */\r
+ #define REQDIR_DEVICETOHOST (1 << 7)\r
+\r
+ /** Request type mask, indicating that the request is a standard request.\r
+ *\r
+ * \see CONTROL_REQTYPE_TYPE macro.\r
+ */\r
+ #define REQTYPE_STANDARD (0 << 5)\r
+\r
+ /** Request type mask, indicating that the request is a class-specific request.\r
+ *\r
+ * \see CONTROL_REQTYPE_TYPE macro.\r
+ */\r
+ #define REQTYPE_CLASS (1 << 5)\r
+\r
+ /** Request type mask, indicating that the request is a vendor specific request.\r
+ *\r
+ * \see CONTROL_REQTYPE_TYPE macro.\r
+ */\r
+ #define REQTYPE_VENDOR (2 << 5)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to the device as a whole.\r
+ *\r
+ * \see CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_DEVICE (0 << 0)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to an interface in the\r
+ * currently selected configuration.\r
+ *\r
+ * \see CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_INTERFACE (1 << 0)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to an endpoint in the\r
+ * currently selected configuration.\r
+ *\r
+ * \see CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_ENDPOINT (2 << 0)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to an unspecified element\r
+ * in the currently selected configuration.\r
+ *\r
+ * \see CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_OTHER (3 << 0)\r
+ \r
+ /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature\r
+ * request this indicates that an endpoint (whose address is given elsewhere in the request\r
+ * should have its stall condition cleared. If used in a similar manner inside a Set Feature\r
+ * request, this stalls an endpoint.\r
+ */\r
+ #define FEATURE_ENDPOINT_HALT 0x00\r
+\r
+ /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature\r
+ * request this indicates that the remote wakeup enabled device should not issue remote\r
+ * wakeup requests until further notice. If used in a similar manner inside a Set Feature\r
+ * request, this re-enabled the remote wakeup feature on the device.\r
+ */\r
+ #define FEATURE_REMOTE_WAKEUP 0x01\r
+\r
+ /* Enums: */\r
+ /** Enumeration for the various standard request commands. These commands are applicable when the\r
+ * request type is REQTYPE_STANDARD (with the exception of REQ_GetDescriptor, which is always\r
+ * handled regardless of the request type value).\r
+ *\r
+ * \see Chapter 9 of the USB 2.0 Specification.\r
+ */\r
+ enum USB_Control_Request_t\r
+ {\r
+ REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface\r
+ * recipients. Passed to the user application for other recipients\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface\r
+ * recipients. Passed to the user application for other recipients\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface\r
+ * recipients. Passed to the user application for other recipients\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed\r
+ * to the user application for other recipients via the\r
+ * USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request\r
+ * types. */\r
+ REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed\r
+ * to the user application for other recipients via the\r
+ * USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed\r
+ * to the user application for other recipients via the\r
+ * USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ };\r
+\r
+/* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define FEATURE_SELFPOWERED_ENABLED (1 << 0)\r
+ #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)\r
+ #endif\r
+ \r
+#endif\r