My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

udi_composite_desc.c 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /**
  2. * \file
  3. *
  4. * \brief Descriptors for an USB Composite Device
  5. *
  6. * Copyright (c) 2009-2016 Atmel Corporation. All rights reserved.
  7. *
  8. * \asf_license_start
  9. *
  10. * \page License
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. *
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. *
  22. * 3. The name of Atmel may not be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * 4. This software may only be redistributed and used in connection with an
  26. * Atmel microcontroller product.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  29. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  30. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  31. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  32. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. * \asf_license_stop
  41. *
  42. */
  43. /*
  44. * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
  45. */
  46. #ifdef ARDUINO_ARCH_SAM
  47. #include "conf_usb.h"
  48. #include "udd.h"
  49. #include "udc_desc.h"
  50. #if ENABLED(SDSUPPORT)
  51. /**
  52. * \defgroup udi_group_desc Descriptors for a USB Device
  53. * composite
  54. *
  55. * @{
  56. */
  57. /**INDENT-OFF**/
  58. //! USB Device Descriptor
  59. COMPILER_WORD_ALIGNED
  60. UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {
  61. .bLength = sizeof(usb_dev_desc_t),
  62. .bDescriptorType = USB_DT_DEVICE,
  63. .bcdUSB = LE16(USB_V2_0),
  64. .bDeviceClass = CDC_CLASS_MULTI,
  65. .bDeviceSubClass = CDC_SUBCLASS_ACM,
  66. .bDeviceProtocol = CDC_PROTOCOL_V25TER,
  67. .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
  68. .idVendor = LE16(USB_DEVICE_VENDOR_ID),
  69. .idProduct = LE16(USB_DEVICE_PRODUCT_ID),
  70. .bcdDevice = LE16((USB_DEVICE_MAJOR_VERSION << 8)
  71. | USB_DEVICE_MINOR_VERSION),
  72. #ifdef USB_DEVICE_MANUFACTURE_NAME
  73. .iManufacturer = 1,
  74. #else
  75. .iManufacturer = 0, // No manufacture string
  76. #endif
  77. #ifdef USB_DEVICE_PRODUCT_NAME
  78. .iProduct = 2,
  79. #else
  80. .iProduct = 0, // No product string
  81. #endif
  82. #if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER)
  83. .iSerialNumber = 3,
  84. #else
  85. .iSerialNumber = 0, // No serial string
  86. #endif
  87. .bNumConfigurations = 1
  88. };
  89. #ifdef USB_DEVICE_HS_SUPPORT
  90. //! USB Device Qualifier Descriptor for HS
  91. COMPILER_WORD_ALIGNED
  92. UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
  93. .bLength = sizeof(usb_dev_qual_desc_t),
  94. .bDescriptorType = USB_DT_DEVICE_QUALIFIER,
  95. .bcdUSB = LE16(USB_V2_0),
  96. .bDeviceClass = CDC_CLASS_MULTI,
  97. .bDeviceSubClass = CDC_SUBCLASS_ACM,
  98. .bDeviceProtocol = CDC_PROTOCOL_V25TER,
  99. .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
  100. .bNumConfigurations = 1
  101. };
  102. #endif
  103. //! Structure for USB Device Configuration Descriptor
  104. COMPILER_PACK_SET(1)
  105. typedef struct {
  106. usb_conf_desc_t conf;
  107. UDI_COMPOSITE_DESC_T;
  108. } udc_desc_t;
  109. COMPILER_PACK_RESET()
  110. //! USB Device Configuration Descriptor filled for FS
  111. COMPILER_WORD_ALIGNED
  112. UDC_DESC_STORAGE udc_desc_t udc_desc_fs = {
  113. .conf.bLength = sizeof(usb_conf_desc_t),
  114. .conf.bDescriptorType = USB_DT_CONFIGURATION,
  115. .conf.wTotalLength = LE16(sizeof(udc_desc_t)),
  116. .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE,
  117. .conf.bConfigurationValue = 1,
  118. .conf.iConfiguration = 0,
  119. .conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
  120. .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
  121. UDI_COMPOSITE_DESC_FS
  122. };
  123. #ifdef USB_DEVICE_HS_SUPPORT
  124. //! USB Device Configuration Descriptor filled for HS
  125. COMPILER_WORD_ALIGNED
  126. UDC_DESC_STORAGE udc_desc_t udc_desc_hs = {
  127. .conf.bLength = sizeof(usb_conf_desc_t),
  128. .conf.bDescriptorType = USB_DT_CONFIGURATION,
  129. .conf.wTotalLength = LE16(sizeof(udc_desc_t)),
  130. .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE,
  131. .conf.bConfigurationValue = 1,
  132. .conf.iConfiguration = 0,
  133. .conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
  134. .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
  135. UDI_COMPOSITE_DESC_HS
  136. };
  137. #endif
  138. /**
  139. * \name UDC structures which contains all USB Device definitions
  140. */
  141. //@{
  142. //! Associate an UDI for each USB interface
  143. UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = {
  144. UDI_COMPOSITE_API
  145. };
  146. //! Add UDI with USB Descriptors FS
  147. UDC_DESC_STORAGE udc_config_speed_t udc_config_lsfs[1] = {{
  148. .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_fs,
  149. .udi_apis = udi_apis,
  150. }};
  151. #ifdef USB_DEVICE_HS_SUPPORT
  152. //! Add UDI with USB Descriptors HS
  153. UDC_DESC_STORAGE udc_config_speed_t udc_config_hs[1] = {{
  154. .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_hs,
  155. .udi_apis = udi_apis,
  156. }};
  157. #endif
  158. //! Add all information about USB Device in global structure for UDC
  159. UDC_DESC_STORAGE udc_config_t udc_config = {
  160. .confdev_lsfs = &udc_device_desc,
  161. .conf_lsfs = udc_config_lsfs,
  162. #ifdef USB_DEVICE_HS_SUPPORT
  163. .confdev_hs = &udc_device_desc,
  164. .qualifier = &udc_device_qual,
  165. .conf_hs = udc_config_hs,
  166. #endif
  167. };
  168. //@}
  169. /**INDENT-ON**/
  170. //@}
  171. #endif // ARDUINO_ARCH_SAM
  172. #endif // SDSUPPORT