config.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**************************************************************************//**
  2. * @file config.h
  3. * @version V1.00
  4. * @brief This header file defines the configuration of USB Host library.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. *
  8. * @copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
  9. *****************************************************************************/
  10. #ifndef _USBH_CONFIG_H_
  11. #define _USBH_CONFIG_H_
  12. /// @cond HIDDEN_SYMBOLS
  13. #include <rtconfig.h>
  14. #include <rtdevice.h>
  15. /*----------------------------------------------------------------------------------------*/
  16. /* Hardware settings */
  17. /*----------------------------------------------------------------------------------------*/
  18. #define HCLK_MHZ 192 /* used for loop-delay. must be larger than
  19. true HCLK clock MHz */
  20. #define ENABLE_OHCI_IRQ() NVIC_EnableIRQ(USBH_IRQn)
  21. #define DISABLE_OHCI_IRQ() NVIC_DisableIRQ(USBH_IRQn)
  22. #define ENABLE_EHCI_IRQ() NVIC_EnableIRQ(HSUSBH_IRQn)
  23. #define DISABLE_EHCI_IRQ() NVIC_DisableIRQ(HSUSBH_IRQn)
  24. #define ENABLE_OHCI /* Enable OHCI host controller */
  25. #if defined(BSP_USING_HSUSBH)
  26. #define ENABLE_EHCI /* Enable EHCI host controller */
  27. #endif
  28. #define EHCI_PORT_CNT 1 /* Number of EHCI roothub ports */
  29. #define OHCI_PORT_CNT 2 /* Number of OHCI roothub ports */
  30. #define OHCI_PER_PORT_POWER /* OHCI root hub per port powered */
  31. #define OHCI_ISO_DELAY 4 /* preserved number frames while scheduling
  32. OHCI isochronous transfer */
  33. #define EHCI_ISO_DELAY 2 /* preserved number of frames while
  34. scheduling EHCI isochronous transfer */
  35. #define EHCI_ISO_RCLM_RANGE 32 /* When inspecting activated iTD/siTD,
  36. unconditionally reclaim iTD/isTD scheduled
  37. in just elapsed EHCI_ISO_RCLM_RANGE ms. */
  38. #define MAX_DESC_BUFF_SIZE 512 /* To hold the configuration descriptor, USB
  39. core will allocate a buffer with this size
  40. for each connected device. USB core does
  41. not release it until device disconnected. */
  42. /*----------------------------------------------------------------------------------------*/
  43. /* Memory allocation settings */
  44. /*----------------------------------------------------------------------------------------*/
  45. #define STATIC_MEMORY_ALLOC 0 /* pre-allocate static memory blocks. No dynamic memory aloocation.
  46. But the maximum number of connected devices and transfers are
  47. limited. */
  48. #define MAX_UDEV_DRIVER 8 /*!< Maximum number of registered drivers */
  49. #define MAX_ALT_PER_IFACE 8 /*!< maximum number of alternative interfaces per interface */
  50. #define MAX_EP_PER_IFACE 6 /*!< maximum number of endpoints per interface */
  51. #define MAX_HUB_DEVICE 8 /*!< Maximum number of hub devices */
  52. /* Host controller hardware transfer descriptors memory pool. ED/TD/ITD of OHCI and QH/QTD of EHCI
  53. are all allocated from this pool. Allocated unit size is determined by MEM_POOL_UNIT_SIZE.
  54. May allocate one or more units depend on hardware descriptor type. */
  55. #define MEM_POOL_UNIT_SIZE 64 /*!< A fixed hard coding setting. Do not change it! */
  56. #define MEM_POOL_UNIT_NUM 256 /*!< Increase this or heap size if memory allocate failed. */
  57. /*----------------------------------------------------------------------------------------*/
  58. /* Re-defined staff for various compiler */
  59. /*----------------------------------------------------------------------------------------*/
  60. #ifdef __ICCARM__
  61. #define __inline inline
  62. #endif
  63. /*----------------------------------------------------------------------------------------*/
  64. /* Debug settings */
  65. /*----------------------------------------------------------------------------------------*/
  66. #define ENABLE_ERROR_MSG /* enable debug messages */
  67. #define ENABLE_DEBUG_MSG /* enable debug messages */
  68. //#define ENABLE_VERBOSE_DEBUG /* verbos debug messages */
  69. //#define DUMP_DESCRIPTOR /* dump descriptors */
  70. #ifdef ENABLE_ERROR_MSG
  71. #define USB_error rt_kprintf
  72. #else
  73. #define USB_error(...)
  74. #endif
  75. #ifdef ENABLE_DEBUG_MSG
  76. #define USB_debug rt_kprintf
  77. #ifdef ENABLE_VERBOSE_DEBUG
  78. #define USB_vdebug rt_kprintf
  79. #else
  80. #define USB_vdebug(...)
  81. #endif
  82. #else
  83. #define USB_debug(...)
  84. #define USB_vdebug(...)
  85. #endif
  86. /// @endcond HIDDEN_SYMBOLS
  87. #endif /* _USBH_CONFIG_H_ */
  88. /*** (C) COPYRIGHT 2018 Nuvoton Technology Corp. ***/