tusb_config.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2019 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. */
  25. #ifndef _TUSB_CONFIG_H_
  26. #define _TUSB_CONFIG_H_
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. //--------------------------------------------------------------------+
  31. // Board Specific Configuration
  32. //--------------------------------------------------------------------+
  33. // RHPort number used for device can be defined by board.mk, default to port 0
  34. #ifndef BOARD_TUD_RHPORT
  35. #define BOARD_TUD_RHPORT 0
  36. #endif
  37. // RHPort max operational speed can defined by board.mk
  38. #ifndef BOARD_TUD_MAX_SPEED
  39. #define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
  40. #endif
  41. // RHPort number used for host can be defined by board.mk, default to port 1
  42. #ifndef BOARD_TUH_RHPORT
  43. #define BOARD_TUH_RHPORT 1
  44. #endif
  45. // RHPort max operational speed can defined by board.mk
  46. #ifndef BOARD_TUH_MAX_SPEED
  47. #define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
  48. #endif
  49. //--------------------------------------------------------------------
  50. // COMMON CONFIGURATION
  51. //--------------------------------------------------------------------
  52. // defined by compiler flags for flexibility
  53. #ifndef CFG_TUSB_MCU
  54. #error CFG_TUSB_MCU must be defined
  55. #endif
  56. #ifndef CFG_TUSB_OS
  57. #define CFG_TUSB_OS OPT_OS_NONE
  58. #endif
  59. #ifndef CFG_TUSB_DEBUG
  60. #define CFG_TUSB_DEBUG 0
  61. #endif
  62. // Enable Device stack, Default is max speed that hardware controller could support with on-chip PHY
  63. #define CFG_TUD_ENABLED 1
  64. #define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
  65. // Enable Host stack, Default is max speed that hardware controller could support with on-chip PHY
  66. #define CFG_TUH_ENABLED 1
  67. #define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
  68. #if CFG_TUSB_MCU == OPT_MCU_RP2040
  69. // Use pico-pio-usb as host controller for raspberry rp2040
  70. #define CFG_TUH_RPI_PIO_USB 1
  71. #endif
  72. // CFG_TUSB_DEBUG is defined by compiler in DEBUG build
  73. // #define CFG_TUSB_DEBUG 0
  74. /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
  75. * Tinyusb use follows macros to declare transferring memory so that they can be put
  76. * into those specific section.
  77. * e.g
  78. * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
  79. * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
  80. */
  81. #ifndef CFG_TUSB_MEM_SECTION
  82. #define CFG_TUSB_MEM_SECTION
  83. #endif
  84. #ifndef CFG_TUSB_MEM_ALIGN
  85. #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
  86. #endif
  87. //--------------------------------------------------------------------
  88. // DEVICE CONFIGURATION
  89. //--------------------------------------------------------------------
  90. #ifndef CFG_TUD_ENDPOINT0_SIZE
  91. #define CFG_TUD_ENDPOINT0_SIZE 64
  92. #endif
  93. //------------- CLASS -------------//
  94. #define CFG_TUD_CDC 1
  95. // CDC FIFO size of TX and RX
  96. #define CFG_TUD_CDC_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
  97. #define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
  98. // CDC Endpoint transfer buffer size, more is faster
  99. #define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
  100. //--------------------------------------------------------------------
  101. // HOST CONFIGURATION
  102. //--------------------------------------------------------------------
  103. // Size of buffer to hold descriptors and other data used for enumeration
  104. #define CFG_TUH_ENUMERATION_BUFSIZE 256
  105. #define CFG_TUH_HUB 1
  106. // max device support (excluding hub device)
  107. #define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1) // hub typically has 4 ports
  108. #define CFG_TUH_HID 4
  109. #define CFG_TUH_HID_EPIN_BUFSIZE 64
  110. #define CFG_TUH_HID_EPOUT_BUFSIZE 64
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif /* _TUSB_CONFIG_H_ */