Keyboard firmwares for Atmel AVR and Cortex-M
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

USBDescriptor.h 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Copyright (c) 2010-2011 mbed.org, MIT License
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  4. * and associated documentation files (the "Software"), to deal in the Software without
  5. * restriction, including without limitation the rights to use, copy, modify, merge, publish,
  6. * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
  7. * Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or
  10. * substantial portions of the Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  13. * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. */
  18. /* Standard descriptor types */
  19. #define DEVICE_DESCRIPTOR (1)
  20. #define CONFIGURATION_DESCRIPTOR (2)
  21. #define STRING_DESCRIPTOR (3)
  22. #define INTERFACE_DESCRIPTOR (4)
  23. #define ENDPOINT_DESCRIPTOR (5)
  24. #define QUALIFIER_DESCRIPTOR (6)
  25. /* Standard descriptor lengths */
  26. #define DEVICE_DESCRIPTOR_LENGTH (0x12)
  27. #define CONFIGURATION_DESCRIPTOR_LENGTH (0x09)
  28. #define INTERFACE_DESCRIPTOR_LENGTH (0x09)
  29. #define ENDPOINT_DESCRIPTOR_LENGTH (0x07)
  30. /*string offset*/
  31. #define STRING_OFFSET_LANGID (0)
  32. #define STRING_OFFSET_IMANUFACTURER (1)
  33. #define STRING_OFFSET_IPRODUCT (2)
  34. #define STRING_OFFSET_ISERIAL (3)
  35. #define STRING_OFFSET_ICONFIGURATION (4)
  36. #define STRING_OFFSET_IINTERFACE (5)
  37. /* USB Specification Release Number */
  38. #define USB_VERSION_2_0 (0x0200)
  39. /* Least/Most significant byte of short integer */
  40. #define LSB(n) ((n)&0xff)
  41. #define MSB(n) (((n)&0xff00)>>8)
  42. /* Convert physical endpoint number to descriptor endpoint number */
  43. #define PHY_TO_DESC(endpoint) (((endpoint)>>1) | (((endpoint) & 1) ? 0x80:0))
  44. /* bmAttributes in configuration descriptor */
  45. /* C_RESERVED must always be set */
  46. #define C_RESERVED (1U<<7)
  47. #define C_SELF_POWERED (1U<<6)
  48. #define C_REMOTE_WAKEUP (1U<<5)
  49. /* bMaxPower in configuration descriptor */
  50. #define C_POWER(mA) ((mA)/2)
  51. /* bmAttributes in endpoint descriptor */
  52. #define E_CONTROL (0x00)
  53. #define E_ISOCHRONOUS (0x01)
  54. #define E_BULK (0x02)
  55. #define E_INTERRUPT (0x03)
  56. /* For isochronous endpoints only: */
  57. #define E_NO_SYNCHRONIZATION (0x00)
  58. #define E_ASYNCHRONOUS (0x04)
  59. #define E_ADAPTIVE (0x08)
  60. #define E_SYNCHRONOUS (0x0C)
  61. #define E_DATA (0x00)
  62. #define E_FEEDBACK (0x10)
  63. #define E_IMPLICIT_FEEDBACK (0x20)