usb_config.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. #include <rtthread.h>
  9. #define CHERRYUSB_VERSION 0x001002
  10. /* ================ USB common Configuration ================ */
  11. #define CONFIG_USB_PRINTF(...) rt_kprintf(__VA_ARGS__)
  12. #define usb_malloc(size) rt_malloc(size)
  13. #define usb_free(ptr) rt_free(ptr)
  14. #define usb_align(align, size) rt_malloc_align(size, align)
  15. #ifndef CONFIG_USB_DBG_LEVEL
  16. #define CONFIG_USB_DBG_LEVEL USB_DBG_ERROR
  17. #endif
  18. /* Enable print with color */
  19. #define CONFIG_USB_PRINTF_COLOR_ENABLE
  20. /* data align size when use dma */
  21. #ifndef CONFIG_USB_ALIGN_SIZE
  22. #define CONFIG_USB_ALIGN_SIZE 4
  23. #endif
  24. /* attribute data into no cache ram */
  25. #define USB_NOCACHE_RAM_SECTION __attribute__((section(".noncacheable")))
  26. /* ================= USB Device Stack Configuration ================ */
  27. /* Ep0 max transfer buffer, specially for receiving data from ep0 out */
  28. #define CONFIG_USBDEV_REQUEST_BUFFER_LEN 512
  29. /* Setup packet log for debug */
  30. #define CONFIG_USBDEV_SETUP_LOG_PRINT
  31. /* Check if the input descriptor is correct */
  32. #define CONFIG_USBDEV_DESC_CHECK
  33. #ifndef CONFIG_USB_ERROR_USE_SYSTEM
  34. #define CONFIG_USB_ERROR_USE_SYSTEM
  35. #endif
  36. /* Enable test mode */
  37. // #define CONFIG_USBDEV_TEST_MODE
  38. #ifndef CONFIG_USBDEV_MSC_BLOCK_SIZE
  39. #define CONFIG_USBDEV_MSC_BLOCK_SIZE 512
  40. #endif
  41. #ifndef CONFIG_USBDEV_MSC_MANUFACTURER_STRING
  42. #define CONFIG_USBDEV_MSC_MANUFACTURER_STRING ""
  43. #endif
  44. #ifndef CONFIG_USBDEV_MSC_PRODUCT_STRING
  45. #define CONFIG_USBDEV_MSC_PRODUCT_STRING ""
  46. #endif
  47. #ifndef CONFIG_USBDEV_MSC_VERSION_STRING
  48. #define CONFIG_USBDEV_MSC_VERSION_STRING "0.01"
  49. #endif
  50. #define CONFIG_USBDEV_MSC_THREAD
  51. #ifndef CONFIG_USBDEV_MSC_PRIO
  52. #define CONFIG_USBDEV_MSC_PRIO 4
  53. #endif
  54. #ifndef CONFIG_USBDEV_MSC_STACKSIZE
  55. #define CONFIG_USBDEV_MSC_STACKSIZE 8192
  56. #endif
  57. #ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE
  58. #define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156
  59. #endif
  60. #ifndef CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE
  61. #define CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 1536
  62. #endif
  63. #ifndef CONFIG_USBDEV_RNDIS_VENDOR_ID
  64. #define CONFIG_USBDEV_RNDIS_VENDOR_ID 0x0000ffff
  65. #endif
  66. #ifndef CONFIG_USBDEV_RNDIS_VENDOR_DESC
  67. #define CONFIG_USBDEV_RNDIS_VENDOR_DESC "CherryUSB"
  68. #endif
  69. #define CONFIG_USBDEV_RNDIS_USING_LWIP
  70. /* ================ USB HOST Stack Configuration ================== */
  71. #define CONFIG_USBHOST_MAX_RHPORTS 1
  72. #define CONFIG_USBHOST_MAX_EXTHUBS 1
  73. #define CONFIG_USBHOST_MAX_EHPORTS 4
  74. #define CONFIG_USBHOST_MAX_INTERFACES 6
  75. #define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 1
  76. #define CONFIG_USBHOST_MAX_ENDPOINTS 4
  77. #define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
  78. #define CONFIG_USBHOST_MAX_HID_CLASS 4
  79. #define CONFIG_USBHOST_MAX_MSC_CLASS 2
  80. #define CONFIG_USBHOST_MAX_AUDIO_CLASS 1
  81. #define CONFIG_USBHOST_MAX_VIDEO_CLASS 1
  82. #define CONFIG_USBHOST_DEV_NAMELEN 16
  83. #ifndef CONFIG_USBHOST_PSC_PRIO
  84. #define CONFIG_USBHOST_PSC_PRIO 4
  85. #endif
  86. #ifndef CONFIG_USBHOST_PSC_STACKSIZE
  87. #define CONFIG_USBHOST_PSC_STACKSIZE 81920
  88. #endif
  89. // #define CONFIG_USBHOST_GET_STRING_DESC
  90. // #define CONFIG_USBHOST_MSOS_ENABLE
  91. #define CONFIG_USBHOST_MSOS_VENDOR_CODE 0x00
  92. /* Ep0 max transfer buffer */
  93. #define CONFIG_USBHOST_REQUEST_BUFFER_LEN 512
  94. #ifndef CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT
  95. #define CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 500
  96. #endif
  97. #ifndef CONFIG_USBHOST_MSC_TIMEOUT
  98. #define CONFIG_USBHOST_MSC_TIMEOUT 5000
  99. #endif
  100. /* ================ USB Device Port Configuration ================*/
  101. /* ================ USB Host Port Configuration ==================*/
  102. #define CONFIG_USBHOST_PIPE_NUM 10
  103. /* ================ XHCI Configuration ================ */
  104. #if defined(PKG_CHERRYUSB_HOST_XHCI)
  105. #define CONFIG_USBHOST_XHCI
  106. #define CONFIG_USBHOST_XHCI_ID 0U
  107. #endif
  108. /* ================ PUSB2 Configuration ================ */
  109. #if defined(PKG_CHERRYUSB_HOST_PUSB2) || defined(PKG_CHERRYUSB_DEVICE_PUSB2)
  110. #define CONFIG_USBDEV_PUSB2_CTRL_ID 0U
  111. #define CONFIG_USBDEV_PUSB2_CTRL_NUM 1U
  112. #endif
  113. #endif