tusb_config.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. //--------------------------------------------------------------------
  42. // COMMON CONFIGURATION
  43. //--------------------------------------------------------------------
  44. // defined by compiler flags for flexibility
  45. #ifndef CFG_TUSB_MCU
  46. #error CFG_TUSB_MCU must be defined
  47. #endif
  48. #ifndef CFG_TUSB_OS
  49. #define CFG_TUSB_OS OPT_OS_NONE
  50. #endif
  51. #ifndef CFG_TUSB_DEBUG
  52. #define CFG_TUSB_DEBUG 0
  53. #endif
  54. // Enable Device stack
  55. #define CFG_TUD_ENABLED 1
  56. // Default is max speed that hardware controller could support with on-chip PHY
  57. #define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
  58. /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
  59. * Tinyusb use follows macros to declare transferring memory so that they can be put
  60. * into those specific section.
  61. * e.g
  62. * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
  63. * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
  64. */
  65. #ifndef CFG_TUSB_MEM_SECTION
  66. #define CFG_TUSB_MEM_SECTION
  67. #endif
  68. #ifndef CFG_TUSB_MEM_ALIGN
  69. #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
  70. #endif
  71. //--------------------------------------------------------------------
  72. // DEVICE CONFIGURATION
  73. //--------------------------------------------------------------------
  74. #ifndef CFG_TUD_ENDPOINT0_SIZE
  75. #define CFG_TUD_ENDPOINT0_SIZE 64
  76. #endif
  77. //------------- CLASS -------------//
  78. #define CFG_TUD_HID 1
  79. #define CFG_TUD_CDC 0
  80. #define CFG_TUD_MSC 0
  81. #define CFG_TUD_MIDI 0
  82. #define CFG_TUD_VENDOR 0
  83. // HID buffer size Should be sufficient to hold ID (if any) + Data
  84. #define CFG_TUD_HID_EP_BUFSIZE 16
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif /* _TUSB_CONFIG_H_ */