Descriptors.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. 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. *
  28. * Header file for Descriptors.c.
  29. */
  30. #ifndef _DESCRIPTORS_H_
  31. #define _DESCRIPTORS_H_
  32. /* Includes: */
  33. #include <avr/pgmspace.h>
  34. #include <LUFA/Drivers/USB/USB.h>
  35. #include "Config/AppConfig.h"
  36. /* Macros: */
  37. /** Endpoint address of the Mass Storage device-to-host data IN endpoint. */
  38. #define MASS_STORAGE_IN_EPADDR (ENDPOINT_DIR_IN | 3)
  39. /** Endpoint address of the Mass Storage host-to-device data OUT endpoint. */
  40. #define MASS_STORAGE_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
  41. /** Size in bytes of the Mass Storage data endpoints. */
  42. #define MASS_STORAGE_IO_EPSIZE 64
  43. /** Endpoint address of the CDC device-to-host notification IN endpoint. */
  44. #define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 5)
  45. /** Endpoint address of the CDC device-to-host data IN endpoint. */
  46. #define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 1)
  47. /** Endpoint address of the CDC host-to-device data OUT endpoint. */
  48. #define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 2)
  49. /** Size in bytes of the CDC device-to-host notification IN endpoint. */
  50. #define CDC_NOTIFICATION_EPSIZE 8
  51. /** Size in bytes of the CDC data IN and OUT endpoints. */
  52. #define CDC_TXRX_EPSIZE 64
  53. /* Type Defines: */
  54. /** Type define for the device configuration descriptor structure. This must be defined in the
  55. * application code, as the configuration descriptor contains several sub-descriptors which
  56. * vary between devices, and which describe the device's usage to the host.
  57. */
  58. typedef struct
  59. {
  60. USB_Descriptor_Configuration_Header_t Config;
  61. // RNDIS CDC Command Interface
  62. USB_Descriptor_Interface_Association_t CDC_IAD;
  63. USB_Descriptor_Interface_t CDC_CCI_Interface;
  64. USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
  65. USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
  66. USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union;
  67. USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
  68. // RNDIS CDC Data Interface
  69. USB_Descriptor_Interface_t CDC_DCI_Interface;
  70. USB_Descriptor_Endpoint_t RNDIS_DataOutEndpoint;
  71. USB_Descriptor_Endpoint_t RNDIS_DataInEndpoint;
  72. // Mass Storage Interface
  73. USB_Descriptor_Interface_t MS_Interface;
  74. USB_Descriptor_Endpoint_t MS_DataInEndpoint;
  75. USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
  76. } USB_Descriptor_Configuration_t;
  77. /** Enum for the device interface descriptor IDs within the device. Each interface descriptor
  78. * should have a unique ID index associated with it, which can be used to refer to the
  79. * interface from other descriptors.
  80. */
  81. enum InterfaceDescriptors_t
  82. {
  83. INTERFACE_ID_CDC_CCI = 0, /**< CDC CCI interface descriptor ID */
  84. INTERFACE_ID_CDC_DCI = 1, /**< CDC DCI interface descriptor ID */
  85. INTERFACE_ID_MassStorage = 2, /**< Mass storage interface descriptor ID */
  86. };
  87. /** Enum for the device string descriptor IDs within the device. Each string descriptor should
  88. * have a unique ID index associated with it, which can be used to refer to the string from
  89. * other descriptors.
  90. */
  91. enum StringDescriptors_t
  92. {
  93. STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
  94. STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
  95. STRING_ID_Product = 2, /**< Product string ID */
  96. };
  97. /* Function Prototypes: */
  98. uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
  99. const uint16_t wIndex,
  100. const void** const DescriptorAddress)
  101. ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
  102. #endif