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.

conf_usb.h 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /**
  2. * \file
  3. *
  4. * \brief USB configuration file
  5. *
  6. * Copyright (c) 2011-2015 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. #ifndef _CONF_USB_H_
  47. #define _CONF_USB_H_
  48. #undef UNUSED /* To avoid a macro clash as macros.h already defines it */
  49. #include "../../../inc/MarlinConfigPre.h"
  50. #include "compiler.h"
  51. /**
  52. * USB Device Configuration
  53. * @{
  54. */
  55. //! Device definition (mandatory)
  56. #define USB_DEVICE_MAJOR_VERSION 1
  57. #define USB_DEVICE_MINOR_VERSION 0
  58. #define USB_DEVICE_POWER 100 // Consumption on Vbus line (mA)
  59. #define USB_DEVICE_ATTR \
  60. (USB_CONFIG_ATTR_SELF_POWERED)
  61. // (USB_CONFIG_ATTR_BUS_POWERED)
  62. // (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED)
  63. // (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
  64. /**
  65. * Device speeds support
  66. * Low speed not supported by CDC and MSC
  67. * @{
  68. */
  69. //! To define a Low speed device
  70. //#define USB_DEVICE_LOW_SPEED
  71. //! To define a Full speed device
  72. //#define USB_DEVICE_FULL_SPEED
  73. #if MB(ARCHIM1)
  74. #define USB_DEVICE_FULL_SPEED
  75. #endif
  76. //! To authorize the High speed
  77. #ifndef USB_DEVICE_FULL_SPEED
  78. #if (UC3A3||UC3A4)
  79. #define USB_DEVICE_HS_SUPPORT
  80. #elif (SAM3XA||SAM3U)
  81. #define USB_DEVICE_HS_SUPPORT
  82. #endif
  83. #endif
  84. //@}
  85. /**
  86. * USB Device Callbacks definitions (Optional)
  87. * @{
  88. */
  89. #define UDC_VBUS_EVENT(b_vbus_high)
  90. #define UDC_SOF_EVENT()
  91. #define UDC_SUSPEND_EVENT()
  92. #define UDC_RESUME_EVENT()
  93. #define UDC_GET_EXTRA_STRING() usb_task_extra_string()
  94. #define USB_DEVICE_SPECIFIC_REQUEST() usb_task_other_requests()
  95. //@}
  96. #if ENABLED(SDSUPPORT)
  97. /**
  98. * USB Device low level configuration
  99. * When only one interface is used, these configurations are defined by the class module.
  100. * For composite device, these configuration must be defined here
  101. * @{
  102. */
  103. //! Control endpoint size
  104. #define USB_DEVICE_EP_CTRL_SIZE 64
  105. //! Two interfaces for this device (CDC COM + CDC DATA + MSC)
  106. #define USB_DEVICE_NB_INTERFACE 3
  107. //! 5 endpoints used by CDC and MSC interfaces
  108. #if SAM3U
  109. // (3 | USB_EP_DIR_IN) // CDC Notify endpoint
  110. // (6 | USB_EP_DIR_IN) // CDC TX
  111. // (5 | USB_EP_DIR_OUT) // CDC RX
  112. // (1 | USB_EP_DIR_IN) // MSC IN
  113. // (2 | USB_EP_DIR_OUT) // MSC OUT
  114. # define USB_DEVICE_MAX_EP 6
  115. # if defined(USB_DEVICE_HS_SUPPORT)
  116. // In HS mode, size of bulk endpoints are 512
  117. // If CDC and MSC endpoints all uses 2 banks, DPRAM is not enough: 4 bulk
  118. // endpoints requires 4K bytes. So reduce the number of banks of CDC bulk
  119. // endpoints to use less DPRAM. Keep MSC setting to keep MSC performance.
  120. # define UDD_BULK_NB_BANK(ep) ((ep == 5 || ep== 6) ? 1 : 2)
  121. #endif
  122. #else
  123. // (3 | USB_EP_DIR_IN) // CDC Notify endpoint
  124. // (4 | USB_EP_DIR_IN) // CDC TX
  125. // (5 | USB_EP_DIR_OUT) // CDC RX
  126. // (1 | USB_EP_DIR_IN) // MSC IN
  127. // (2 | USB_EP_DIR_OUT) // MSC OUT
  128. # define USB_DEVICE_MAX_EP 5
  129. # if SAM3XA && defined(USB_DEVICE_HS_SUPPORT)
  130. // In HS mode, size of bulk endpoints are 512
  131. // If CDC and MSC endpoints all uses 2 banks, DPRAM is not enough: 4 bulk
  132. // endpoints requires 4K bytes. So reduce the number of banks of CDC bulk
  133. // endpoints to use less DPRAM. Keep MSC setting to keep MSC performance.
  134. # define UDD_BULK_NB_BANK(ep) ((ep == 4 || ep== 5) ? 1 : 2)
  135. # endif
  136. #endif
  137. #endif
  138. //@}
  139. //@}
  140. /**
  141. * USB Interface Configuration
  142. * @{
  143. */
  144. /**
  145. * Configuration of CDC interface
  146. * @{
  147. */
  148. //! Define one USB communication ports
  149. #define UDI_CDC_PORT_NB 1
  150. //! Interface callback definition
  151. #define UDI_CDC_ENABLE_EXT(port) usb_task_cdc_enable(port)
  152. #define UDI_CDC_DISABLE_EXT(port) usb_task_cdc_disable(port)
  153. #define UDI_CDC_RX_NOTIFY(port) usb_task_cdc_rx_notify(port)
  154. #define UDI_CDC_TX_EMPTY_NOTIFY(port)
  155. #define UDI_CDC_SET_CODING_EXT(port,cfg) usb_task_cdc_config(port,cfg)
  156. #define UDI_CDC_SET_DTR_EXT(port,set) usb_task_cdc_set_dtr(port,set)
  157. #define UDI_CDC_SET_RTS_EXT(port,set)
  158. //! Define it when the transfer CDC Device to Host is a low rate (<512000 bauds)
  159. //! to reduce CDC buffers size
  160. //#define UDI_CDC_LOW_RATE
  161. //! Default configuration of communication port
  162. #define UDI_CDC_DEFAULT_RATE 115200
  163. #define UDI_CDC_DEFAULT_STOPBITS CDC_STOP_BITS_1
  164. #define UDI_CDC_DEFAULT_PARITY CDC_PAR_NONE
  165. #define UDI_CDC_DEFAULT_DATABITS 8
  166. //! Enable id string of interface to add an extra USB string
  167. #define UDI_CDC_IAD_STRING_ID 4
  168. #if ENABLED(SDSUPPORT)
  169. /**
  170. * USB CDC low level configuration
  171. * In standalone these configurations are defined by the CDC module.
  172. * For composite device, these configuration must be defined here
  173. * @{
  174. */
  175. //! Endpoint numbers definition
  176. #if SAM3U
  177. # define UDI_CDC_COMM_EP_0 (3 | USB_EP_DIR_IN) // Notify endpoint
  178. # define UDI_CDC_DATA_EP_IN_0 (6 | USB_EP_DIR_IN) // TX
  179. # define UDI_CDC_DATA_EP_OUT_0 (5 | USB_EP_DIR_OUT)// RX
  180. #else
  181. # define UDI_CDC_COMM_EP_0 (3 | USB_EP_DIR_IN) // Notify endpoint
  182. # define UDI_CDC_DATA_EP_IN_0 (4 | USB_EP_DIR_IN) // TX
  183. # define UDI_CDC_DATA_EP_OUT_0 (5 | USB_EP_DIR_OUT)// RX
  184. #endif
  185. //! Interface numbers
  186. #define UDI_CDC_COMM_IFACE_NUMBER_0 0
  187. #define UDI_CDC_DATA_IFACE_NUMBER_0 1
  188. //@}
  189. //@}
  190. /**
  191. * Configuration of MSC interface
  192. * @{
  193. */
  194. //! Vendor name and Product version of MSC interface
  195. #define UDI_MSC_GLOBAL_VENDOR_ID \
  196. 'M', 'A', 'R', 'L', 'I', 'N', '3', 'D'
  197. #define UDI_MSC_GLOBAL_PRODUCT_VERSION \
  198. '1', '.', '0', '0'
  199. //! Interface callback definition
  200. #define UDI_MSC_ENABLE_EXT() usb_task_msc_enable()
  201. #define UDI_MSC_DISABLE_EXT() usb_task_msc_disable()
  202. //! Enable id string of interface to add an extra USB string
  203. #define UDI_MSC_STRING_ID 5
  204. /**
  205. * USB MSC low level configuration
  206. * In standalone these configurations are defined by the MSC module.
  207. * For composite device, these configuration must be defined here
  208. * @{
  209. */
  210. //! Endpoint numbers definition
  211. #define UDI_MSC_EP_IN (1 | USB_EP_DIR_IN)
  212. #define UDI_MSC_EP_OUT (2 | USB_EP_DIR_OUT)
  213. //! Interface number
  214. #define UDI_MSC_IFACE_NUMBER 2
  215. //@}
  216. //@}
  217. //@}
  218. /**
  219. * Description of Composite Device
  220. * @{
  221. */
  222. //! USB Interfaces descriptor structure
  223. #define UDI_COMPOSITE_DESC_T \
  224. usb_iad_desc_t udi_cdc_iad; \
  225. udi_cdc_comm_desc_t udi_cdc_comm; \
  226. udi_cdc_data_desc_t udi_cdc_data; \
  227. udi_msc_desc_t udi_msc
  228. //! USB Interfaces descriptor value for Full Speed
  229. #define UDI_COMPOSITE_DESC_FS \
  230. .udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
  231. .udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
  232. .udi_cdc_data = UDI_CDC_DATA_DESC_0_FS, \
  233. .udi_msc = UDI_MSC_DESC_FS
  234. //! USB Interfaces descriptor value for High Speed
  235. #define UDI_COMPOSITE_DESC_HS \
  236. .udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
  237. .udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
  238. .udi_cdc_data = UDI_CDC_DATA_DESC_0_HS, \
  239. .udi_msc = UDI_MSC_DESC_HS
  240. //! USB Interface APIs
  241. #define UDI_COMPOSITE_API \
  242. &udi_api_cdc_comm, \
  243. &udi_api_cdc_data, \
  244. &udi_api_msc
  245. //@}
  246. /**
  247. * USB Device Driver Configuration
  248. * @{
  249. */
  250. //@}
  251. //! The includes of classes and other headers must be done at the end of this file to avoid compile error
  252. #include "udi_cdc.h"
  253. #include "udi_msc.h"
  254. #else
  255. #include "udi_cdc_conf.h"
  256. #endif
  257. #include "usb_task.h"
  258. #endif // _CONF_USB_H_