config.h 4.6 KB

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