tusb_config.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #ifndef CONFIG_TINYUSB_CDC_ENABLED
  33. # define CONFIG_TINYUSB_CDC_ENABLED 0
  34. #endif
  35. #ifndef CONFIG_TINYUSB_MSC_ENABLED
  36. # define CONFIG_TINYUSB_MSC_ENABLED 0
  37. #endif
  38. #ifndef CONFIG_TINYUSB_HID_ENABLED
  39. # define CONFIG_TINYUSB_HID_ENABLED 0
  40. #endif
  41. #ifndef CONFIG_TINYUSB_MIDI_ENABLED
  42. # define CONFIG_TINYUSB_MIDI_ENABLED 0
  43. #endif
  44. #ifndef CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED
  45. # define CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED 0
  46. #endif
  47. #define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED
  48. #define CFG_TUSB_OS OPT_OS_FREERTOS
  49. /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
  50. * Tinyusb use follows macros to declare transferring memory so that they can be put
  51. * into those specific section.
  52. * e.g
  53. * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
  54. * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
  55. */
  56. #ifndef CFG_TUSB_MEM_SECTION
  57. # define CFG_TUSB_MEM_SECTION
  58. #endif
  59. #ifndef CFG_TUSB_MEM_ALIGN
  60. # define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
  61. #endif
  62. #ifndef CFG_TUD_ENDPOINT0_SIZE
  63. #define CFG_TUD_ENDPOINT0_SIZE 64
  64. #endif
  65. // CDC FIFO size of TX and RX
  66. #define CFG_TUD_CDC_RX_BUFSIZE CONFIG_TINYUSB_CDC_RX_BUFSIZE
  67. #define CFG_TUD_CDC_TX_BUFSIZE CONFIG_TINYUSB_CDC_TX_BUFSIZE
  68. // MSC Buffer size of Device Mass storage
  69. #define CFG_TUD_MSC_BUFSIZE CONFIG_TINYUSB_MSC_BUFSIZE
  70. // HID buffer size Should be sufficient to hold ID (if any) + Data
  71. #define CFG_TUD_HID_BUFSIZE CONFIG_TINYUSB_HID_BUFSIZE
  72. // Enabled device class driver
  73. #define CFG_TUD_CDC CONFIG_TINYUSB_CDC_ENABLED
  74. #define CFG_TUD_MSC CONFIG_TINYUSB_MSC_ENABLED
  75. #define CFG_TUD_HID CONFIG_TINYUSB_HID_ENABLED
  76. #define CFG_TUD_MIDI CONFIG_TINYUSB_MIDI_ENABLED
  77. #define CFG_TUD_CUSTOM_CLASS CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED
  78. #ifdef __cplusplus
  79. }
  80. #endif