cherryusb_config_template.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 0x001001
  9. /* ================ USB common Configuration ================ */
  10. #define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
  11. #define usb_malloc(size) malloc(size)
  12. #define usb_free(ptr) free(ptr)
  13. #ifndef CONFIG_USB_DBG_LEVEL
  14. #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
  15. #endif
  16. /* Enable print with color */
  17. #define CONFIG_USB_PRINTF_COLOR_ENABLE
  18. /* data align size when use dma */
  19. #ifndef CONFIG_USB_ALIGN_SIZE
  20. #define CONFIG_USB_ALIGN_SIZE 4
  21. #endif
  22. /* attribute data into no cache ram */
  23. #define USB_NOCACHE_RAM_SECTION __attribute__((section(".noncacheable")))
  24. /* ================= USB Device Stack Configuration ================ */
  25. /* Ep0 max transfer buffer, specially for receiving data from ep0 out */
  26. #define CONFIG_USBDEV_REQUEST_BUFFER_LEN 256
  27. /* Setup packet log for debug */
  28. // #define CONFIG_USBDEV_SETUP_LOG_PRINT
  29. /* Check if the input descriptor is correct */
  30. // #define CONFIG_USBDEV_DESC_CHECK
  31. /* Enable test mode */
  32. // #define CONFIG_USBDEV_TEST_MODE
  33. #ifndef CONFIG_USBDEV_MSC_BLOCK_SIZE
  34. #define CONFIG_USBDEV_MSC_BLOCK_SIZE 512
  35. #endif
  36. #ifndef CONFIG_USBDEV_MSC_MANUFACTURER_STRING
  37. #define CONFIG_USBDEV_MSC_MANUFACTURER_STRING ""
  38. #endif
  39. #ifndef CONFIG_USBDEV_MSC_PRODUCT_STRING
  40. #define CONFIG_USBDEV_MSC_PRODUCT_STRING ""
  41. #endif
  42. #ifndef CONFIG_USBDEV_MSC_VERSION_STRING
  43. #define CONFIG_USBDEV_MSC_VERSION_STRING "0.01"
  44. #endif
  45. // #define CONFIG_USBDEV_MSC_THREAD
  46. #ifndef CONFIG_USBDEV_MSC_PRIO
  47. #define CONFIG_USBDEV_MSC_PRIO 4
  48. #endif
  49. #ifndef CONFIG_USBDEV_MSC_STACKSIZE
  50. #define CONFIG_USBDEV_MSC_STACKSIZE 2048
  51. #endif
  52. #ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE
  53. #define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156
  54. #endif
  55. #ifndef CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE
  56. #define CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 1536
  57. #endif
  58. #ifndef CONFIG_USBDEV_RNDIS_VENDOR_ID
  59. #define CONFIG_USBDEV_RNDIS_VENDOR_ID 0x0000ffff
  60. #endif
  61. #ifndef CONFIG_USBDEV_RNDIS_VENDOR_DESC
  62. #define CONFIG_USBDEV_RNDIS_VENDOR_DESC "CherryUSB"
  63. #endif
  64. #define CONFIG_USBDEV_RNDIS_USING_LWIP
  65. /* ================ USB HOST Stack Configuration ================== */
  66. #define CONFIG_USBHOST_MAX_RHPORTS 1
  67. #define CONFIG_USBHOST_MAX_EXTHUBS 1
  68. #define CONFIG_USBHOST_MAX_EHPORTS 4
  69. #define CONFIG_USBHOST_MAX_INTERFACES 6
  70. #define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 1
  71. #define CONFIG_USBHOST_MAX_ENDPOINTS 4
  72. #define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
  73. #define CONFIG_USBHOST_MAX_HID_CLASS 4
  74. #define CONFIG_USBHOST_MAX_MSC_CLASS 2
  75. #define CONFIG_USBHOST_MAX_AUDIO_CLASS 1
  76. #define CONFIG_USBHOST_MAX_VIDEO_CLASS 1
  77. #define CONFIG_USBHOST_MAX_RNDIS_CLASS 1
  78. #define CONFIG_USBHOST_DEV_NAMELEN 16
  79. #ifndef CONFIG_USBHOST_PSC_PRIO
  80. #define CONFIG_USBHOST_PSC_PRIO 4
  81. #endif
  82. #ifndef CONFIG_USBHOST_PSC_STACKSIZE
  83. #define CONFIG_USBHOST_PSC_STACKSIZE 2048
  84. #endif
  85. //#define CONFIG_USBHOST_GET_STRING_DESC
  86. /* Ep0 max transfer buffer */
  87. #define CONFIG_USBHOST_REQUEST_BUFFER_LEN 512
  88. #ifndef CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT
  89. #define CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 500
  90. #endif
  91. #ifndef CONFIG_USBHOST_MSC_TIMEOUT
  92. #define CONFIG_USBHOST_MSC_TIMEOUT 5000
  93. #endif
  94. /* ================ USB Device Port Configuration ================*/
  95. //#define USBD_IRQHandler USBD_IRQHandler
  96. //#define USB_BASE (0x40080000UL)
  97. //#define USB_NUM_BIDIR_ENDPOINTS 4
  98. /* ================ USB Host Port Configuration ==================*/
  99. #define CONFIG_USBHOST_PIPE_NUM 10
  100. /* ================ EHCI Configuration ================ */
  101. #define CONFIG_USB_EHCI_HCCR_BASE (0x20072000)
  102. #define CONFIG_USB_EHCI_HCOR_BASE (0x20072000 + 0x10)
  103. #define CONFIG_USB_EHCI_FRAME_LIST_SIZE 1024
  104. // #define CONFIG_USB_EHCI_INFO_ENABLE
  105. // #define CONFIG_USB_EHCI_HCOR_RESERVED_DISABLE
  106. // #define CONFIG_USB_EHCI_CONFIGFLAG
  107. // #define CONFIG_USB_EHCI_PORT_POWER
  108. #endif