cherryusb_config_template.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * Copyright (c) 2022, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef CHERRYUSB_CONFIG_H
  7. #define CHERRYUSB_CONFIG_H
  8. /* ================ USB common Configuration ================ */
  9. #define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
  10. #ifndef CONFIG_USB_DBG_LEVEL
  11. #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
  12. #endif
  13. /* Enable print with color */
  14. #define CONFIG_USB_PRINTF_COLOR_ENABLE
  15. /* data align size when use dma */
  16. #ifndef CONFIG_USB_ALIGN_SIZE
  17. #define CONFIG_USB_ALIGN_SIZE 4
  18. #endif
  19. /* attribute data into no cache ram */
  20. #define USB_NOCACHE_RAM_SECTION __attribute__((section(".noncacheable")))
  21. /* ================= USB Device Stack Configuration ================ */
  22. /* Ep0 in and out transfer buffer */
  23. #ifndef CONFIG_USBDEV_REQUEST_BUFFER_LEN
  24. #define CONFIG_USBDEV_REQUEST_BUFFER_LEN 512
  25. #endif
  26. /* Setup packet log for debug */
  27. // #define CONFIG_USBDEV_SETUP_LOG_PRINT
  28. /* Send ep0 in data from user buffer instead of copying into ep0 reqdata
  29. * Please note that user buffer must be aligned with CONFIG_USB_ALIGN_SIZE
  30. */
  31. // #define CONFIG_USBDEV_EP0_INDATA_NO_COPY
  32. /* Check if the input descriptor is correct */
  33. // #define CONFIG_USBDEV_DESC_CHECK
  34. /* Enable test mode */
  35. // #define CONFIG_USBDEV_TEST_MODE
  36. #ifndef CONFIG_USBDEV_MSC_MAX_LUN
  37. #define CONFIG_USBDEV_MSC_MAX_LUN 1
  38. #endif
  39. #ifndef CONFIG_USBDEV_MSC_MAX_BUFSIZE
  40. #define CONFIG_USBDEV_MSC_MAX_BUFSIZE 512
  41. #endif
  42. #ifndef CONFIG_USBDEV_MSC_MANUFACTURER_STRING
  43. #define CONFIG_USBDEV_MSC_MANUFACTURER_STRING ""
  44. #endif
  45. #ifndef CONFIG_USBDEV_MSC_PRODUCT_STRING
  46. #define CONFIG_USBDEV_MSC_PRODUCT_STRING ""
  47. #endif
  48. #ifndef CONFIG_USBDEV_MSC_VERSION_STRING
  49. #define CONFIG_USBDEV_MSC_VERSION_STRING "0.01"
  50. #endif
  51. /* move msc read & write from isr to while(1), you should call usbd_msc_polling in while(1) */
  52. // #define CONFIG_USBDEV_MSC_POLLING
  53. /* move msc read & write from isr to thread */
  54. // #define CONFIG_USBDEV_MSC_THREAD
  55. #ifndef CONFIG_USBDEV_MSC_PRIO
  56. #define CONFIG_USBDEV_MSC_PRIO 4
  57. #endif
  58. #ifndef CONFIG_USBDEV_MSC_STACKSIZE
  59. #define CONFIG_USBDEV_MSC_STACKSIZE 2048
  60. #endif
  61. #ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE
  62. #define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156
  63. #endif
  64. /* rndis transfer buffer size, must be a multiple of (1536 + 44)*/
  65. #ifndef CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE
  66. #define CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 1580
  67. #endif
  68. #ifndef CONFIG_USBDEV_RNDIS_VENDOR_ID
  69. #define CONFIG_USBDEV_RNDIS_VENDOR_ID 0x0000ffff
  70. #endif
  71. #ifndef CONFIG_USBDEV_RNDIS_VENDOR_DESC
  72. #define CONFIG_USBDEV_RNDIS_VENDOR_DESC "CherryUSB"
  73. #endif
  74. #define CONFIG_USBDEV_RNDIS_USING_LWIP
  75. /* ================ USB HOST Stack Configuration ================== */
  76. #define CONFIG_USBHOST_MAX_RHPORTS 1
  77. #define CONFIG_USBHOST_MAX_EXTHUBS 1
  78. #define CONFIG_USBHOST_MAX_EHPORTS 4
  79. #define CONFIG_USBHOST_MAX_INTERFACES 8
  80. #define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 8
  81. #define CONFIG_USBHOST_MAX_ENDPOINTS 4
  82. #define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
  83. #define CONFIG_USBHOST_MAX_HID_CLASS 4
  84. #define CONFIG_USBHOST_MAX_MSC_CLASS 2
  85. #define CONFIG_USBHOST_MAX_AUDIO_CLASS 1
  86. #define CONFIG_USBHOST_MAX_VIDEO_CLASS 1
  87. #define CONFIG_USBHOST_DEV_NAMELEN 16
  88. #ifndef CONFIG_USBHOST_PSC_PRIO
  89. #define CONFIG_USBHOST_PSC_PRIO 0
  90. #endif
  91. #ifndef CONFIG_USBHOST_PSC_STACKSIZE
  92. #define CONFIG_USBHOST_PSC_STACKSIZE 2048
  93. #endif
  94. //#define CONFIG_USBHOST_GET_STRING_DESC
  95. // #define CONFIG_USBHOST_MSOS_ENABLE
  96. #ifndef CONFIG_USBHOST_MSOS_VENDOR_CODE
  97. #define CONFIG_USBHOST_MSOS_VENDOR_CODE 0x00
  98. #endif
  99. /* Ep0 max transfer buffer */
  100. #ifndef CONFIG_USBHOST_REQUEST_BUFFER_LEN
  101. #define CONFIG_USBHOST_REQUEST_BUFFER_LEN 512
  102. #endif
  103. #ifndef CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT
  104. #define CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 500
  105. #endif
  106. #ifndef CONFIG_USBHOST_MSC_TIMEOUT
  107. #define CONFIG_USBHOST_MSC_TIMEOUT 5000
  108. #endif
  109. /* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
  110. * you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
  111. */
  112. #ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE
  113. #define CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE (2048)
  114. #endif
  115. /* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
  116. #ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE
  117. #define CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE (2048)
  118. #endif
  119. /* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
  120. * you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
  121. */
  122. #ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE
  123. #define CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE (2048)
  124. #endif
  125. /* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
  126. #ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE
  127. #define CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE (2048)
  128. #endif
  129. /* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
  130. * you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
  131. */
  132. #ifndef CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE
  133. #define CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE (2048)
  134. #endif
  135. /* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
  136. #ifndef CONFIG_USBHOST_ASIX_ETH_MAX_TX_SIZE
  137. #define CONFIG_USBHOST_ASIX_ETH_MAX_TX_SIZE (2048)
  138. #endif
  139. /* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
  140. * you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
  141. */
  142. #ifndef CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE
  143. #define CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE (2048)
  144. #endif
  145. /* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
  146. #ifndef CONFIG_USBHOST_RTL8152_ETH_MAX_TX_SIZE
  147. #define CONFIG_USBHOST_RTL8152_ETH_MAX_TX_SIZE (2048)
  148. #endif
  149. #define CONFIG_USBHOST_BLUETOOTH_HCI_H4
  150. // #define CONFIG_USBHOST_BLUETOOTH_HCI_LOG
  151. #ifndef CONFIG_USBHOST_BLUETOOTH_TX_SIZE
  152. #define CONFIG_USBHOST_BLUETOOTH_TX_SIZE 2048
  153. #endif
  154. #ifndef CONFIG_USBHOST_BLUETOOTH_RX_SIZE
  155. #define CONFIG_USBHOST_BLUETOOTH_RX_SIZE 2048
  156. #endif
  157. /* ================ USB Device Port Configuration ================*/
  158. #ifndef CONFIG_USBDEV_MAX_BUS
  159. #define CONFIG_USBDEV_MAX_BUS 1 // for now, bus num must be 1 except hpm ip
  160. #endif
  161. #ifndef CONFIG_USBDEV_EP_NUM
  162. #define CONFIG_USBDEV_EP_NUM 8
  163. #endif
  164. /* ---------------- FSDEV Configuration ---------------- */
  165. //#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2 // maybe 1 or 2, many chips may have a difference
  166. /* ---------------- DWC2 Configuration ---------------- */
  167. /* (5 * number of control endpoints + 8) + ((largest USB packet used / 4) + 1 for
  168. * status information) + (2 * number of OUT endpoints) + 1 for Global NAK
  169. */
  170. // #define CONFIG_USB_DWC2_RXALL_FIFO_SIZE (1024 / 4)
  171. /* IN Endpoints Max packet Size / 4 */
  172. // #define CONFIG_USB_DWC2_TX0_FIFO_SIZE (64 / 4)
  173. // #define CONFIG_USB_DWC2_TX1_FIFO_SIZE (512 / 4)
  174. // #define CONFIG_USB_DWC2_TX2_FIFO_SIZE (64 / 4)
  175. // #define CONFIG_USB_DWC2_TX3_FIFO_SIZE (64 / 4)
  176. // #define CONFIG_USB_DWC2_TX4_FIFO_SIZE (0 / 4)
  177. // #define CONFIG_USB_DWC2_TX5_FIFO_SIZE (0 / 4)
  178. // #define CONFIG_USB_DWC2_TX6_FIFO_SIZE (0 / 4)
  179. // #define CONFIG_USB_DWC2_TX7_FIFO_SIZE (0 / 4)
  180. // #define CONFIG_USB_DWC2_TX8_FIFO_SIZE (0 / 4)
  181. /* ---------------- MUSB Configuration ---------------- */
  182. // #define CONFIG_USB_MUSB_SUNXI
  183. /* ================ USB Host Port Configuration ==================*/
  184. #ifndef CONFIG_USBHOST_MAX_BUS
  185. #define CONFIG_USBHOST_MAX_BUS 1
  186. #endif
  187. #ifndef CONFIG_USBHOST_PIPE_NUM
  188. #define CONFIG_USBHOST_PIPE_NUM 10
  189. #endif
  190. /* ---------------- EHCI Configuration ---------------- */
  191. #define CONFIG_USB_EHCI_HCCR_OFFSET (0x0)
  192. #define CONFIG_USB_EHCI_FRAME_LIST_SIZE 1024
  193. #define CONFIG_USB_EHCI_QH_NUM CONFIG_USBHOST_PIPE_NUM
  194. #define CONFIG_USB_EHCI_QTD_NUM 3
  195. #define CONFIG_USB_EHCI_ITD_NUM 20
  196. // #define CONFIG_USB_EHCI_HCOR_RESERVED_DISABLE
  197. // #define CONFIG_USB_EHCI_CONFIGFLAG
  198. // #define CONFIG_USB_EHCI_ISO
  199. // #define CONFIG_USB_EHCI_WITH_OHCI
  200. /* ---------------- OHCI Configuration ---------------- */
  201. #define CONFIG_USB_OHCI_HCOR_OFFSET (0x0)
  202. /* ---------------- XHCI Configuration ---------------- */
  203. #define CONFIG_USB_XHCI_HCCR_OFFSET (0x0)
  204. /* ---------------- DWC2 Configuration ---------------- */
  205. /* largest non-periodic USB packet used / 4 */
  206. // #define CONFIG_USB_DWC2_NPTX_FIFO_SIZE (512 / 4)
  207. /* largest periodic USB packet used / 4 */
  208. // #define CONFIG_USB_DWC2_PTX_FIFO_SIZE (1024 / 4)
  209. /*
  210. * (largest USB packet used / 4) + 1 for status information + 1 transfer complete +
  211. * 1 location each for Bulk/Control endpoint for handling NAK/NYET scenario
  212. */
  213. // #define CONFIG_USB_DWC2_RX_FIFO_SIZE ((1012 - CONFIG_USB_DWC2_NPTX_FIFO_SIZE - CONFIG_USB_DWC2_PTX_FIFO_SIZE) / 4)
  214. /* ---------------- MUSB Configuration ---------------- */
  215. // #define CONFIG_USB_MUSB_SUNXI
  216. #endif