usb_config.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-02-28 leo first version
  9. */
  10. #ifndef __USB_CONFIG_H__
  11. #define __USB_CONFIG_H__
  12. #include <rtthread.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #if defined BSP_USING_DEVICE_USBFS1 || defined BSP_USING_DEVICE_USBFS2
  17. #define USE_OTG_DEVICE_MODE
  18. #endif
  19. #if defined BSP_USING_HOST_USBFS1 || defined BSP_USING_HOST_USBFS2
  20. #define USE_OTG_HOST_MODE
  21. #endif
  22. /* usbfs irqhandler */
  23. #define OTGFS1_IRQHandler OTGFS1_IRQHandler
  24. #define OTGFS2_IRQHandler OTGFS2_IRQHandler
  25. /**
  26. * @brief usb device mode config
  27. */
  28. #define USB_EPT_MAX_NUM 8
  29. /* otg1 device fifo */
  30. #define USBD_RX_SIZE 128
  31. #define USBD_EP0_TX_SIZE 24
  32. #define USBD_EP1_TX_SIZE 20
  33. #define USBD_EP2_TX_SIZE 20
  34. #define USBD_EP3_TX_SIZE 20
  35. #define USBD_EP4_TX_SIZE 20
  36. #define USBD_EP5_TX_SIZE 20
  37. #define USBD_EP6_TX_SIZE 20
  38. #define USBD_EP7_TX_SIZE 20
  39. /* otg2 device fifo */
  40. #define USBD2_RX_SIZE 128
  41. #define USBD2_EP0_TX_SIZE 24
  42. #define USBD2_EP1_TX_SIZE 20
  43. #define USBD2_EP2_TX_SIZE 20
  44. #define USBD2_EP3_TX_SIZE 20
  45. #define USBD2_EP4_TX_SIZE 20
  46. #define USBD2_EP5_TX_SIZE 20
  47. #define USBD2_EP6_TX_SIZE 20
  48. #define USBD2_EP7_TX_SIZE 20
  49. /**
  50. * @brief usb host mode config
  51. */
  52. #define USB_HOST_CHANNEL_NUM 16
  53. /* otg1 host fifo */
  54. #define USBH_RX_FIFO_SIZE 128
  55. #define USBH_NP_TX_FIFO_SIZE 96
  56. #define USBH_P_TX_FIFO_SIZE 96
  57. /* otg2 host fifo */
  58. #define USBH2_RX_FIFO_SIZE 128
  59. #define USBH2_NP_TX_FIFO_SIZE 96
  60. #define USBH2_P_TX_FIFO_SIZE 96
  61. /**
  62. * @brief usb sof output enable
  63. */
  64. // #define USB_SOF_OUTPUT_ENABLE
  65. /**
  66. * @brief usb vbus ignore, not use vbus pin
  67. */
  68. #define USB_VBUS_IGNORE
  69. /**
  70. * @brief usb low power wakeup handler enable
  71. */
  72. // #define USB_LOW_POWER_WAKUP
  73. #if defined(BSP_USING_HOST_USBFS1)
  74. #undef BSP_USING_HOST_USBFS2
  75. #undef BSP_USING_DEVICE_USBFS1
  76. #define USBFS1_CONFIG \
  77. { \
  78. .name = "usbh1", \
  79. .id = USB_OTG1_ID, \
  80. .irqn = OTGFS1_IRQn, \
  81. }
  82. #endif /* BSP_USING_HOST_USBFS1 */
  83. #if defined(BSP_USING_DEVICE_USBFS1)
  84. #undef BSP_USING_DEVICE_USBFS2
  85. #define USBFS1_CONFIG \
  86. { \
  87. .name = "usbd", \
  88. .id = USB_OTG1_ID, \
  89. .irqn = OTGFS1_IRQn, \
  90. }
  91. #endif /* BSP_USING_DEVICE_USBFS1 */
  92. #if defined(BSP_USING_HOST_USBFS2)
  93. #undef BSP_USING_HOST_USBFS1
  94. #undef BSP_USING_DEVICE_USBFS2
  95. #define USBFS2_CONFIG \
  96. { \
  97. .name = "usbh2", \
  98. .id = USB_OTG2_ID, \
  99. .irqn = OTGFS2_IRQn, \
  100. }
  101. #endif /* BSP_USING_HOST_USBFS2 */
  102. #if defined(BSP_USING_DEVICE_USBFS2)
  103. #undef BSP_USING_DEVICE_USBFS1
  104. #define USBFS2_CONFIG \
  105. { \
  106. .name = "usbd", \
  107. .id = USB_OTG2_ID, \
  108. .irqn = OTGFS2_IRQn, \
  109. }
  110. #endif /* BSP_USING_DEVICE_USBFS2 */
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif