usb_descriptors.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2016, Alex Taradov <alex@taradov.com>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. The name of the author may not be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  20. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  23. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  24. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  25. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  26. * POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #ifndef _USB_DESCRIPTORS_H_
  29. #define _USB_DESCRIPTORS_H_
  30. /*- Includes ----------------------------------------------------------------*/
  31. #include "usb.h"
  32. #include "utils.h"
  33. /*- Definitions -------------------------------------------------------------*/
  34. enum
  35. {
  36. USB_HID_DESCRIPTOR = 0x21,
  37. USB_HID_REPORT_DESCRIPTOR = 0x22,
  38. USB_HID_PHYSICAL_DESCRIPTOR = 0x23,
  39. };
  40. enum
  41. {
  42. USB_STR_ZERO,
  43. USB_STR_MANUFACTURER,
  44. USB_STR_PRODUCT,
  45. USB_STR_SERIAL_NUMBER,
  46. USB_STR_CONFIGURATION,
  47. USB_STR_INTERFACE,
  48. USB_STR_COUNT,
  49. };
  50. /*- Types -------------------------------------------------------------------*/
  51. typedef struct PACK
  52. {
  53. uint8_t bLength;
  54. uint8_t bDescriptorType;
  55. uint16_t bcdHID;
  56. uint8_t bCountryCode;
  57. uint8_t bNumDescriptors;
  58. uint8_t bDescriptorType1;
  59. uint16_t wDescriptorLength;
  60. } usb_hid_descriptor_t;
  61. typedef struct PACK
  62. {
  63. usb_configuration_descriptor_t configuration;
  64. usb_interface_descriptor_t interface;
  65. usb_hid_descriptor_t hid;
  66. usb_endpoint_descriptor_t ep_in;
  67. usb_endpoint_descriptor_t ep_out;
  68. } usb_configuration_hierarchy_t;
  69. //-----------------------------------------------------------------------------
  70. extern const usb_device_descriptor_t usb_device_descriptor;
  71. extern const usb_configuration_hierarchy_t usb_configuration_hierarchy;
  72. extern const uint8_t usb_hid_report_descriptor[28];
  73. extern const usb_string_descriptor_zero_t usb_string_descriptor_zero;
  74. extern const char *const usb_strings[];
  75. #endif // _USB_DESCRIPTORS_H_