Descriptors.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 <LUFA/Drivers/USB/USB.h>
  34. #include "Config/AppConfig.h"
  35. /* Macros: */
  36. #if defined(__AVR_AT90USB1287__)
  37. #define AVR_SIGNATURE_1 0x1E
  38. #define AVR_SIGNATURE_2 0x97
  39. #define AVR_SIGNATURE_3 0x82
  40. #elif defined(__AVR_AT90USB647__)
  41. #define AVR_SIGNATURE_1 0x1E
  42. #define AVR_SIGNATURE_2 0x96
  43. #define AVR_SIGNATURE_3 0x82
  44. #elif defined(__AVR_AT90USB1286__)
  45. #define AVR_SIGNATURE_1 0x1E
  46. #define AVR_SIGNATURE_2 0x97
  47. #define AVR_SIGNATURE_3 0x82
  48. #elif defined(__AVR_AT90USB646__)
  49. #define AVR_SIGNATURE_1 0x1E
  50. #define AVR_SIGNATURE_2 0x96
  51. #define AVR_SIGNATURE_3 0x82
  52. #elif defined(__AVR_ATmega32U4__)
  53. #define AVR_SIGNATURE_1 0x1E
  54. #define AVR_SIGNATURE_2 0x95
  55. #define AVR_SIGNATURE_3 0x87
  56. #elif defined(__AVR_ATmega16U4__)
  57. #define AVR_SIGNATURE_1 0x1E
  58. #define AVR_SIGNATURE_2 0x94
  59. #define AVR_SIGNATURE_3 0x88
  60. #elif defined(__AVR_ATmega32U2__)
  61. #define AVR_SIGNATURE_1 0x1E
  62. #define AVR_SIGNATURE_2 0x95
  63. #define AVR_SIGNATURE_3 0x8A
  64. #elif defined(__AVR_ATmega16U2__)
  65. #define AVR_SIGNATURE_1 0x1E
  66. #define AVR_SIGNATURE_2 0x94
  67. #define AVR_SIGNATURE_3 0x89
  68. #elif defined(__AVR_AT90USB162__)
  69. #define AVR_SIGNATURE_1 0x1E
  70. #define AVR_SIGNATURE_2 0x94
  71. #define AVR_SIGNATURE_3 0x82
  72. #elif defined(__AVR_ATmega8U2__)
  73. #define AVR_SIGNATURE_1 0x1E
  74. #define AVR_SIGNATURE_2 0x93
  75. #define AVR_SIGNATURE_3 0x89
  76. #elif defined(__AVR_AT90USB82__)
  77. #define AVR_SIGNATURE_1 0x1E
  78. #define AVR_SIGNATURE_2 0x93
  79. #define AVR_SIGNATURE_3 0x82
  80. #else
  81. #error The selected AVR part is not currently supported by this bootloader.
  82. #endif
  83. /** Endpoint address for the CDC control interface event notification endpoint. */
  84. #define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2)
  85. /** Endpoint address for the CDC data interface TX (data IN) endpoint. */
  86. #define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 3)
  87. /** Endpoint address for the CDC data interface RX (data OUT) endpoint. */
  88. #define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 4)
  89. /** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */
  90. #define CDC_TXRX_EPSIZE 16
  91. /** Size of the CDC control interface notification endpoint bank, in bytes. */
  92. #define CDC_NOTIFICATION_EPSIZE 8
  93. /* Type Defines: */
  94. /** Type define for the device configuration descriptor structure. This must be defined in the
  95. * application code, as the configuration descriptor contains several sub-descriptors which
  96. * vary between devices, and which describe the device's usage to the host.
  97. */
  98. typedef struct
  99. {
  100. USB_Descriptor_Configuration_Header_t Config;
  101. // CDC Control Interface
  102. USB_Descriptor_Interface_t CDC_CCI_Interface;
  103. USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
  104. USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
  105. USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union;
  106. USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
  107. // CDC Data Interface
  108. USB_Descriptor_Interface_t CDC_DCI_Interface;
  109. USB_Descriptor_Endpoint_t CDC_DataOutEndpoint;
  110. USB_Descriptor_Endpoint_t CDC_DataInEndpoint;
  111. } USB_Descriptor_Configuration_t;
  112. /** Enum for the device interface descriptor IDs within the device. Each interface descriptor
  113. * should have a unique ID index associated with it, which can be used to refer to the
  114. * interface from other descriptors.
  115. */
  116. enum InterfaceDescriptors_t
  117. {
  118. INTERFACE_ID_CDC_CCI = 0, /**< CDC CCI interface descriptor ID */
  119. INTERFACE_ID_CDC_DCI = 1, /**< CDC DCI interface descriptor ID */
  120. };
  121. /** Enum for the device string descriptor IDs within the device. Each string descriptor should
  122. * have a unique ID index associated with it, which can be used to refer to the string from
  123. * other descriptors.
  124. */
  125. enum StringDescriptors_t
  126. {
  127. STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
  128. STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
  129. STRING_ID_Product = 2, /**< Product string ID */
  130. };
  131. /* Function Prototypes: */
  132. uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
  133. const uint16_t wIndex,
  134. const void** const DescriptorAddress)
  135. ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
  136. #endif