1 /* 2 * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 * Copyright 2016 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #ifndef __USB_H__ 10 #define __USB_H__ 11 12 #include <stdint.h> 13 #include <stdio.h> 14 #include "fsl_os_abstraction.h" 15 #include "fsl_common.h" 16 #include "usb_misc.h" 17 #include "usb_spec.h" 18 19 /*! 20 * @addtogroup usb_drv 21 * @{ 22 */ 23 24 /******************************************************************************* 25 * Definitions 26 ******************************************************************************/ 27 /*! @brief Defines USB stack major version */ 28 #define USB_STACK_VERSION_MAJOR (2UL) 29 /*! @brief Defines USB stack minor version */ 30 #define USB_STACK_VERSION_MINOR (9UL) 31 /*! @brief Defines USB stack bugfix version */ 32 #define USB_STACK_VERSION_BUGFIX (0U) 33 34 /*! @brief USB stack version definition */ 35 #define USB_MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix)) 36 37 /*! @brief USB stack component version definition, changed with component in yaml together */ 38 #define USB_STACK_COMPONENT_VERSION \ 39 MAKE_VERSION(USB_STACK_VERSION_MAJOR, USB_STACK_VERSION_MINOR, USB_STACK_VERSION_BUGFIX) 40 41 /* 42 * Component ID used by tools 43 * 44 * FSL_COMPONENT_ID "middleware.usb.stack_common" 45 */ 46 47 /*! @brief USB error code */ 48 typedef enum _usb_status 49 { 50 kStatus_USB_Success = 0x00U, /*!< Success */ 51 kStatus_USB_Error, /*!< Failed */ 52 53 kStatus_USB_Busy, /*!< Busy */ 54 kStatus_USB_InvalidHandle, /*!< Invalid handle */ 55 kStatus_USB_InvalidParameter, /*!< Invalid parameter */ 56 kStatus_USB_InvalidRequest, /*!< Invalid request */ 57 kStatus_USB_ControllerNotFound, /*!< Controller cannot be found */ 58 kStatus_USB_InvalidControllerInterface, /*!< Invalid controller interface */ 59 60 kStatus_USB_NotSupported, /*!< Configuration is not supported */ 61 kStatus_USB_Retry, /*!< Enumeration get configuration retry */ 62 kStatus_USB_TransferStall, /*!< Transfer stalled */ 63 kStatus_USB_TransferFailed, /*!< Transfer failed */ 64 kStatus_USB_AllocFail, /*!< Allocation failed */ 65 kStatus_USB_LackSwapBuffer, /*!< Insufficient swap buffer for KHCI */ 66 kStatus_USB_TransferCancel, /*!< The transfer cancelled */ 67 kStatus_USB_BandwidthFail, /*!< Allocate bandwidth failed */ 68 kStatus_USB_MSDStatusFail, /*!< For MSD, the CSW status means fail */ 69 kStatus_USB_EHCIAttached, 70 kStatus_USB_EHCIDetached, 71 kStatus_USB_DataOverRun, /*!< The amount of data returned by the endpoint exceeded 72 either the size of the maximum data packet allowed 73 from the endpoint or the remaining buffer size. */ 74 } usb_status_t; 75 76 /*! @brief USB host handle type define */ 77 typedef void *usb_host_handle; 78 79 /*! @brief USB device handle type define. For device stack it is the whole device handle; for host stack it is the 80 * attached device instance handle*/ 81 typedef void *usb_device_handle; 82 83 /*! @brief USB OTG handle type define */ 84 typedef void *usb_otg_handle; 85 86 /*! @brief USB controller ID */ 87 typedef enum _usb_controller_index 88 { 89 kUSB_ControllerKhci0 = 0U, /*!< KHCI 0U */ 90 kUSB_ControllerKhci1 = 1U, /*!< KHCI 1U, Currently, there are no platforms which have two KHCI IPs, this is reserved 91 to be used in the future. */ 92 kUSB_ControllerEhci0 = 2U, /*!< EHCI 0U */ 93 kUSB_ControllerEhci1 = 3U, /*!< EHCI 1U */ 94 95 kUSB_ControllerLpcIp3511Fs0 = 4U, /*!< LPC USB IP3511 FS controller 0 */ 96 kUSB_ControllerLpcIp3511Fs1 = 5U, /*!< LPC USB IP3511 FS controller 1, there are no platforms which have two IP3511 97 IPs, this is reserved to be used in the future. */ 98 99 kUSB_ControllerLpcIp3511Hs0 = 6U, /*!< LPC USB IP3511 HS controller 0 */ 100 kUSB_ControllerLpcIp3511Hs1 = 7U, /*!< LPC USB IP3511 HS controller 1, there are no platforms which have two IP3511 101 IPs, this is reserved to be used in the future. */ 102 103 kUSB_ControllerOhci0 = 8U, /*!< OHCI 0U */ 104 kUSB_ControllerOhci1 = 9U, /*!< OHCI 1U, Currently, there are no platforms which have two OHCI IPs, this is reserved 105 to be used in the future. */ 106 107 kUSB_ControllerIp3516Hs0 = 10U, /*!< IP3516HS 0U */ 108 kUSB_ControllerIp3516Hs1 = 11U, /*!< IP3516HS 1U, Currently, there are no platforms which have two IP3516HS IPs, 109 this is reserved to be used in the future. */ 110 kUSB_ControllerDwc30 = 12U, /*!< DWC3 0U */ 111 kUSB_ControllerDwc31 = 13U, /*!< DWC3 1U Currently, there are no platforms which have two Dwc IPs, this is reserved 112 to be used in the future.*/ 113 } usb_controller_index_t; 114 115 /** 116 * @brief USB stack version fields 117 */ 118 typedef struct _usb_version 119 { 120 uint8_t major; /*!< Major */ 121 uint8_t minor; /*!< Minor */ 122 uint8_t bugfix; /*!< Bug fix */ 123 } usb_version_t; 124 125 /******************************************************************************* 126 * API 127 ******************************************************************************/ 128 129 /*! @} */ 130 131 #endif /* __USB_H__ */ 132