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 31 #ifndef __USB_H__ 32 #define __USB_H__ 33 34 #include <stdint.h> 35 #include <stdio.h> 36 #include <fsl_common.h> 37 #include "usb_misc.h" 38 #include "usb_spec.h" 39 40 /*! 41 * @addtogroup usb_drv 42 * @{ 43 */ 44 45 /******************************************************************************* 46 * Definitions 47 ******************************************************************************/ 48 /*! @brief Defines USB stack major version */ 49 #define USB_STACK_VERSION_MAJOR (1U) 50 /*! @brief Defines USB stack minor version */ 51 #define USB_STACK_VERSION_MINOR (6U) 52 /*! @brief Defines USB stack bugfix version */ 53 #define USB_STACK_VERSION_BUGFIX (3U) 54 55 /*! @brief USB stack version definition */ 56 #define USB_MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix)) 57 58 /*! @brief USB error code */ 59 typedef enum _usb_status 60 { 61 kStatus_USB_Success = 0x00U, /*!< Success */ 62 kStatus_USB_Error, /*!< Failed */ 63 64 kStatus_USB_Busy, /*!< Busy */ 65 kStatus_USB_InvalidHandle, /*!< Invalid handle */ 66 kStatus_USB_InvalidParameter, /*!< Invalid parameter */ 67 kStatus_USB_InvalidRequest, /*!< Invalid request */ 68 kStatus_USB_ControllerNotFound, /*!< Controller cannot be found */ 69 kStatus_USB_InvalidControllerInterface, /*!< Invalid controller interface */ 70 71 kStatus_USB_NotSupported, /*!< Configuration is not supported */ 72 kStatus_USB_Retry, /*!< Enumeration get configuration retry */ 73 kStatus_USB_TransferStall, /*!< Transfer stalled */ 74 kStatus_USB_TransferFailed, /*!< Transfer failed */ 75 kStatus_USB_AllocFail, /*!< Allocation failed */ 76 kStatus_USB_LackSwapBuffer, /*!< Insufficient swap buffer for KHCI */ 77 kStatus_USB_TransferCancel, /*!< The transfer cancelled */ 78 kStatus_USB_BandwidthFail, /*!< Allocate bandwidth failed */ 79 kStatus_USB_MSDStatusFail, /*!< For MSD, the CSW status means fail */ 80 kStatus_USB_EHCIAttached, 81 kStatus_USB_EHCIDetached, 82 } usb_status_t; 83 84 /*! @brief USB host handle type define */ 85 typedef void *usb_host_handle; 86 87 /*! @brief USB device handle type define. For device stack it is the whole device handle; for host stack it is the 88 * attached device instance handle*/ 89 typedef void *usb_device_handle; 90 91 /*! @brief USB OTG handle type define */ 92 typedef void *usb_otg_handle; 93 94 /*! @brief USB controller ID */ 95 typedef enum _usb_controller_index 96 { 97 kUSB_ControllerKhci0 = 0U, /*!< KHCI 0U */ 98 kUSB_ControllerKhci1 = 1U, /*!< KHCI 1U, Currently, there are no platforms which have two KHCI IPs, this is reserved 99 to be used in the future. */ 100 kUSB_ControllerEhci0 = 2U, /*!< EHCI 0U */ 101 kUSB_ControllerEhci1 = 3U, /*!< EHCI 1U, Currently, there are no platforms which have two EHCI IPs, this is reserved 102 to be used in the future. */ 103 104 kUSB_ControllerLpcIp3511Fs0 = 4U, /*!< LPC USB IP3511 FS controller 0 */ 105 kUSB_ControllerLpcIp3511Fs1 = 106 5U, /*!< LPC USB IP3511 FS controller 1, there are no platforms which have two IP3511 IPs, this is reserved 107 to be used in the future. */ 108 109 kUSB_ControllerLpcIp3511Hs0 = 6U, /*!< LPC USB IP3511 HS controller 0 */ 110 kUSB_ControllerLpcIp3511Hs1 = 111 7U, /*!< LPC USB IP3511 HS controller 1, there are no platforms which have two IP3511 IPs, this is reserved 112 to be used in the future. */ 113 114 kUSB_ControllerOhci0 = 8U, /*!< OHCI 0U */ 115 kUSB_ControllerOhci1 = 9U, /*!< OHCI 1U, Currently, there are no platforms which have two OHCI IPs, this is reserved 116 to be used in the future. */ 117 118 kUSB_ControllerIp3516Hs0 = 10U, /*!< IP3516HS 0U */ 119 kUSB_ControllerIp3516Hs1 = 120 11U, /*!< IP3516HS 1U, Currently, there are no platforms which have two IP3516HS IPs, this is reserved 121 to be used in the future. */ 122 } usb_controller_index_t; 123 124 /** 125 * @brief USB stack version fields 126 */ 127 typedef struct _usb_version 128 { 129 uint8_t major; /*!< Major */ 130 uint8_t minor; /*!< Minor */ 131 uint8_t bugfix; /*!< Bug fix */ 132 } usb_version_t; 133 134 /******************************************************************************* 135 * API 136 ******************************************************************************/ 137 138 /*! @} */ 139 140 #endif /* __USB_H__ */ 141