Keyboard firmwares for Atmel AVR and Cortex-M
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

StdDescriptors.h 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  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 Common standard USB Descriptor definitions for all architectures.
  28. * \copydetails Group_StdDescriptors
  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_StdDescriptors USB Descriptors
  35. * \brief Standard USB Descriptor definitions.
  36. *
  37. * Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains
  38. * structures and macros for the easy creation of standard USB descriptors in USB device projects.
  39. *
  40. * @{
  41. */
  42. #ifndef __USBDESCRIPTORS_H__
  43. #define __USBDESCRIPTORS_H__
  44. /* Includes: */
  45. #include "../../../Common/Common.h"
  46. #include "USBMode.h"
  47. #include "Events.h"
  48. /* Enable C linkage for C++ Compilers: */
  49. #if defined(__cplusplus)
  50. extern "C" {
  51. #endif
  52. /* Preprocessor Checks: */
  53. #if !defined(__INCLUDE_FROM_USB_DRIVER)
  54. #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
  55. #endif
  56. /* Public Interface - May be used in end-application: */
  57. /* Macros: */
  58. /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
  59. * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
  60. * descriptor does not exist.
  61. */
  62. #define NO_DESCRIPTOR 0
  63. /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
  64. *
  65. * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected.
  66. */
  67. #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
  68. /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
  69. * Should be used in string descriptor's headers for giving the string descriptor's byte length.
  70. *
  71. * \param[in] UnicodeChars Number of Unicode characters in the string text.
  72. */
  73. #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
  74. /** Convenience macro to easily create \ref USB_Descriptor_String_t instances from a wide character string.
  75. *
  76. * \note This macro is for little-endian systems only.
  77. *
  78. * \param[in] String String to initialize a USB String Descriptor structure with.
  79. */
  80. #define USB_STRING_DESCRIPTOR(String) { .Header = {.Size = sizeof(USB_Descriptor_Header_t) + (sizeof(String) - 2), .Type = DTYPE_String}, .UnicodeString = String }
  81. /** Convenience macro to easily create \ref USB_Descriptor_String_t instances from an array of characters.
  82. *
  83. * \param[in] ... Characters to initialize a USB String Descriptor structure with.
  84. */
  85. #define USB_STRING_DESCRIPTOR_ARRAY(...) { .Header = {.Size = sizeof(USB_Descriptor_Header_t) + sizeof((uint16_t){__VA_ARGS__}), .Type = DTYPE_String}, .UnicodeString = {__VA_ARGS__} }
  86. /** Macro to encode a given major/minor/revision version number into Binary Coded Decimal format for descriptor
  87. * fields requiring BCD encoding, such as the USB version number in the standard device descriptor.
  88. *
  89. * \note This value is automatically converted into Little Endian, suitable for direct use inside device
  90. * descriptors on all architectures without endianness conversion macros.
  91. *
  92. * \param[in] Major Major version number to encode.
  93. * \param[in] Minor Minor version number to encode.
  94. * \param[in] Revision Revision version number to encode.
  95. */
  96. #define VERSION_BCD(Major, Minor, Revision) \
  97. CPU_TO_LE16( ((Major & 0xFF) << 8) | \
  98. ((Minor & 0x0F) << 4) | \
  99. (Revision & 0x0F) )
  100. /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
  101. * to indicate that the English language is supported by the device in its string descriptors.
  102. */
  103. #define LANGUAGE_ID_ENG 0x0409
  104. /** \name USB Configuration Descriptor Attribute Masks */
  105. //@{
  106. /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be set on all
  107. * devices for historical purposes.
  108. */
  109. #define USB_CONFIG_ATTR_RESERVED 0x80
  110. /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
  111. * descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power
  112. * from the device's own power source.
  113. */
  114. #define USB_CONFIG_ATTR_SELFPOWERED 0x40
  115. /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
  116. * descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the
  117. * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
  118. * request.
  119. */
  120. #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
  121. //@}
  122. /** \name Endpoint Descriptor Attribute Masks */
  123. //@{
  124. /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
  125. * \c Attributes value to indicate that the specified endpoint is not synchronized.
  126. *
  127. * \see The USB specification for more details on the possible Endpoint attributes.
  128. */
  129. #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
  130. /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
  131. * \c Attributes value to indicate that the specified endpoint is asynchronous.
  132. *
  133. * \see The USB specification for more details on the possible Endpoint attributes.
  134. */
  135. #define ENDPOINT_ATTR_ASYNC (1 << 2)
  136. /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
  137. * \c Attributes value to indicate that the specified endpoint is adaptive.
  138. *
  139. * \see The USB specification for more details on the possible Endpoint attributes.
  140. */
  141. #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
  142. /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
  143. * \c Attributes value to indicate that the specified endpoint is synchronized.
  144. *
  145. * \see The USB specification for more details on the possible Endpoint attributes.
  146. */
  147. #define ENDPOINT_ATTR_SYNC (3 << 2)
  148. //@}
  149. /** \name Endpoint Descriptor Usage Masks */
  150. //@{
  151. /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
  152. * \c Attributes value to indicate that the specified endpoint is used for data transfers.
  153. *
  154. * \see The USB specification for more details on the possible Endpoint usage attributes.
  155. */
  156. #define ENDPOINT_USAGE_DATA (0 << 4)
  157. /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
  158. * \c Attributes value to indicate that the specified endpoint is used for feedback.
  159. *
  160. * \see The USB specification for more details on the possible Endpoint usage attributes.
  161. */
  162. #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
  163. /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
  164. * \c Attributes value to indicate that the specified endpoint is used for implicit feedback.
  165. *
  166. * \see The USB specification for more details on the possible Endpoint usage attributes.
  167. */
  168. #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
  169. //@}
  170. /* Enums: */
  171. /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
  172. enum USB_DescriptorTypes_t
  173. {
  174. DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */
  175. DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
  176. DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */
  177. DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */
  178. DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
  179. DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
  180. DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */
  181. DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
  182. DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
  183. DTYPE_CSInterface = 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
  184. DTYPE_CSEndpoint = 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
  185. };
  186. /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
  187. enum USB_Descriptor_ClassSubclassProtocol_t
  188. {
  189. USB_CSCP_NoDeviceClass = 0x00, /**< Descriptor Class value indicating that the device does not belong
  190. * to a particular class at the device level.
  191. */
  192. USB_CSCP_NoDeviceSubclass = 0x00, /**< Descriptor Subclass value indicating that the device does not belong
  193. * to a particular subclass at the device level.
  194. */
  195. USB_CSCP_NoDeviceProtocol = 0x00, /**< Descriptor Protocol value indicating that the device does not belong
  196. * to a particular protocol at the device level.
  197. */
  198. USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
  199. * to a vendor specific class.
  200. */
  201. USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
  202. * to a vendor specific subclass.
  203. */
  204. USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
  205. * to a vendor specific protocol.
  206. */
  207. USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the
  208. * Interface Association Descriptor class.
  209. */
  210. USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
  211. * Interface Association Descriptor subclass.
  212. */
  213. USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
  214. * Interface Association Descriptor protocol.
  215. */
  216. };
  217. /* Type Defines: */
  218. /** \brief Standard USB Descriptor Header (LUFA naming conventions).
  219. *
  220. * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
  221. * uses LUFA-specific element names to make each element's purpose clearer.
  222. *
  223. * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
  224. *
  225. * \note Regardless of CPU architecture, these values should be stored as little endian.
  226. */
  227. typedef struct
  228. {
  229. uint8_t Size; /**< Size of the descriptor, in bytes. */
  230. uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  231. * given by the specific class.
  232. */
  233. } ATTR_PACKED USB_Descriptor_Header_t;
  234. /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
  235. *
  236. * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
  237. * uses the relevant standard's given element names to ensure compatibility with the standard.
  238. *
  239. * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
  240. *
  241. * \note Regardless of CPU architecture, these values should be stored as little endian.
  242. */
  243. typedef struct
  244. {
  245. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  246. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  247. * given by the specific class.
  248. */
  249. } ATTR_PACKED USB_StdDescriptor_Header_t;
  250. /** \brief Standard USB Device Descriptor (LUFA naming conventions).
  251. *
  252. * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
  253. * element's purpose clearer.
  254. *
  255. * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
  256. *
  257. * \note Regardless of CPU architecture, these values should be stored as little endian.
  258. */
  259. typedef struct
  260. {
  261. USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
  262. uint16_t USBSpecification; /**< BCD of the supported USB specification.
  263. *
  264. * \see \ref VERSION_BCD() utility macro.
  265. */
  266. uint8_t Class; /**< USB device class. */
  267. uint8_t SubClass; /**< USB device subclass. */
  268. uint8_t Protocol; /**< USB device protocol. */
  269. uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
  270. uint16_t VendorID; /**< Vendor ID for the USB product. */
  271. uint16_t ProductID; /**< Unique product ID for the USB product. */
  272. uint16_t ReleaseNumber; /**< Product release (version) number.
  273. *
  274. * \see \ref VERSION_BCD() utility macro.
  275. */
  276. uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The
  277. * host will request this string via a separate
  278. * control request for the string descriptor.
  279. *
  280. * \note If no string supplied, use \ref NO_DESCRIPTOR.
  281. */
  282. uint8_t ProductStrIndex; /**< String index for the product name/details.
  283. *
  284. * \see ManufacturerStrIndex structure entry.
  285. */
  286. uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
  287. * serial number, in uppercase Unicode ASCII.
  288. *
  289. * \note On some microcontroller models, there is an embedded serial number
  290. * in the chip which can be used for the device serial number.
  291. * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
  292. * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
  293. * and will cause the host to generate a pseudo-unique value for the
  294. * device upon insertion.
  295. *
  296. * \see \c ManufacturerStrIndex structure entry.
  297. */
  298. uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
  299. * the device.
  300. */
  301. } ATTR_PACKED USB_Descriptor_Device_t;
  302. /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
  303. *
  304. * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
  305. * to ensure compatibility with the standard.
  306. *
  307. * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
  308. *
  309. * \note Regardless of CPU architecture, these values should be stored as little endian.
  310. */
  311. typedef struct
  312. {
  313. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  314. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  315. * given by the specific class.
  316. */
  317. uint16_t bcdUSB; /**< BCD of the supported USB specification.
  318. *
  319. * \see \ref VERSION_BCD() utility macro.
  320. */
  321. uint8_t bDeviceClass; /**< USB device class. */
  322. uint8_t bDeviceSubClass; /**< USB device subclass. */
  323. uint8_t bDeviceProtocol; /**< USB device protocol. */
  324. uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
  325. uint16_t idVendor; /**< Vendor ID for the USB product. */
  326. uint16_t idProduct; /**< Unique product ID for the USB product. */
  327. uint16_t bcdDevice; /**< Product release (version) number.
  328. *
  329. * \see \ref VERSION_BCD() utility macro.
  330. */
  331. uint8_t iManufacturer; /**< String index for the manufacturer's name. The
  332. * host will request this string via a separate
  333. * control request for the string descriptor.
  334. *
  335. * \note If no string supplied, use \ref NO_DESCRIPTOR.
  336. */
  337. uint8_t iProduct; /**< String index for the product name/details.
  338. *
  339. * \see ManufacturerStrIndex structure entry.
  340. */
  341. uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
  342. * serial number, in uppercase Unicode ASCII.
  343. *
  344. * \note On some microcontroller models, there is an embedded serial number
  345. * in the chip which can be used for the device serial number.
  346. * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
  347. * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
  348. * and will cause the host to generate a pseudo-unique value for the
  349. * device upon insertion.
  350. *
  351. * \see \c ManufacturerStrIndex structure entry.
  352. */
  353. uint8_t bNumConfigurations; /**< Total number of configurations supported by
  354. * the device.
  355. */
  356. } ATTR_PACKED USB_StdDescriptor_Device_t;
  357. /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).
  358. *
  359. * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names
  360. * to make each element's purpose clearer.
  361. *
  362. * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
  363. */
  364. typedef struct
  365. {
  366. USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
  367. uint16_t USBSpecification; /**< BCD of the supported USB specification.
  368. *
  369. * \see \ref VERSION_BCD() utility macro.
  370. */
  371. uint8_t Class; /**< USB device class. */
  372. uint8_t SubClass; /**< USB device subclass. */
  373. uint8_t Protocol; /**< USB device protocol. */
  374. uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
  375. uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
  376. * the device.
  377. */
  378. uint8_t Reserved; /**< Reserved for future use, must be 0. */
  379. } ATTR_PACKED USB_Descriptor_DeviceQualifier_t;
  380. /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
  381. *
  382. * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names
  383. * to ensure compatibility with the standard.
  384. *
  385. * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.
  386. */
  387. typedef struct
  388. {
  389. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  390. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  391. * given by the specific class.
  392. */
  393. uint16_t bcdUSB; /**< BCD of the supported USB specification.
  394. *
  395. * \see \ref VERSION_BCD() utility macro.
  396. */
  397. uint8_t bDeviceClass; /**< USB device class. */
  398. uint8_t bDeviceSubClass; /**< USB device subclass. */
  399. uint8_t bDeviceProtocol; /**< USB device protocol. */
  400. uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
  401. uint8_t bNumConfigurations; /**< Total number of configurations supported by
  402. * the device.
  403. */
  404. uint8_t bReserved; /**< Reserved for future use, must be 0. */
  405. } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t;
  406. /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
  407. *
  408. * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
  409. * to make each element's purpose clearer.
  410. *
  411. * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
  412. *
  413. * \note Regardless of CPU architecture, these values should be stored as little endian.
  414. */
  415. typedef struct
  416. {
  417. USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
  418. uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
  419. * and all sub descriptors inside the configuration.
  420. */
  421. uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
  422. uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
  423. uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
  424. uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
  425. * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
  426. */
  427. uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the
  428. * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
  429. * macro.
  430. */
  431. } ATTR_PACKED USB_Descriptor_Configuration_Header_t;
  432. /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
  433. *
  434. * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
  435. * to ensure compatibility with the standard.
  436. *
  437. * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
  438. *
  439. * \note Regardless of CPU architecture, these values should be stored as little endian.
  440. */
  441. typedef struct
  442. {
  443. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  444. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  445. * given by the specific class.
  446. */
  447. uint16_t wTotalLength; /**< Size of the configuration descriptor header,
  448. * and all sub descriptors inside the configuration.
  449. */
  450. uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */
  451. uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */
  452. uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */
  453. uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
  454. * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
  455. */
  456. uint8_t bMaxPower; /**< Maximum power consumption of the device while in the
  457. * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
  458. * macro.
  459. */
  460. } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t;
  461. /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
  462. *
  463. * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
  464. * to make each element's purpose clearer.
  465. *
  466. * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
  467. *
  468. * \note Regardless of CPU architecture, these values should be stored as little endian.
  469. */
  470. typedef struct
  471. {
  472. USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
  473. uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */
  474. uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same
  475. * interface number can have multiple alternate settings
  476. * with different endpoint configurations, which can be
  477. * selected by the host.
  478. */
  479. uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
  480. uint8_t Class; /**< Interface class ID. */
  481. uint8_t SubClass; /**< Interface subclass ID. */
  482. uint8_t Protocol; /**< Interface protocol ID. */
  483. uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */
  484. } ATTR_PACKED USB_Descriptor_Interface_t;
  485. /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
  486. *
  487. * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
  488. * to ensure compatibility with the standard.
  489. *
  490. * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
  491. *
  492. * \note Regardless of CPU architecture, these values should be stored as little endian.
  493. */
  494. typedef struct
  495. {
  496. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  497. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  498. * given by the specific class.
  499. */
  500. uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */
  501. uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same
  502. * interface number can have multiple alternate settings
  503. * with different endpoint configurations, which can be
  504. * selected by the host.
  505. */
  506. uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */
  507. uint8_t bInterfaceClass; /**< Interface class ID. */
  508. uint8_t bInterfaceSubClass; /**< Interface subclass ID. */
  509. uint8_t bInterfaceProtocol; /**< Interface protocol ID. */
  510. uint8_t iInterface; /**< Index of the string descriptor describing the
  511. * interface.
  512. */
  513. } ATTR_PACKED USB_StdDescriptor_Interface_t;
  514. /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
  515. *
  516. * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
  517. * to make each element's purpose clearer.
  518. *
  519. * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
  520. * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
  521. * devices with multiple interfaces related to the same function to have the multiple interfaces bound
  522. * together at the point of enumeration, loading one generic driver for all the interfaces in the single
  523. * function. Read the ECN for more information.
  524. *
  525. * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
  526. *
  527. * \note Regardless of CPU architecture, these values should be stored as little endian.
  528. */
  529. typedef struct
  530. {
  531. USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
  532. uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
  533. uint8_t TotalInterfaces; /**< Total number of associated interfaces. */
  534. uint8_t Class; /**< Interface class ID. */
  535. uint8_t SubClass; /**< Interface subclass ID. */
  536. uint8_t Protocol; /**< Interface protocol ID. */
  537. uint8_t IADStrIndex; /**< Index of the string descriptor describing the
  538. * interface association.
  539. */
  540. } ATTR_PACKED USB_Descriptor_Interface_Association_t;
  541. /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
  542. *
  543. * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
  544. * element names to ensure compatibility with the standard.
  545. *
  546. * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
  547. * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
  548. * devices with multiple interfaces related to the same function to have the multiple interfaces bound
  549. * together at the point of enumeration, loading one generic driver for all the interfaces in the single
  550. * function. Read the ECN for more information.
  551. *
  552. * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
  553. * element names.
  554. *
  555. * \note Regardless of CPU architecture, these values should be stored as little endian.
  556. */
  557. typedef struct
  558. {
  559. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  560. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  561. * given by the specific class.
  562. */
  563. uint8_t bFirstInterface; /**< Index of the first associated interface. */
  564. uint8_t bInterfaceCount; /**< Total number of associated interfaces. */
  565. uint8_t bFunctionClass; /**< Interface class ID. */
  566. uint8_t bFunctionSubClass; /**< Interface subclass ID. */
  567. uint8_t bFunctionProtocol; /**< Interface protocol ID. */
  568. uint8_t iFunction; /**< Index of the string descriptor describing the
  569. * interface association.
  570. */
  571. } ATTR_PACKED USB_StdDescriptor_Interface_Association_t;
  572. /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
  573. *
  574. * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
  575. * to make each element's purpose clearer.
  576. *
  577. * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
  578. *
  579. * \note Regardless of CPU architecture, these values should be stored as little endian.
  580. */
  581. typedef struct
  582. {
  583. USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
  584. uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current
  585. * configuration, including direction mask.
  586. */
  587. uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
  588. * and attributes (ENDPOINT_ATTR_*) masks.
  589. */
  590. uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
  591. * size that the endpoint can receive at a time.
  592. */
  593. uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
  594. * or ISOCHRONOUS type.
  595. */
  596. } ATTR_PACKED USB_Descriptor_Endpoint_t;
  597. /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
  598. *
  599. * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
  600. * element names to ensure compatibility with the standard.
  601. *
  602. * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
  603. * element names.
  604. *
  605. * \note Regardless of CPU architecture, these values should be stored as little endian.
  606. */
  607. typedef struct
  608. {
  609. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  610. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
  611. * value given by the specific class.
  612. */
  613. uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current
  614. * configuration, including direction mask.
  615. */
  616. uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
  617. * and attributes (ENDPOINT_ATTR_*) masks.
  618. */
  619. uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
  620. * that the endpoint can receive at a time.
  621. */
  622. uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
  623. * ISOCHRONOUS type.
  624. */
  625. } ATTR_PACKED USB_StdDescriptor_Endpoint_t;
  626. /** \brief Standard USB String Descriptor (LUFA naming conventions).
  627. *
  628. * Type define for a standard string descriptor. Unlike other standard descriptors, the length
  629. * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
  630. * macro rather than by the size of the descriptor structure, as the length is not fixed.
  631. *
  632. * This structure should also be used for string index 0, which contains the supported language IDs for
  633. * the device as an array.
  634. *
  635. * This structure uses LUFA-specific element names to make each element's purpose clearer.
  636. *
  637. * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
  638. *
  639. * \note Regardless of CPU architecture, these values should be stored as little endian.
  640. */
  641. typedef struct
  642. {
  643. USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
  644. #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__))
  645. wchar_t UnicodeString[];
  646. #else
  647. uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
  648. * string language IDs). If normal ASCII characters are
  649. * to be used, they must be added as an array of characters
  650. * rather than a normal C string so that they are widened to
  651. * Unicode size.
  652. *
  653. * Under GCC, strings prefixed with the "L" character (before
  654. * the opening string quotation mark) are considered to be
  655. * Unicode strings, and may be used instead of an explicit
  656. * array of ASCII characters on little endian devices with
  657. * UTF-16-LE \c wchar_t encoding.
  658. */
  659. #endif
  660. } ATTR_PACKED USB_Descriptor_String_t;
  661. /** \brief Standard USB String Descriptor (USB-IF naming conventions).
  662. *
  663. * Type define for a standard string descriptor. Unlike other standard descriptors, the length
  664. * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
  665. * macro rather than by the size of the descriptor structure, as the length is not fixed.
  666. *
  667. * This structure should also be used for string index 0, which contains the supported language IDs for
  668. * the device as an array.
  669. *
  670. * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
  671. *
  672. * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
  673. * element names.
  674. *
  675. * \note Regardless of CPU architecture, these values should be stored as little endian.
  676. */
  677. typedef struct
  678. {
  679. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  680. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
  681. * or a value given by the specific class.
  682. */
  683. uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs).
  684. * If normal ASCII characters are to be used, they must be added as an array
  685. * of characters rather than a normal C string so that they are widened to
  686. * Unicode size.
  687. *
  688. * Under GCC, strings prefixed with the "L" character (before the opening string
  689. * quotation mark) are considered to be Unicode strings, and may be used instead
  690. * of an explicit array of ASCII characters.
  691. */
  692. } ATTR_PACKED USB_StdDescriptor_String_t;
  693. /* Disable C linkage for C++ Compilers: */
  694. #if defined(__cplusplus)
  695. }
  696. #endif
  697. #endif
  698. /** @} */