cherryusb_config_template.h 8.8 KB

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