tusb_config.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * tusb_config.h
  3. *
  4. * Created on: May 5, 2021
  5. * Author: Jeremiah McCarthy
  6. */
  7. #ifndef TUSB_CONFIG_H_
  8. #define TUSB_CONFIG_H_
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. //--------------------------------------------------------------------+
  13. // Board Specific Configuration
  14. //--------------------------------------------------------------------+
  15. // RHPort number used for device can be defined by board.mk, default to port 0
  16. #ifndef BOARD_TUD_RHPORT
  17. #define BOARD_TUD_RHPORT 0
  18. #endif
  19. // RHPort max operational speed can defined by board.mk
  20. #ifndef BOARD_TUD_MAX_SPEED
  21. #define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
  22. #endif
  23. //--------------------------------------------------------------------
  24. // COMMON CONFIGURATION
  25. //--------------------------------------------------------------------
  26. // defined by compiler flags for flexibility
  27. #ifndef CFG_TUSB_MCU
  28. #error CFG_TUSB_MCU must be defined
  29. #endif
  30. #ifndef CFG_TUSB_OS
  31. #define CFG_TUSB_OS OPT_OS_NONE
  32. #endif
  33. #ifndef CFG_TUSB_DEBUG
  34. #define CFG_TUSB_DEBUG 0
  35. #endif
  36. // Enable Device stack
  37. #define CFG_TUD_ENABLED 1
  38. // Default is max speed that hardware controller could support with on-chip PHY
  39. #define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
  40. /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
  41. * Tinyusb use follows macros to declare transferring memory so that they can be put
  42. * into those specific section.
  43. * e.g
  44. * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
  45. * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
  46. */
  47. #ifndef CFG_TUSB_MEM_SECTION
  48. #define CFG_TUSB_MEM_SECTION
  49. #endif
  50. #ifndef CFG_TUSB_MEM_ALIGN
  51. #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
  52. #endif
  53. //--------------------------------------------------------------------
  54. // DEVICE CONFIGURATION
  55. //--------------------------------------------------------------------
  56. #ifndef CFG_TUD_ENDPOINT0_SIZE
  57. #define CFG_TUD_ENDPOINT0_SIZE 64
  58. #endif
  59. //------------- CLASS -------------//
  60. #define CFG_TUD_DFU 1
  61. // DFU buffer size, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR
  62. #define CFG_TUD_DFU_XFER_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif /* TUSB_CONFIG_H_ */