usb_device_ch9.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef __USB_DEVICE_CH9_H__
  35. #define __USB_DEVICE_CH9_H__
  36. /*******************************************************************************
  37. * Definitions
  38. ******************************************************************************/
  39. /*!
  40. * @addtogroup usb_device_ch9
  41. * @{
  42. */
  43. /*******************************************************************************
  44. * Definitions
  45. ******************************************************************************/
  46. /*! @brief Defines USB device status size when the host request to get device status */
  47. #define USB_DEVICE_STATUS_SIZE (0x02U)
  48. /*! @brief Defines USB device interface status size when the host request to get interface status */
  49. #define USB_INTERFACE_STATUS_SIZE (0x02U)
  50. /*! @brief Defines USB device endpoint status size when the host request to get endpoint status */
  51. #define USB_ENDPOINT_STATUS_SIZE (0x02U)
  52. /*! @brief Defines USB device configuration size when the host request to get current configuration */
  53. #define USB_CONFIGURE_SIZE (0X01U)
  54. /*! @brief Defines USB device interface alternate setting size when the host request to get interface alternate setting
  55. */
  56. #define USB_INTERFACE_SIZE (0X01U)
  57. /*! @brief Defines USB device status mask */
  58. #define USB_GET_STATUS_DEVICE_MASK (0x03U)
  59. /*! @brief Defines USB device interface status mask */
  60. #define USB_GET_STATUS_INTERFACE_MASK (0x03U)
  61. /*! @brief Defines USB device endpoint status mask */
  62. #define USB_GET_STATUS_ENDPOINT_MASK (0x03U)
  63. /*! @brief Control read and write sequence */
  64. typedef enum _usb_device_control_read_write_sequence
  65. {
  66. kUSB_DeviceControlPipeSetupStage = 0U, /*!< Setup stage */
  67. kUSB_DeviceControlPipeDataStage, /*!< Data stage */
  68. kUSB_DeviceControlPipeStatusStage, /*!< status stage */
  69. } usb_device_control_read_write_sequence_t;
  70. /*******************************************************************************
  71. * API
  72. ******************************************************************************/
  73. #if defined(__cplusplus)
  74. extern "C" {
  75. #endif
  76. /*******************************************************************************
  77. * API
  78. ******************************************************************************/
  79. /*!
  80. * @brief Initialize the control pipes.
  81. *
  82. * The function is used to initialize the control pipes. This function should be called when event
  83. * kUSB_DeviceEventBusReset is received.
  84. *
  85. * @param handle The device handle.
  86. *
  87. * @return A USB error code or kStatus_USB_Success.
  88. */
  89. extern usb_status_t USB_DeviceControlPipeInit(usb_device_handle handle);
  90. #if defined(__cplusplus)
  91. }
  92. #endif
  93. /*! @}*/
  94. #endif /* __USB_DEVICE_CH9_H__ */