No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tusb_config.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. // COMMON CONFIGURATION
  32. //--------------------------------------------------------------------
  33. // defined by board.mk
  34. #ifndef CFG_TUSB_MCU
  35. #error CFG_TUSB_MCU must be defined
  36. #endif
  37. // RHPort number used for device can be defined by board.mk, default to port 0
  38. #ifndef BOARD_DEVICE_RHPORT_NUM
  39. #define BOARD_DEVICE_RHPORT_NUM 0
  40. #endif
  41. // RHPort max operational speed can defined by board.mk
  42. // Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed
  43. #ifndef BOARD_DEVICE_RHPORT_SPEED
  44. #if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \
  45. CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56 || CFG_TUSB_MCU == OPT_MCU_SAMX7X)
  46. #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED
  47. #else
  48. #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
  49. #endif
  50. #endif
  51. // Device mode with rhport and speed defined by board.mk
  52. #if BOARD_DEVICE_RHPORT_NUM == 0
  53. #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
  54. #elif BOARD_DEVICE_RHPORT_NUM == 1
  55. #define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
  56. #else
  57. #error "Incorrect RHPort configuration"
  58. #endif
  59. #ifndef CFG_TUSB_OS
  60. #define CFG_TUSB_OS OPT_OS_NONE
  61. #endif
  62. // CFG_TUSB_DEBUG is defined by compiler in DEBUG build
  63. // #define CFG_TUSB_DEBUG 0
  64. /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
  65. * Tinyusb use follows macros to declare transferring memory so that they can be put
  66. * into those specific section.
  67. * e.g
  68. * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
  69. * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
  70. */
  71. #ifndef CFG_TUSB_MEM_SECTION
  72. #define CFG_TUSB_MEM_SECTION
  73. #endif
  74. #ifndef CFG_TUSB_MEM_ALIGN
  75. #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
  76. #endif
  77. //--------------------------------------------------------------------
  78. // DEVICE CONFIGURATION
  79. //--------------------------------------------------------------------
  80. #ifndef CFG_TUD_ENDPOINT0_SIZE
  81. #define CFG_TUD_ENDPOINT0_SIZE 64
  82. #endif
  83. //------------- CLASS -------------//
  84. #define CFG_TUD_HID 1
  85. #define CFG_TUD_CDC 1
  86. #define CFG_TUD_MSC 1
  87. #define CFG_TUD_MIDI 0
  88. #define CFG_TUD_VENDOR 0
  89. // HID buffer size Should be sufficient to hold ID (if any) + Data
  90. #define CFG_TUD_HID_EP_BUFSIZE 16
  91. // CDC FIFO size of TX and RX
  92. #define CFG_TUD_CDC_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
  93. #define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
  94. // CDC Endpoint transfer buffer size, more is faster
  95. #define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
  96. // MSC Buffer size of Device Mass storage
  97. #define CFG_TUD_MSC_EP_BUFSIZE 512
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif /* _TUSB_CONFIG_H_ */