Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StdRequestType.h 11KB

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