mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
[Bsp][i.mxrt]Add USB Drivers support HS
This commit is contained in:
1 parent
92f6301882
commit
5713db3fb9
22 files changed
+15142
No files matched your search
@@ -35,3 +35,16 @@ config RT_USING_HP_RTC
|
||||
default n
|
||||
endif
|
||||
|
||||
if RT_USING_USB_DEVICE
|
||||
choice
|
||||
prompt "select usb device controller"
|
||||
default RT_USING_EHCI0_AS_DEVICE
|
||||
|
||||
config RT_USING_EHCI0_AS_DEVICE
|
||||
bool "set EHCI0 as device"
|
||||
config RT_USING_EHCI1_AS_DEVICE
|
||||
bool "set EHCI1 as device"
|
||||
endchoice
|
||||
endif
|
||||
|
||||
|
||||
@@ -27,6 +27,13 @@ if GetDepend('RT_USING_LWIP'):
|
||||
|
||||
if GetDepend('RT_USING_SDIO'):
|
||||
src += ['drv_sdio.c']
|
||||
if GetDepend('RT_USING_USB_DEVICE'):
|
||||
src += Glob('usb/phy/*.c')
|
||||
CPPDEFINES += ['ENDIANNESS']
|
||||
|
||||
if GetDepend('RT_USING_USB_DEVICE'):
|
||||
src += ['drv_usbd.c']
|
||||
src += Glob('usb/device/*.c')
|
||||
|
||||
if GetDepend('RT_USING_RTGUI') or GetDepend('PKG_USING_GUIENGINE'):
|
||||
src += ['drv_lcd.c', 'drv_ft5406.c', 'drv_i2c.c']
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __USB_DEVICE_DCI_H__
|
||||
#define __USB_DEVICE_DCI_H__
|
||||
|
||||
/*!
|
||||
* @addtogroup usb_device_controller_driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Macro to define controller handle */
|
||||
#define usb_device_controller_handle usb_device_handle
|
||||
|
||||
/*! @brief Available notify types for device notification */
|
||||
typedef enum _usb_device_notification
|
||||
{
|
||||
kUSB_DeviceNotifyBusReset = 0x10U, /*!< Reset signal detected */
|
||||
kUSB_DeviceNotifySuspend, /*!< Suspend signal detected */
|
||||
kUSB_DeviceNotifyResume, /*!< Resume signal detected */
|
||||
kUSB_DeviceNotifyLPMSleep, /*!< LPM signal detected */
|
||||
kUSB_DeviceNotifyLPMResume, /*!< Resume signal detected */
|
||||
kUSB_DeviceNotifyError, /*!< Errors happened in bus */
|
||||
kUSB_DeviceNotifyDetach, /*!< Device disconnected from a host */
|
||||
kUSB_DeviceNotifyAttach, /*!< Device connected to a host */
|
||||
#if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U))
|
||||
kUSB_DeviceNotifyDcdTimeOut, /*!< Device charger detection timeout */
|
||||
kUSB_DeviceNotifyDcdUnknownPortType, /*!< Device charger detection unknown port type */
|
||||
kUSB_DeviceNotifySDPDetected, /*!< The SDP facility is detected */
|
||||
kUSB_DeviceNotifyChargingPortDetected, /*!< The charging port is detected */
|
||||
kUSB_DeviceNotifyChargingHostDetected, /*!< The CDP facility is detected */
|
||||
kUSB_DeviceNotifyDedicatedChargerDetected, /*!< The DCP facility is detected */
|
||||
#endif
|
||||
} usb_device_notification_t;
|
||||
|
||||
/*! @brief Device notification message structure */
|
||||
typedef struct _usb_device_callback_message_struct
|
||||
{
|
||||
uint8_t *buffer; /*!< Transferred buffer */
|
||||
uint32_t length; /*!< Transferred data length */
|
||||
uint8_t code; /*!< Notification code */
|
||||
uint8_t isSetup; /*!< Is in a setup phase */
|
||||
} usb_device_callback_message_struct_t;
|
||||
|
||||
/*! @brief Control type for controller */
|
||||
typedef enum _usb_device_control_type
|
||||
{
|
||||
kUSB_DeviceControlRun = 0U, /*!< Enable the device functionality */
|
||||
kUSB_DeviceControlStop, /*!< Disable the device functionality */
|
||||
kUSB_DeviceControlEndpointInit, /*!< Initialize a specified endpoint */
|
||||
kUSB_DeviceControlEndpointDeinit, /*!< De-initialize a specified endpoint */
|
||||
kUSB_DeviceControlEndpointStall, /*!< Stall a specified endpoint */
|
||||
kUSB_DeviceControlEndpointUnstall, /*!< Unstall a specified endpoint */
|
||||
kUSB_DeviceControlGetDeviceStatus, /*!< Get device status */
|
||||
kUSB_DeviceControlGetEndpointStatus, /*!< Get endpoint status */
|
||||
kUSB_DeviceControlSetDeviceAddress, /*!< Set device address */
|
||||
kUSB_DeviceControlGetSynchFrame, /*!< Get current frame */
|
||||
kUSB_DeviceControlResume, /*!< Drive controller to generate a resume signal in USB bus */
|
||||
kUSB_DeviceControlSleepResume, /*!< Drive controller to generate a LPM resume signal in USB bus */
|
||||
kUSB_DeviceControlSuspend, /*!< Drive controller to enetr into suspend mode */
|
||||
kUSB_DeviceControlSleep, /*!< Drive controller to enetr into sleep mode */
|
||||
kUSB_DeviceControlSetDefaultStatus, /*!< Set controller to default status */
|
||||
kUSB_DeviceControlGetSpeed, /*!< Get current speed */
|
||||
kUSB_DeviceControlGetOtgStatus, /*!< Get OTG status */
|
||||
kUSB_DeviceControlSetOtgStatus, /*!< Set OTG status */
|
||||
kUSB_DeviceControlSetTestMode, /*!< Drive xCHI into test mode */
|
||||
kUSB_DeviceControlGetRemoteWakeUp, /*!< Get flag of LPM Remote Wake-up Enabled by USB host. */
|
||||
#if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U))
|
||||
kUSB_DeviceControlDcdInitModule,
|
||||
kUSB_DeviceControlDcdDeinitModule,
|
||||
#endif
|
||||
} usb_device_control_type_t;
|
||||
|
||||
/*! @brief USB device controller initialization function typedef */
|
||||
typedef usb_status_t (*usb_device_controller_init_t)(uint8_t controllerId,
|
||||
usb_device_handle handle,
|
||||
usb_device_controller_handle *controllerHandle);
|
||||
|
||||
/*! @brief USB device controller de-initialization function typedef */
|
||||
typedef usb_status_t (*usb_device_controller_deinit_t)(usb_device_controller_handle controllerHandle);
|
||||
|
||||
/*! @brief USB device controller send data function typedef */
|
||||
typedef usb_status_t (*usb_device_controller_send_t)(usb_device_controller_handle controllerHandle,
|
||||
uint8_t endpointAddress,
|
||||
uint8_t *buffer,
|
||||
uint32_t length);
|
||||
|
||||
/*! @brief USB device controller receive data function typedef */
|
||||
typedef usb_status_t (*usb_device_controller_recv_t)(usb_device_controller_handle controllerHandle,
|
||||
uint8_t endpointAddress,
|
||||
uint8_t *buffer,
|
||||
uint32_t length);
|
||||
|
||||
/*! @brief USB device controller cancel transfer function in a specified endpoint typedef */
|
||||
typedef usb_status_t (*usb_device_controller_cancel_t)(usb_device_controller_handle controllerHandle,
|
||||
uint8_t endpointAddress);
|
||||
|
||||
/*! @brief USB device controller control function typedef */
|
||||
typedef usb_status_t (*usb_device_controller_control_t)(usb_device_controller_handle controllerHandle,
|
||||
usb_device_control_type_t command,
|
||||
void *param);
|
||||
|
||||
/*! @brief USB device controller interface structure */
|
||||
typedef struct _usb_device_controller_interface_struct
|
||||
{
|
||||
usb_device_controller_init_t deviceInit; /*!< Controller initialization */
|
||||
usb_device_controller_deinit_t deviceDeinit; /*!< Controller de-initialization */
|
||||
usb_device_controller_send_t deviceSend; /*!< Controller send data */
|
||||
usb_device_controller_recv_t deviceRecv; /*!< Controller receive data */
|
||||
usb_device_controller_cancel_t deviceCancel; /*!< Controller cancel transfer */
|
||||
usb_device_controller_control_t deviceControl; /*!< Controller control */
|
||||
} usb_device_controller_interface_struct_t;
|
||||
|
||||
/*! @brief USB device status structure */
|
||||
typedef struct _usb_device_struct
|
||||
{
|
||||
#if ((defined(USB_DEVICE_CONFIG_REMOTE_WAKEUP)) && (USB_DEVICE_CONFIG_REMOTE_WAKEUP > 0U))
|
||||
volatile uint64_t hwTick; /*!< Current hw tick(ms)*/
|
||||
#endif
|
||||
usb_device_controller_handle controllerHandle; /*!< Controller handle */
|
||||
const usb_device_controller_interface_struct_t *controllerInterface; /*!< Controller interface handle */
|
||||
#if USB_DEVICE_CONFIG_USE_TASK
|
||||
usb_osa_msgq_handle notificationQueue; /*!< Message queue */
|
||||
#endif
|
||||
usb_device_callback_t deviceCallback; /*!< Device callback function pointer */
|
||||
usb_device_endpoint_callback_struct_t
|
||||
epCallback[USB_DEVICE_CONFIG_ENDPOINTS << 1U]; /*!< Endpoint callback function structure */
|
||||
uint8_t deviceAddress; /*!< Current device address */
|
||||
uint8_t controllerId; /*!< Controller ID */
|
||||
uint8_t state; /*!< Current device state */
|
||||
#if ((defined(USB_DEVICE_CONFIG_REMOTE_WAKEUP)) && (USB_DEVICE_CONFIG_REMOTE_WAKEUP > 0U))
|
||||
uint8_t remotewakeup; /*!< Remote wakeup is enabled or not */
|
||||
#endif
|
||||
uint8_t isResetting; /*!< Is doing device reset or not */
|
||||
#if (defined(USB_DEVICE_CONFIG_USE_TASK) && (USB_DEVICE_CONFIG_USE_TASK > 0U))
|
||||
uint8_t epCallbackDirectly; /*!< Whether call ep callback directly when the task is enabled */
|
||||
#endif
|
||||
} usb_device_struct_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* __USB_DEVICE_DCI_H__ */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _USB_HOST_DEV_MNG_H_
|
||||
#define _USB_HOST_DEV_MNG_H_
|
||||
|
||||
#include "usb_host.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/*!
|
||||
* @addtogroup usb_host_drv
|
||||
* @{
|
||||
*/
|
||||
/*! @brief States of device instances enumeration */
|
||||
typedef enum _usb_host_device_enumeration_status
|
||||
{
|
||||
kStatus_DEV_Notinit = 0, /*!< Device is invalid */
|
||||
kStatus_DEV_Initial, /*!< Device has been processed by host driver */
|
||||
kStatus_DEV_GetDes8, /*!< Enumeration process: get 8 bytes' device descriptor */
|
||||
kStatus_DEV_SetAddress, /*!< Enumeration process: set device address */
|
||||
kStatus_DEV_GetDes, /*!< Enumeration process: get device descriptor */
|
||||
kStatus_DEV_GetCfg9, /*!< Enumeration process: get 9 bytes' configuration descriptor */
|
||||
kStatus_DEV_GetCfg, /*!< Enumeration process: get configuration descriptor */
|
||||
kStatus_DEV_SetCfg, /*!< Enumeration process: set configuration */
|
||||
kStatus_DEV_EnumDone, /*!< Enumeration is done */
|
||||
kStatus_DEV_AppUsed, /*!< This device has been used by application */
|
||||
} usb_host_device_enumeration_status_t;
|
||||
|
||||
/*! @brief States of device's interface */
|
||||
typedef enum _usb_host_interface_state
|
||||
{
|
||||
kStatus_interface_Attached = 1, /*!< Interface's default status */
|
||||
kStatus_interface_Opened, /*!< Interface is used by application */
|
||||
kStatus_interface_Detached, /*!< Interface is not used by application */
|
||||
} usb_host_interface_state_t;
|
||||
|
||||
/*! @brief States of device */
|
||||
typedef enum _usb_host_device_state
|
||||
{
|
||||
kStatus_device_Detached = 0, /*!< Device is used by application */
|
||||
kStatus_device_Attached, /*!< Device's default status */
|
||||
} usb_host_device_state_t;
|
||||
|
||||
/*! @brief Device instance */
|
||||
typedef struct _usb_host_device_instance
|
||||
{
|
||||
struct _usb_host_device_instance *next; /*!< Next device, or NULL */
|
||||
usb_host_handle hostHandle; /*!< Host handle */
|
||||
usb_host_configuration_t configuration; /*!< Parsed configuration information for the device */
|
||||
usb_descriptor_device_t *deviceDescriptor; /*!< Standard device descriptor */
|
||||
usb_host_pipe_handle controlPipe; /*!< Device's control pipe */
|
||||
uint8_t *configurationDesc; /*!< Configuration descriptor pointer */
|
||||
uint16_t configurationLen; /*!< Configuration descriptor length */
|
||||
uint16_t configurationValue; /*!< Configuration index */
|
||||
uint8_t interfaceStatus[USB_HOST_CONFIG_CONFIGURATION_MAX_INTERFACE]; /*!< Interfaces' status, please reference to
|
||||
#usb_host_interface_state_t */
|
||||
uint8_t *enumBuffer; /*!< Buffer for enumeration */
|
||||
uint8_t state; /*!< Device state for enumeration */
|
||||
uint8_t enumRetries; /*!< Re-enumeration when error in control transfer */
|
||||
uint8_t stallRetries; /*!< Re-transfer when stall */
|
||||
uint8_t speed; /*!< Device speed */
|
||||
uint8_t allocatedAddress; /*!< Temporary address for the device. When set address request succeeds, setAddress is
|
||||
a value, 1 - 127 */
|
||||
uint8_t setAddress; /*!< The address has been set to the device successfully, 1 - 127 */
|
||||
uint8_t deviceAttachState; /*!< See the usb_host_device_state_t */
|
||||
#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))
|
||||
/* hub related */
|
||||
uint8_t hubNumber; /*!< Device's first connected hub address (root hub = 0) */
|
||||
uint8_t portNumber; /*!< Device's first connected hub's port no (1 - 8) */
|
||||
uint8_t hsHubNumber; /*!< Device's first connected high-speed hub's address (1 - 8) */
|
||||
uint8_t hsHubPort; /*!< Device's first connected high-speed hub's port no (1 - 8) */
|
||||
uint8_t level; /*!< Device's level (root device = 0) */
|
||||
#endif
|
||||
} usb_host_device_instance_t;
|
||||
|
||||
typedef struct _usb_host_enum_process_entry
|
||||
{
|
||||
uint8_t successState; /*!< When the last step is successful, the next state value */
|
||||
uint8_t retryState; /*!< When the last step need retry, the next state value */
|
||||
usb_status_t (*process)(usb_host_device_instance_t *deviceInstance); /*!< When the last step transfer is done, the
|
||||
function is used to process the transfer
|
||||
data */
|
||||
} usb_host_enum_process_entry_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @brief Calls this function when device attach.
|
||||
*
|
||||
* @param hostHandle Host instance handle.
|
||||
* @param speed Device speed.
|
||||
* @param hubNumber Device hub no. root device's hub no. is 0.
|
||||
* @param portNumber Device port no. root device's port no. is 0.
|
||||
* @param level Device level. root device's level is 1.
|
||||
* @param deviceHandle Return device handle.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
extern usb_status_t USB_HostAttachDevice(usb_host_handle hostHandle,
|
||||
uint8_t speed,
|
||||
uint8_t hubNumber,
|
||||
uint8_t portNumber,
|
||||
uint8_t level,
|
||||
usb_device_handle *deviceHandle);
|
||||
|
||||
/*!
|
||||
* @brief Call this function when device detaches.
|
||||
*
|
||||
* @param hostHandle Host instance handle.
|
||||
* @param hubNumber Device hub no. root device's hub no. is 0.
|
||||
* @param portNumber Device port no. root device's port no. is 0.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
extern usb_status_t USB_HostDetachDevice(usb_host_handle hostHandle, uint8_t hubNumber, uint8_t portNumber);
|
||||
|
||||
/*!
|
||||
* @brief Call this function when device detaches.
|
||||
*
|
||||
* @param hostHandle Host instance handle.
|
||||
* @param deviceHandle Device handle.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
extern usb_status_t USB_HostDetachDeviceInternal(usb_host_handle hostHandle, usb_device_handle deviceHandle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the device attach/detach state.
|
||||
*
|
||||
* @param deviceHandle Device handle.
|
||||
*
|
||||
* @return 0x01 - attached; 0x00 - detached.
|
||||
*/
|
||||
extern uint8_t USB_HostGetDeviceAttachState(usb_device_handle deviceHandle);
|
||||
|
||||
/*!
|
||||
* @brief Determine whether the device is attached.
|
||||
*
|
||||
* @param hostHandle Host instance pointer.
|
||||
* @param deviceHandle Device handle.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
extern usb_status_t USB_HostValidateDevice(usb_host_handle hostHandle, usb_device_handle deviceHandle);
|
||||
|
||||
/*! @}*/
|
||||
#endif /* _USB_HOST_DEV_MNG_H_ */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _USB_HOST_HCI_H_
|
||||
#define _USB_HOST_HCI_H_
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief USB host lock */
|
||||
#define USB_HostLock() USB_OsaMutexLock(hostInstance->hostMutex)
|
||||
/*! @brief USB host unlock */
|
||||
#define USB_HostUnlock() USB_OsaMutexUnlock(hostInstance->hostMutex)
|
||||
|
||||
/*!
|
||||
* @addtogroup usb_host_controller_driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @brief USB host controller control code */
|
||||
typedef enum _usb_host_controller_control
|
||||
{
|
||||
kUSB_HostCancelTransfer = 1U, /*!< Cancel transfer code */
|
||||
kUSB_HostBusControl, /*!< Bus control code */
|
||||
kUSB_HostGetFrameNumber, /*!< Get frame number code */
|
||||
kUSB_HostUpdateControlEndpointAddress, /*!< Update control endpoint address */
|
||||
kUSB_HostUpdateControlPacketSize, /*!< Update control endpoint maximum packet size */
|
||||
kUSB_HostPortAttachDisable, /*!< Disable the port attach event */
|
||||
kUSB_HostPortAttachEnable, /*!< Enable the port attach event */
|
||||
kUSB_HostL1Config, /*!< L1 suspend Bus control code */
|
||||
} usb_host_controller_control_t;
|
||||
|
||||
/*! @brief USB host controller bus control code */
|
||||
typedef enum _usb_host_bus_control
|
||||
{
|
||||
kUSB_HostBusReset = 1U, /*!< Reset bus */
|
||||
kUSB_HostBusRestart, /*!< Restart bus */
|
||||
kUSB_HostBusEnableAttach, /*!< Enable attach */
|
||||
kUSB_HostBusDisableAttach, /*!< Disable attach */
|
||||
kUSB_HostBusSuspend, /*!< Suspend BUS */
|
||||
kUSB_HostBusResume, /*!< Resume BUS */
|
||||
kUSB_HostBusL1SuspendInit, /*!< L1 Suspend BUS */
|
||||
kUSB_HostBusL1Sleep, /*!< L1 Suspend BUS */
|
||||
kUSB_HostBusL1Resume, /*!< L1 Resume BUS */
|
||||
} usb_host_bus_control_t;
|
||||
|
||||
/*! @brief USB host controller interface structure */
|
||||
typedef struct _usb_host_controller_interface
|
||||
{
|
||||
usb_status_t (*controllerCreate)(
|
||||
uint8_t controllerId,
|
||||
usb_host_handle upperLayerHandle,
|
||||
usb_host_controller_handle *controllerHandle); /*!< Create a controller instance function prototype*/
|
||||
usb_status_t (*controllerDestory)(
|
||||
usb_host_controller_handle controllerHandle); /*!< Destroy a controller instance function prototype*/
|
||||
usb_status_t (*controllerOpenPipe)(usb_host_controller_handle controllerHandle,
|
||||
usb_host_pipe_handle *pipeHandle,
|
||||
usb_host_pipe_init_t *pipeInit); /*!< Open a controller pipe function prototype*/
|
||||
usb_status_t (*controllerClosePipe)(
|
||||
usb_host_controller_handle controllerHandle,
|
||||
usb_host_pipe_handle pipeHandle); /*!< Close a controller pipe function prototype*/
|
||||
usb_status_t (*controllerWritePipe)(usb_host_controller_handle controllerHandle,
|
||||
usb_host_pipe_handle pipeHandle,
|
||||
usb_host_transfer_t *transfer); /*!< Write data to a pipe function prototype*/
|
||||
usb_status_t (*controllerReadPipe)(usb_host_controller_handle controllerHandle,
|
||||
usb_host_pipe_handle pipeHandle,
|
||||
usb_host_transfer_t *transfer); /*!< Read data from a pipe function prototype*/
|
||||
usb_status_t (*controllerIoctl)(usb_host_controller_handle controllerHandle,
|
||||
uint32_t ioctlEvent,
|
||||
void *ioctlParam); /*!< Control a controller function prototype*/
|
||||
} usb_host_controller_interface_t;
|
||||
|
||||
/*! @}*/
|
||||
|
||||
/*!
|
||||
* @addtogroup usb_host_drv
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @brief USB host instance structure */
|
||||
typedef struct _usb_host_instance
|
||||
{
|
||||
void *controllerHandle; /*!< The low level controller handle*/
|
||||
host_callback_t deviceCallback; /*!< Device attach/detach callback*/
|
||||
usb_osa_mutex_handle hostMutex; /*!< Host layer mutex*/
|
||||
usb_host_transfer_t transferList[USB_HOST_CONFIG_MAX_TRANSFERS]; /*!< Transfer resource*/
|
||||
usb_host_transfer_t *transferHead; /*!< Idle transfer head*/
|
||||
const usb_host_controller_interface_t *controllerTable; /*!< KHCI/EHCI interface*/
|
||||
void *deviceList; /*!< Device list*/
|
||||
#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
|
||||
void *suspendedDevice; /*!< Suspended device handle*/
|
||||
volatile uint64_t hwTick; /*!< Current hw tick(ms)*/
|
||||
uint8_t sleepType; /*!< L1 LPM device handle*/
|
||||
#endif
|
||||
uint8_t addressBitMap[16]; /*!< Used for address allocation. The first bit is the address 1, second bit is the
|
||||
address 2*/
|
||||
uint8_t occupied; /*!< 0 - the instance is not occupied; 1 - the instance is occupied*/
|
||||
uint8_t controllerId; /*!< The controller ID*/
|
||||
} usb_host_instance_t;
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _USB_HOST_HCI_H_ */
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __USB_H__
|
||||
#define __USB_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <fsl_common.h>
|
||||
#include "usb_misc.h"
|
||||
#include "usb_spec.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup usb_drv
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/*! @brief Defines USB stack major version */
|
||||
#define USB_STACK_VERSION_MAJOR (1U)
|
||||
/*! @brief Defines USB stack minor version */
|
||||
#define USB_STACK_VERSION_MINOR (6U)
|
||||
/*! @brief Defines USB stack bugfix version */
|
||||
#define USB_STACK_VERSION_BUGFIX (3U)
|
||||
|
||||
/*! @brief USB stack version definition */
|
||||
#define USB_MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
|
||||
|
||||
/*! @brief USB error code */
|
||||
typedef enum _usb_status
|
||||
{
|
||||
kStatus_USB_Success = 0x00U, /*!< Success */
|
||||
kStatus_USB_Error, /*!< Failed */
|
||||
|
||||
kStatus_USB_Busy, /*!< Busy */
|
||||
kStatus_USB_InvalidHandle, /*!< Invalid handle */
|
||||
kStatus_USB_InvalidParameter, /*!< Invalid parameter */
|
||||
kStatus_USB_InvalidRequest, /*!< Invalid request */
|
||||
kStatus_USB_ControllerNotFound, /*!< Controller cannot be found */
|
||||
kStatus_USB_InvalidControllerInterface, /*!< Invalid controller interface */
|
||||
|
||||
kStatus_USB_NotSupported, /*!< Configuration is not supported */
|
||||
kStatus_USB_Retry, /*!< Enumeration get configuration retry */
|
||||
kStatus_USB_TransferStall, /*!< Transfer stalled */
|
||||
kStatus_USB_TransferFailed, /*!< Transfer failed */
|
||||
kStatus_USB_AllocFail, /*!< Allocation failed */
|
||||
kStatus_USB_LackSwapBuffer, /*!< Insufficient swap buffer for KHCI */
|
||||
kStatus_USB_TransferCancel, /*!< The transfer cancelled */
|
||||
kStatus_USB_BandwidthFail, /*!< Allocate bandwidth failed */
|
||||
kStatus_USB_MSDStatusFail, /*!< For MSD, the CSW status means fail */
|
||||
kStatus_USB_EHCIAttached,
|
||||
kStatus_USB_EHCIDetached,
|
||||
} usb_status_t;
|
||||
|
||||
/*! @brief USB host handle type define */
|
||||
typedef void *usb_host_handle;
|
||||
|
||||
/*! @brief USB device handle type define. For device stack it is the whole device handle; for host stack it is the
|
||||
* attached device instance handle*/
|
||||
typedef void *usb_device_handle;
|
||||
|
||||
/*! @brief USB OTG handle type define */
|
||||
typedef void *usb_otg_handle;
|
||||
|
||||
/*! @brief USB controller ID */
|
||||
typedef enum _usb_controller_index
|
||||
{
|
||||
kUSB_ControllerKhci0 = 0U, /*!< KHCI 0U */
|
||||
kUSB_ControllerKhci1 = 1U, /*!< KHCI 1U, Currently, there are no platforms which have two KHCI IPs, this is reserved
|
||||
to be used in the future. */
|
||||
kUSB_ControllerEhci0 = 2U, /*!< EHCI 0U */
|
||||
kUSB_ControllerEhci1 = 3U, /*!< EHCI 1U, Currently, there are no platforms which have two EHCI IPs, this is reserved
|
||||
to be used in the future. */
|
||||
|
||||
kUSB_ControllerLpcIp3511Fs0 = 4U, /*!< LPC USB IP3511 FS controller 0 */
|
||||
kUSB_ControllerLpcIp3511Fs1 =
|
||||
5U, /*!< LPC USB IP3511 FS controller 1, there are no platforms which have two IP3511 IPs, this is reserved
|
||||
to be used in the future. */
|
||||
|
||||
kUSB_ControllerLpcIp3511Hs0 = 6U, /*!< LPC USB IP3511 HS controller 0 */
|
||||
kUSB_ControllerLpcIp3511Hs1 =
|
||||
7U, /*!< LPC USB IP3511 HS controller 1, there are no platforms which have two IP3511 IPs, this is reserved
|
||||
to be used in the future. */
|
||||
|
||||
kUSB_ControllerOhci0 = 8U, /*!< OHCI 0U */
|
||||
kUSB_ControllerOhci1 = 9U, /*!< OHCI 1U, Currently, there are no platforms which have two OHCI IPs, this is reserved
|
||||
to be used in the future. */
|
||||
|
||||
kUSB_ControllerIp3516Hs0 = 10U, /*!< IP3516HS 0U */
|
||||
kUSB_ControllerIp3516Hs1 =
|
||||
11U, /*!< IP3516HS 1U, Currently, there are no platforms which have two IP3516HS IPs, this is reserved
|
||||
to be used in the future. */
|
||||
} usb_controller_index_t;
|
||||
|
||||
/**
|
||||
* @brief USB stack version fields
|
||||
*/
|
||||
typedef struct _usb_version
|
||||
{
|
||||
uint8_t major; /*!< Major */
|
||||
uint8_t minor; /*!< Minor */
|
||||
uint8_t bugfix; /*!< Bug fix */
|
||||
} usb_version_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif /* __USB_H__ */
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 - 2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _USB_DEVICE_CONFIG_H_
|
||||
#define _USB_DEVICE_CONFIG_H_
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/*!
|
||||
* @addtogroup usb_device_configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @name Hardware instance define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @brief KHCI instance count */
|
||||
#define USB_DEVICE_CONFIG_KHCI (0U)
|
||||
|
||||
/*! @brief EHCI instance count */
|
||||
#define USB_DEVICE_CONFIG_EHCI (2U)
|
||||
|
||||
/*! @brief LPC USB IP3511 FS instance count */
|
||||
#define USB_DEVICE_CONFIG_LPCIP3511FS (0U)
|
||||
|
||||
/*! @brief LPC USB IP3511 HS instance count */
|
||||
#define USB_DEVICE_CONFIG_LPCIP3511HS (0U)
|
||||
|
||||
/*! @brief Device instance count, the sum of KHCI and EHCI instance counts*/
|
||||
#define USB_DEVICE_CONFIG_NUM \
|
||||
(USB_DEVICE_CONFIG_KHCI + USB_DEVICE_CONFIG_EHCI + USB_DEVICE_CONFIG_LPCIP3511FS + USB_DEVICE_CONFIG_LPCIP3511HS)
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name class instance define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @brief HID instance count */
|
||||
#define USB_DEVICE_CONFIG_HID (0U)
|
||||
|
||||
/*! @brief CDC ACM instance count */
|
||||
#define USB_DEVICE_CONFIG_CDC_ACM (1U)
|
||||
|
||||
/*! @brief MSC instance count */
|
||||
#define USB_DEVICE_CONFIG_MSC (0U)
|
||||
|
||||
/*! @brief Audio instance count */
|
||||
#define USB_DEVICE_CONFIG_AUDIO (0U)
|
||||
|
||||
/*! @brief PHDC instance count */
|
||||
#define USB_DEVICE_CONFIG_PHDC (0U)
|
||||
|
||||
/*! @brief Video instance count */
|
||||
#define USB_DEVICE_CONFIG_VIDEO (0U)
|
||||
|
||||
/*! @brief CCID instance count */
|
||||
#define USB_DEVICE_CONFIG_CCID (0U)
|
||||
|
||||
/*! @brief Printer instance count */
|
||||
#define USB_DEVICE_CONFIG_PRINTER (0U)
|
||||
|
||||
/*! @brief DFU instance count */
|
||||
#define USB_DEVICE_CONFIG_DFU (0U)
|
||||
|
||||
/* @} */
|
||||
|
||||
/*! @brief Whether device is self power. 1U supported, 0U not supported */
|
||||
#define USB_DEVICE_CONFIG_SELF_POWER (1U)
|
||||
|
||||
/*! @brief How many endpoints are supported in the stack. */
|
||||
#define USB_DEVICE_CONFIG_ENDPOINTS (4U)
|
||||
|
||||
/*! @brief Whether the device task is enabled. */
|
||||
#define USB_DEVICE_CONFIG_USE_TASK (0U)
|
||||
|
||||
/*! @brief How many the notification message are supported when the device task is enabled. */
|
||||
#define USB_DEVICE_CONFIG_MAX_MESSAGES (8U)
|
||||
|
||||
/*! @brief Whether test mode enabled. */
|
||||
#define USB_DEVICE_CONFIG_USB20_TEST_MODE (0U)
|
||||
|
||||
/*! @brief Whether device CV test is enabled. */
|
||||
#define USB_DEVICE_CONFIG_CV_TEST (0U)
|
||||
|
||||
/*! @brief Whether device compliance test is enabled. If the macro is enabled,
|
||||
the test mode and CV test macroes will be set.*/
|
||||
#define USB_DEVICE_CONFIG_COMPLIANCE_TEST (0U)
|
||||
|
||||
#if ((defined(USB_DEVICE_CONFIG_COMPLIANCE_TEST)) && (USB_DEVICE_CONFIG_COMPLIANCE_TEST > 0U))
|
||||
|
||||
/*! @brief Undefine the marco USB_DEVICE_CONFIG_USB20_TEST_MODE. */
|
||||
#undef USB_DEVICE_CONFIG_USB20_TEST_MODE
|
||||
/*! @brief Undefine the marco USB_DEVICE_CONFIG_CV_TEST. */
|
||||
#undef USB_DEVICE_CONFIG_CV_TEST
|
||||
|
||||
/*! @brief enable the test mode. */
|
||||
#define USB_DEVICE_CONFIG_USB20_TEST_MODE (1U)
|
||||
|
||||
/*! @brief enable the CV test */
|
||||
#define USB_DEVICE_CONFIG_CV_TEST (1U)
|
||||
|
||||
#endif
|
||||
|
||||
#if ((defined(USB_DEVICE_CONFIG_KHCI)) && (USB_DEVICE_CONFIG_KHCI > 0U))
|
||||
|
||||
/*! @brief The MAX buffer length for the KHCI DMA workaround.*/
|
||||
#define USB_DEVICE_CONFIG_KHCI_DMA_ALIGN_BUFFER_LENGTH (64U)
|
||||
#endif
|
||||
|
||||
#if ((defined(USB_DEVICE_CONFIG_EHCI)) && (USB_DEVICE_CONFIG_EHCI > 0U))
|
||||
/*! @brief How many the DTD are supported. */
|
||||
#define USB_DEVICE_CONFIG_EHCI_MAX_DTD (16U)
|
||||
|
||||
/*! @brief Whether the EHCI ID pin detect feature enabled. */
|
||||
#define USB_DEVICE_CONFIG_EHCI_ID_PIN_DETECT (0U)
|
||||
#endif
|
||||
|
||||
/*! @brief Whether the keep alive feature enabled. */
|
||||
#define USB_DEVICE_CONFIG_KEEP_ALIVE_MODE (0U)
|
||||
|
||||
/*! @brief Whether the transfer buffer is cache-enabled or not. */
|
||||
#define USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE (1U)
|
||||
|
||||
/*! @brief Whether the low power mode is enabled or not. */
|
||||
#define USB_DEVICE_CONFIG_LOW_POWER_MODE (0U)
|
||||
|
||||
#if ((defined(USB_DEVICE_CONFIG_LOW_POWER_MODE)) && (USB_DEVICE_CONFIG_LOW_POWER_MODE > 0U))
|
||||
/*! @brief Whether device remote wakeup supported. 1U supported, 0U not supported */
|
||||
#define USB_DEVICE_CONFIG_REMOTE_WAKEUP (0U)
|
||||
|
||||
/*! @brief Whether LPM is supported. 1U supported, 0U not supported */
|
||||
#define USB_DEVICE_CONFIG_LPM_L1 (0U)
|
||||
#else
|
||||
/*! @brief The device remote wakeup is unsupported. */
|
||||
#define USB_DEVICE_CONFIG_REMOTE_WAKEUP (0U)
|
||||
#endif
|
||||
|
||||
/*! @brief Whether the device detached feature is enabled or not. */
|
||||
#define USB_DEVICE_CONFIG_DETACH_ENABLE (0U)
|
||||
|
||||
/*! @brief Whether handle the USB bus error. */
|
||||
#define USB_DEVICE_CONFIG_ERROR_HANDLING (0U)
|
||||
|
||||
/* @} */
|
||||
/*! @brief rt-thread port alloc */
|
||||
#include <rtthread.h>
|
||||
#define USB_OSA_SR_ALLOC(...)
|
||||
/*! @brief rt-thread port enter critical */
|
||||
#define USB_OSA_ENTER_CRITICAL rt_enter_critical
|
||||
/*! @brief rt-thread port exit critical */
|
||||
#define USB_OSA_EXIT_CRITICAL rt_exit_critical
|
||||
|
||||
#endif /* _USB_DEVICE_CONFIG_H_ */
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __USB_EHCI_H__
|
||||
#define __USB_EHCI_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Device QH */
|
||||
#define USB_DEVICE_EHCI_QH_POINTER_MASK (0xFFFFFFC0U)
|
||||
#define USB_DEVICE_EHCI_QH_MULT_MASK (0xC0000000U)
|
||||
#define USB_DEVICE_EHCI_QH_ZLT_MASK (0x20000000U)
|
||||
#define USB_DEVICE_EHCI_QH_MAX_PACKET_SIZE_MASK (0x07FF0000U)
|
||||
#define USB_DEVICE_EHCI_QH_MAX_PACKET_SIZE (0x00000800U)
|
||||
#define USB_DEVICE_EHCI_QH_IOS_MASK (0x00008000U)
|
||||
|
||||
/* Device DTD */
|
||||
#define USB_DEVICE_ECHI_DTD_POINTER_MASK (0xFFFFFFE0U)
|
||||
#define USB_DEVICE_ECHI_DTD_TERMINATE_MASK (0x00000001U)
|
||||
#define USB_DEVICE_ECHI_DTD_PAGE_MASK (0xFFFFF000U)
|
||||
#define USB_DEVICE_ECHI_DTD_PAGE_OFFSET_MASK (0x00000FFFU)
|
||||
#define USB_DEVICE_ECHI_DTD_PAGE_BLOCK (0x00001000U)
|
||||
#define USB_DEVICE_ECHI_DTD_TOTAL_BYTES_MASK (0x7FFF0000U)
|
||||
#define USB_DEVICE_ECHI_DTD_TOTAL_BYTES (0x00004000U)
|
||||
#define USB_DEVICE_ECHI_DTD_IOC_MASK (0x00008000U)
|
||||
#define USB_DEVICE_ECHI_DTD_MULTIO_MASK (0x00000C00U)
|
||||
#define USB_DEVICE_ECHI_DTD_STATUS_MASK (0x000000FFU)
|
||||
#define USB_DEVICE_EHCI_DTD_STATUS_ERROR_MASK (0x00000068U)
|
||||
#define USB_DEVICE_ECHI_DTD_STATUS_ACTIVE (0x00000080U)
|
||||
#define USB_DEVICE_ECHI_DTD_STATUS_HALTED (0x00000040U)
|
||||
#define USB_DEVICE_ECHI_DTD_STATUS_DATA_BUFFER_ERROR (0x00000020U)
|
||||
#define USB_DEVICE_ECHI_DTD_STATUS_TRANSACTION_ERROR (0x00000008U)
|
||||
|
||||
typedef struct _usb_device_ehci_qh_struct
|
||||
{
|
||||
union
|
||||
{
|
||||
volatile uint32_t capabilttiesCharacteristics;
|
||||
struct
|
||||
{
|
||||
volatile uint32_t reserved1 : 15;
|
||||
volatile uint32_t ios : 1;
|
||||
volatile uint32_t maxPacketSize : 11;
|
||||
volatile uint32_t reserved2 : 2;
|
||||
volatile uint32_t zlt : 1;
|
||||
volatile uint32_t mult : 2;
|
||||
} capabilttiesCharacteristicsBitmap;
|
||||
} capabilttiesCharacteristicsUnion;
|
||||
volatile uint32_t currentDtdPointer;
|
||||
volatile uint32_t nextDtdPointer;
|
||||
union
|
||||
{
|
||||
volatile uint32_t dtdToken;
|
||||
struct
|
||||
{
|
||||
volatile uint32_t status : 8;
|
||||
volatile uint32_t reserved1 : 2;
|
||||
volatile uint32_t multiplierOverride : 2;
|
||||
volatile uint32_t reserved2 : 3;
|
||||
volatile uint32_t ioc : 1;
|
||||
volatile uint32_t totalBytes : 15;
|
||||
volatile uint32_t reserved3 : 1;
|
||||
} dtdTokenBitmap;
|
||||
} dtdTokenUnion;
|
||||
volatile uint32_t bufferPointerPage[5];
|
||||
volatile uint32_t reserved1;
|
||||
uint32_t setupBuffer[2];
|
||||
uint32_t setupBufferBack[2];
|
||||
union
|
||||
{
|
||||
uint32_t endpointStatus;
|
||||
struct
|
||||
{
|
||||
uint32_t isOpened : 1;
|
||||
uint32_t : 31;
|
||||
} endpointStatusBitmap;
|
||||
} endpointStatusUnion;
|
||||
uint32_t reserved2;
|
||||
} usb_device_ehci_qh_struct_t;
|
||||
|
||||
typedef struct _usb_device_ehci_dtd_struct
|
||||
{
|
||||
volatile uint32_t nextDtdPointer;
|
||||
union
|
||||
{
|
||||
volatile uint32_t dtdToken;
|
||||
struct
|
||||
{
|
||||
volatile uint32_t status : 8;
|
||||
volatile uint32_t reserved1 : 2;
|
||||
volatile uint32_t multiplierOverride : 2;
|
||||
volatile uint32_t reserved2 : 3;
|
||||
volatile uint32_t ioc : 1;
|
||||
volatile uint32_t totalBytes : 15;
|
||||
volatile uint32_t reserved3 : 1;
|
||||
} dtdTokenBitmap;
|
||||
} dtdTokenUnion;
|
||||
volatile uint32_t bufferPointerPage[5];
|
||||
union
|
||||
{
|
||||
volatile uint32_t reserved;
|
||||
struct
|
||||
{
|
||||
uint32_t originalBufferOffest : 12;
|
||||
uint32_t originalBufferLength : 19;
|
||||
uint32_t dtdInvalid : 1;
|
||||
} originalBufferInfo;
|
||||
} reservedUnion;
|
||||
} usb_device_ehci_dtd_struct_t;
|
||||
|
||||
#endif /* __USB_EHCI_H__ */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 - 2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __USB_PHY_H__
|
||||
#define __USB_PHY_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
typedef struct _usb_phy_config_struct
|
||||
{
|
||||
uint8_t D_CAL; /* Decode to trim the nominal 17.78mA current source */
|
||||
uint8_t TXCAL45DP; /* Decode to trim the nominal 45-Ohm series termination resistance to the USB_DP output pin */
|
||||
uint8_t TXCAL45DM; /* Decode to trim the nominal 45-Ohm series termination resistance to the USB_DM output pin */
|
||||
} usb_phy_config_struct_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
/*!
|
||||
* @brief EHCI PHY get USB phy bass address.
|
||||
*
|
||||
* This function is used to get USB phy bass address.
|
||||
*
|
||||
* @param[in] controllerId EHCI controller ID; See the #usb_controller_index_t.
|
||||
*
|
||||
* @retval USB phy bass address.
|
||||
*/
|
||||
extern void *USB_EhciPhyGetBase(uint8_t controllerId);
|
||||
|
||||
/*!
|
||||
* @brief EHCI PHY initialization.
|
||||
*
|
||||
* This function initializes the EHCI PHY IP.
|
||||
*
|
||||
* @param[in] controllerId EHCI controller ID; See the #usb_controller_index_t.
|
||||
* @param[in] freq The external input clock.
|
||||
*
|
||||
* @retval kStatus_USB_Success Cancel successfully.
|
||||
* @retval kStatus_USB_Error The freq value is incorrect.
|
||||
*/
|
||||
extern uint32_t USB_EhciPhyInit(uint8_t controllerId, uint32_t freq, usb_phy_config_struct_t *phyConfig);
|
||||
|
||||
/*!
|
||||
* @brief ehci phy initialization for suspend and resume.
|
||||
*
|
||||
* This function initialize ehci phy IP for suspend and resume.
|
||||
*
|
||||
* @param[in] controllerId ehci controller id, please reference to #usb_controller_index_t.
|
||||
* @param[in] freq the external input clock.
|
||||
* for example: if the external input clock is 16M, the parameter freq should be 16000000.
|
||||
*
|
||||
* @retval kStatus_USB_Success cancel successfully.
|
||||
* @retval kStatus_USB_Error the freq value is incorrect.
|
||||
*/
|
||||
extern uint32_t USB_EhciLowPowerPhyInit(uint8_t controllerId, uint32_t freq, usb_phy_config_struct_t *phyConfig);
|
||||
|
||||
/*!
|
||||
* @brief EHCI PHY deinitialization.
|
||||
*
|
||||
* This function deinitializes the EHCI PHY IP.
|
||||
*
|
||||
* @param[in] controllerId EHCI controller ID; See #usb_controller_index_t.
|
||||
*/
|
||||
extern void USB_EhciPhyDeinit(uint8_t controllerId);
|
||||
|
||||
/*!
|
||||
* @brief EHCI PHY disconnect detection enable or disable.
|
||||
*
|
||||
* This function enable/disable the host EHCI disconnect detection.
|
||||
*
|
||||
* @param[in] controllerId EHCI controller ID; See #usb_controller_index_t.
|
||||
* @param[in] enable
|
||||
* 1U - enable;
|
||||
* 0U - disable;
|
||||
*/
|
||||
extern void USB_EhcihostPhyDisconnectDetectCmd(uint8_t controllerId, uint8_t enable);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USB_PHY_H__ */
|
||||
Reference in new issue
Block a user