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.8KB

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