usb.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016 NXP
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of the copyright holder nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef __USB_H__
  31. #define __USB_H__
  32. #include <stdint.h>
  33. #include <stdio.h>
  34. #include <fsl_common.h>
  35. #include <fsl_os_abstraction.h>
  36. #include "usb_misc.h"
  37. #include "usb_spec.h"
  38. /*!
  39. * @addtogroup usb_drv
  40. * @{
  41. */
  42. /*******************************************************************************
  43. * Definitions
  44. ******************************************************************************/
  45. /*! @brief Defines USB stack major version */
  46. #define USB_STACK_VERSION_MAJOR (1U)
  47. /*! @brief Defines USB stack minor version */
  48. #define USB_STACK_VERSION_MINOR (6U)
  49. /*! @brief Defines USB stack bugfix version */
  50. #define USB_STACK_VERSION_BUGFIX (3U)
  51. /*! @brief USB stack version definition */
  52. #define USB_MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
  53. /*! @brief USB error code */
  54. typedef enum _usb_status
  55. {
  56. kStatus_USB_Success = 0x00U, /*!< Success */
  57. kStatus_USB_Error, /*!< Failed */
  58. kStatus_USB_Busy, /*!< Busy */
  59. kStatus_USB_InvalidHandle, /*!< Invalid handle */
  60. kStatus_USB_InvalidParameter, /*!< Invalid parameter */
  61. kStatus_USB_InvalidRequest, /*!< Invalid request */
  62. kStatus_USB_ControllerNotFound, /*!< Controller cannot be found */
  63. kStatus_USB_InvalidControllerInterface, /*!< Invalid controller interface */
  64. kStatus_USB_NotSupported, /*!< Configuration is not supported */
  65. kStatus_USB_Retry, /*!< Enumeration get configuration retry */
  66. kStatus_USB_TransferStall, /*!< Transfer stalled */
  67. kStatus_USB_TransferFailed, /*!< Transfer failed */
  68. kStatus_USB_AllocFail, /*!< Allocation failed */
  69. kStatus_USB_LackSwapBuffer, /*!< Insufficient swap buffer for KHCI */
  70. kStatus_USB_TransferCancel, /*!< The transfer cancelled */
  71. kStatus_USB_BandwidthFail, /*!< Allocate bandwidth failed */
  72. kStatus_USB_MSDStatusFail, /*!< For MSD, the CSW status means fail */
  73. kStatus_USB_EHCIAttached,
  74. kStatus_USB_EHCIDetached,
  75. } usb_status_t;
  76. /*! @brief USB host handle type define */
  77. typedef void *usb_host_handle;
  78. /*! @brief USB device handle type define. For device stack it is the whole device handle; for host stack it is the
  79. * attached device instance handle*/
  80. typedef void *usb_device_handle;
  81. /*! @brief USB OTG handle type define */
  82. typedef void *usb_otg_handle;
  83. /*! @brief USB controller ID */
  84. typedef enum _usb_controller_index
  85. {
  86. kUSB_ControllerKhci0 = 0U, /*!< KHCI 0U */
  87. kUSB_ControllerKhci1 = 1U, /*!< KHCI 1U, Currently, there are no platforms which have two KHCI IPs, this is reserved
  88. to be used in the future. */
  89. kUSB_ControllerEhci0 = 2U, /*!< EHCI 0U */
  90. kUSB_ControllerEhci1 = 3U, /*!< EHCI 1U, Currently, there are no platforms which have two EHCI IPs, this is reserved
  91. to be used in the future. */
  92. kUSB_ControllerLpcIp3511Fs0 = 4U, /*!< LPC USB IP3511 FS controller 0 */
  93. kUSB_ControllerLpcIp3511Fs1 =
  94. 5U, /*!< LPC USB IP3511 FS controller 1, there are no platforms which have two IP3511 IPs, this is reserved
  95. to be used in the future. */
  96. kUSB_ControllerLpcIp3511Hs0 = 6U, /*!< LPC USB IP3511 HS controller 0 */
  97. kUSB_ControllerLpcIp3511Hs1 =
  98. 7U, /*!< LPC USB IP3511 HS controller 1, there are no platforms which have two IP3511 IPs, this is reserved
  99. to be used in the future. */
  100. kUSB_ControllerOhci0 = 8U, /*!< OHCI 0U */
  101. kUSB_ControllerOhci1 = 9U, /*!< OHCI 1U, Currently, there are no platforms which have two OHCI IPs, this is reserved
  102. to be used in the future. */
  103. kUSB_ControllerIp3516Hs0 = 10U, /*!< IP3516HS 0U */
  104. kUSB_ControllerIp3516Hs1 =
  105. 11U, /*!< IP3516HS 1U, Currently, there are no platforms which have two IP3516HS IPs, this is reserved
  106. to be used in the future. */
  107. } usb_controller_index_t;
  108. /**
  109. * @brief USB stack version fields
  110. */
  111. typedef struct _usb_version
  112. {
  113. uint8_t major; /*!< Major */
  114. uint8_t minor; /*!< Minor */
  115. uint8_t bugfix; /*!< Bug fix */
  116. } usb_version_t;
  117. /*******************************************************************************
  118. * API
  119. ******************************************************************************/
  120. /*! @} */
  121. #endif /* __USB_H__ */