dcd_attr.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2021, Ha Thach (tinyusb.org)
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. *
  24. * This file is part of the TinyUSB stack.
  25. */
  26. #ifndef TUSB_DCD_ATTR_H_
  27. #define TUSB_DCD_ATTR_H_
  28. #include "tusb_option.h"
  29. // Attribute includes
  30. // - ENDPOINT_MAX: max (logical) number of endpoint
  31. // - ENDPOINT_EXCLUSIVE_NUMBER: endpoint number with different direction IN and OUT aren't allowed,
  32. // e.g EP1 OUT & EP1 IN cannot exist together
  33. // - PORT_HIGHSPEED: mask to indicate which port support highspeed mode, bit0 for port0 and so on.
  34. //------------- NXP -------------//
  35. #if TU_CHECK_MCU(OPT_MCU_LPC11UXX, OPT_MCU_LPC13XX, OPT_MCU_LPC15XX)
  36. #define DCD_ATTR_ENDPOINT_MAX 5
  37. #elif TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
  38. #define DCD_ATTR_ENDPOINT_MAX 16
  39. #elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
  40. // TODO USB0 has 6, USB1 has 4
  41. #define DCD_ATTR_CONTROLLER_CHIPIDEA_HS
  42. #define DCD_ATTR_ENDPOINT_MAX 6
  43. #elif TU_CHECK_MCU(OPT_MCU_LPC51UXX)
  44. #define DCD_ATTR_ENDPOINT_MAX 5
  45. #elif TU_CHECK_MCU(OPT_MCU_LPC54XXX)
  46. // TODO USB0 has 5, USB1 has 6
  47. #define DCD_ATTR_ENDPOINT_MAX 6
  48. #elif TU_CHECK_MCU(OPT_MCU_LPC55XX)
  49. // TODO USB0 has 5, USB1 has 6
  50. #define DCD_ATTR_ENDPOINT_MAX 6
  51. #elif TU_CHECK_MCU(OPT_MCU_MIMXRT10XX)
  52. #define DCD_ATTR_CONTROLLER_CHIPIDEA_HS
  53. #define DCD_ATTR_ENDPOINT_MAX 8
  54. #elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2BXX)
  55. #define DCD_ATTR_ENDPOINT_MAX 16
  56. #elif TU_CHECK_MCU(OPT_MCU_MM32F327X)
  57. #define DCD_ATTR_ENDPOINT_MAX 16
  58. //------------- Nordic -------------//
  59. #elif TU_CHECK_MCU(OPT_MCU_NRF5X)
  60. // 8 CBI + 1 ISO
  61. #define DCD_ATTR_ENDPOINT_MAX 9
  62. //------------- Microchip -------------//
  63. #elif TU_CHECK_MCU(OPT_MCU_SAMD21, OPT_MCU_SAMD51, OPT_MCU_SAME5X) || \
  64. TU_CHECK_MCU(OPT_MCU_SAMD11, OPT_MCU_SAML21, OPT_MCU_SAML22)
  65. #define DCD_ATTR_ENDPOINT_MAX 8
  66. #elif TU_CHECK_MCU(OPT_MCU_SAMG)
  67. #define DCD_ATTR_ENDPOINT_MAX 6
  68. #define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER
  69. #elif TU_CHECK_MCU(OPT_MCU_SAMX7X)
  70. #define DCD_ATTR_ENDPOINT_MAX 10
  71. #define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER
  72. //------------- ST -------------//
  73. #elif TU_CHECK_MCU(OPT_MCU_STM32F0)
  74. #define DCD_ATTR_ENDPOINT_MAX 8
  75. #elif TU_CHECK_MCU(OPT_MCU_STM32F1)
  76. #if defined (STM32F105x8) || defined (STM32F105xB) || defined (STM32F105xC) || \
  77. defined (STM32F107xB) || defined (STM32F107xC)
  78. #define DCD_ATTR_ENDPOINT_MAX 4
  79. #define DCD_ATTR_DWC2_STM32
  80. #else
  81. #define DCD_ATTR_ENDPOINT_MAX 8
  82. #endif
  83. #elif TU_CHECK_MCU(OPT_MCU_STM32F2)
  84. // FS has 4 ep, HS has 5 ep
  85. #define DCD_ATTR_ENDPOINT_MAX 6
  86. #define DCD_ATTR_DWC2_STM32
  87. #elif TU_CHECK_MCU(OPT_MCU_STM32F3)
  88. #define DCD_ATTR_ENDPOINT_MAX 8
  89. #elif TU_CHECK_MCU(OPT_MCU_STM32F4)
  90. // For most mcu, FS has 4, HS has 6. TODO 446/469/479 HS has 9
  91. #define DCD_ATTR_ENDPOINT_MAX 6
  92. #define DCD_ATTR_DWC2_STM32
  93. #elif TU_CHECK_MCU(OPT_MCU_STM32F7)
  94. // FS has 6, HS has 9
  95. #define DCD_ATTR_ENDPOINT_MAX 9
  96. #define DCD_ATTR_DWC2_STM32
  97. #elif TU_CHECK_MCU(OPT_MCU_STM32H7)
  98. #define DCD_ATTR_ENDPOINT_MAX 9
  99. #define DCD_ATTR_DWC2_STM32
  100. #elif TU_CHECK_MCU(OPT_MCU_STM32G4)
  101. #define DCD_ATTR_ENDPOINT_MAX 8
  102. #elif TU_CHECK_MCU(OPT_MCU_STM32L0, OPT_MCU_STM32L1)
  103. #define DCD_ATTR_ENDPOINT_MAX 8
  104. #elif TU_CHECK_MCU(OPT_MCU_STM32L4)
  105. #if defined (STM32L475xx) || defined (STM32L476xx) || \
  106. defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || \
  107. defined (STM32L4A6xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) || \
  108. defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || \
  109. defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
  110. #define DCD_ATTR_ENDPOINT_MAX 6
  111. #define DCD_ATTR_DWC2_STM32
  112. #else
  113. #define DCD_ATTR_ENDPOINT_MAX 8
  114. #endif
  115. //------------- Sony -------------//
  116. #elif TU_CHECK_MCU(OPT_MCU_CXD56)
  117. #define DCD_ATTR_ENDPOINT_MAX 7
  118. #define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER
  119. //------------- TI -------------//
  120. #elif TU_CHECK_MCU(OPT_MCU_MSP430x5xx)
  121. #define DCD_ATTR_ENDPOINT_MAX 8
  122. #elif TU_CHECK_MCU(OPT_MCU_MSP432E4, OPT_MCU_TM4C123, OPT_MCU_TM4C129)
  123. #define DCD_ATTR_ENDPOINT_MAX 8
  124. //------------- ValentyUSB -------------//
  125. #elif TU_CHECK_MCU(OPT_MCU_VALENTYUSB_EPTRI)
  126. #define DCD_ATTR_ENDPOINT_MAX 16
  127. //------------- Nuvoton -------------//
  128. #elif TU_CHECK_MCU(OPT_MCU_NUC121, OPT_MCU_NUC126)
  129. #define DCD_ATTR_ENDPOINT_MAX 8
  130. #elif TU_CHECK_MCU(OPT_MCU_NUC120)
  131. #define DCD_ATTR_ENDPOINT_MAX 6
  132. #elif TU_CHECK_MCU(OPT_MCU_NUC505)
  133. #define DCD_ATTR_ENDPOINT_MAX 12
  134. //------------- Espressif -------------//
  135. #elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
  136. #define DCD_ATTR_ENDPOINT_MAX 6
  137. //------------- Dialog -------------//
  138. #elif TU_CHECK_MCU(OPT_MCU_DA1469X)
  139. #define DCD_ATTR_ENDPOINT_MAX 4
  140. //------------- Raspberry Pi -------------//
  141. #elif TU_CHECK_MCU(OPT_MCU_RP2040)
  142. #define DCD_ATTR_ENDPOINT_MAX 16
  143. //------------- Silabs -------------//
  144. #elif TU_CHECK_MCU(OPT_MCU_EFM32GG)
  145. #define DCD_ATTR_ENDPOINT_MAX 7
  146. //------------- Renesas -------------//
  147. #elif TU_CHECK_MCU(OPT_MCU_RX63X, OPT_MCU_RX65X, OPT_MCU_RX72N)
  148. #define DCD_ATTR_ENDPOINT_MAX 10
  149. //------------- GigaDevice -------------//
  150. #elif TU_CHECK_MCU(OPT_MCU_GD32VF103)
  151. #define DCD_ATTR_ENDPOINT_MAX 4
  152. //------------- Broadcom -------------//
  153. #elif TU_CHECK_MCU(OPT_MCU_BCM2711)
  154. #define DCD_ATTR_ENDPOINT_MAX 8
  155. //------------- Broadcom -------------//
  156. #elif TU_CHECK_MCU(OPT_MCU_XMC4000)
  157. #define DCD_ATTR_ENDPOINT_MAX 8
  158. #else
  159. #warning "DCD_ATTR_ENDPOINT_MAX is not defined for this MCU, default to 8"
  160. #define DCD_ATTR_ENDPOINT_MAX 8
  161. #endif
  162. // Default to fullspeed if not defined
  163. //#ifndef PORT_HIGHSPEED
  164. // #define DCD_ATTR_PORT_HIGHSPEED 0x00
  165. //#endif
  166. #endif