tusb_config.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2019 Ha Thach (tinyusb.org),
  5. * Additions Copyright (c) 2020, Espressif Systems (Shanghai) PTE LTD
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. * THE SOFTWARE.
  24. *
  25. */
  26. #pragma once
  27. #include "tusb_option.h"
  28. #include "sdkconfig.h"
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /* */
  33. /* COMMON CONFIGURATION */
  34. /* */
  35. #define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
  36. #define CFG_TUSB_OS OPT_OS_FREERTOS
  37. /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
  38. * Tinyusb use follows macros to declare transferring memory so that they can be put
  39. * into those specific section.
  40. * e.g
  41. * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
  42. * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
  43. */
  44. #ifndef CFG_TUSB_MEM_SECTION
  45. # define CFG_TUSB_MEM_SECTION
  46. #endif
  47. #ifndef CFG_TUSB_MEM_ALIGN
  48. # define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
  49. #endif
  50. /* */
  51. /* DRIVER CONFIGURATION */
  52. /* */
  53. #define CFG_TUD_MAINTASK_SIZE 4096
  54. #define CFG_TUD_ENDOINT0_SIZE 64
  55. // CDC FIFO size of TX and RX
  56. #define CFG_TUD_CDC_RX_BUFSIZE CONFIG_USB_CDC_RX_BUFSIZE
  57. #define CFG_TUD_CDC_TX_BUFSIZE CONFIG_USB_CDC_TX_BUFSIZE
  58. // MSC Buffer size of Device Mass storage:
  59. #define CFG_TUD_MSC_BUFSIZE CONFIG_USB_MSC_BUFSIZE
  60. // HID buffer size Should be sufficient to hold ID (if any) + Data
  61. #define CFG_TUD_HID_BUFSIZE CONFIG_USB_HID_BUFSIZE
  62. #define CFG_TUD_CDC CONFIG_USB_CDC_ENABLED
  63. #define CFG_TUD_MSC CONFIG_USB_MSC_ENABLED
  64. #define CFG_TUD_HID CONFIG_USB_HID_ENABLED
  65. #define CFG_TUD_MIDI CONFIG_USB_MIDI_ENABLED
  66. #define CFG_TUD_CUSTOM_CLASS CONFIG_USB_CUSTOM_CLASS_ENABLED
  67. /* */
  68. /* KCONFIG */
  69. /* */
  70. #ifndef CONFIG_USB_CDC_ENABLED
  71. # define CONFIG_USB_CDC_ENABLED 0
  72. #endif
  73. #ifndef CONFIG_USB_MSC_ENABLED
  74. # define CONFIG_USB_MSC_ENABLED 0
  75. #endif
  76. #ifndef CONFIG_USB_HID_ENABLED
  77. # define CONFIG_USB_HID_ENABLED 0
  78. #endif
  79. #ifndef CONFIG_USB_MIDI_ENABLED
  80. # define CONFIG_USB_MIDI_ENABLED 0
  81. #endif
  82. #ifndef CONFIG_USB_CUSTOM_CLASS_ENABLED
  83. # define CONFIG_USB_CUSTOM_CLASS_ENABLED 0
  84. #endif
  85. #ifdef __cplusplus
  86. }
  87. #endif