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

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