Descriptors.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2018.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Copyright 2012 Simon Foster (simon.foster [at] inbox [dot] com)
  10. Permission to use, copy, modify, distribute, and sell this
  11. software and its documentation for any purpose is hereby granted
  12. without fee, provided that the above copyright notice appear in
  13. all copies and that both that the copyright notice and this
  14. permission notice and warranty disclaimer appear in supporting
  15. documentation, and that the name of the author not be used in
  16. advertising or publicity pertaining to distribution of the
  17. software without specific, written prior permission.
  18. The author disclaims all warranties with regard to this
  19. software, including all implied warranties of merchantability
  20. and fitness. In no event shall the author be liable for any
  21. special, indirect or consequential damages or any damages
  22. whatsoever resulting from loss of use, data or profits, whether
  23. in an action of contract, negligence or other tortious action,
  24. arising out of or in connection with the use or performance of
  25. this software.
  26. */
  27. /** \file
  28. *
  29. * Header file for Descriptors.c.
  30. */
  31. #ifndef _DESCRIPTORS_H_
  32. #define _DESCRIPTORS_H_
  33. /* Includes: */
  34. #include <avr/pgmspace.h>
  35. #include <LUFA/Drivers/USB/USB.h>
  36. /* Macros: */
  37. /** Endpoint address of the CDC device-to-host notification IN endpoint. */
  38. #define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2)
  39. /** Endpoint address of the CDC device-to-host data IN endpoint. */
  40. #define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 3)
  41. /** Endpoint address of the CDC host-to-device data OUT endpoint. */
  42. #define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 4)
  43. /** Size in bytes of the CDC device-to-host notification IN endpoint. */
  44. #define CDC_NOTIFICATION_EPSIZE 8
  45. /** Size in bytes of the CDC data IN and OUT endpoints. */
  46. #define CDC_TXRX_EPSIZE 16
  47. /* Type Defines: */
  48. /** Type define for the device configuration descriptor structure. This must be defined in the
  49. * application code, as the configuration descriptor contains several sub-descriptors which
  50. * vary between devices, and which describe the device's usage to the host.
  51. */
  52. typedef struct
  53. {
  54. USB_Descriptor_Configuration_Header_t Config;
  55. // CDC Command Interface
  56. USB_Descriptor_Interface_t CDC_CCI_Interface;
  57. USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
  58. USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
  59. USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union;
  60. USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
  61. // CDC Data Interface
  62. USB_Descriptor_Interface_t CDC_DCI_Interface;
  63. USB_Descriptor_Endpoint_t CDC_DataOutEndpoint;
  64. USB_Descriptor_Endpoint_t CDC_DataInEndpoint;
  65. } USB_Descriptor_Configuration_t;
  66. /** Enum for the device interface descriptor IDs within the device. Each interface descriptor
  67. * should have a unique ID index associated with it, which can be used to refer to the
  68. * interface from other descriptors.
  69. */
  70. enum InterfaceDescriptors_t
  71. {
  72. INTERFACE_ID_CDC_CCI = 0, /**< CDC CCI interface descriptor ID */
  73. INTERFACE_ID_CDC_DCI = 1, /**< CDC DCI interface descriptor ID */
  74. };
  75. /** Enum for the device string descriptor IDs within the device. Each string descriptor should
  76. * have a unique ID index associated with it, which can be used to refer to the string from
  77. * other descriptors.
  78. */
  79. enum StringDescriptors_t
  80. {
  81. STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
  82. STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
  83. STRING_ID_Product = 2, /**< Product string ID */
  84. };
  85. /* Function Prototypes: */
  86. uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
  87. const uint16_t wIndex,
  88. const void** const DescriptorAddress)
  89. ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
  90. #endif