|
@@ -1,12 +1,34 @@
|
|
|
/*
|
|
|
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
|
|
- * Copyright 2016 - 2019 NXP
|
|
|
- * All rights reserved.
|
|
|
+ * Copyright 2016 NXP
|
|
|
*
|
|
|
- * SPDX-License-Identifier: BSD-3-Clause
|
|
|
+ * 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.
|
|
|
*/
|
|
|
|
|
|
-#include <usb/include/usb_host_config.h>
|
|
|
+#include <usb/include/usb_device_config.h>
|
|
|
#include "fsl_common.h"
|
|
|
#include "usb_host.h"
|
|
|
#include "usb_host_hci.h"
|
|
@@ -20,24 +42,16 @@
|
|
|
* Definitions
|
|
|
******************************************************************************/
|
|
|
|
|
|
-/* Component ID definition, used by tools. */
|
|
|
-#ifndef FSL_COMPONENT_ID
|
|
|
-#define FSL_COMPONENT_ID "middleware.usb.host_stack"
|
|
|
-#endif
|
|
|
-
|
|
|
-#if defined __CORTEX_M && (__CORTEX_M == 7U)
|
|
|
-#if (defined(USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE > 0U))
|
|
|
-#warning USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE is not supported.
|
|
|
-#endif
|
|
|
-#endif
|
|
|
-
|
|
|
/*******************************************************************************
|
|
|
* Prototypes
|
|
|
******************************************************************************/
|
|
|
#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))
|
|
|
|
|
|
-#include "usb_host_hub.h"
|
|
|
-#include "usb_host_hub_app.h"
|
|
|
+extern uint32_t USB_HostHubGetTotalThinkTime(usb_host_handle hostHandle, uint8_t parentHubNo);
|
|
|
+
|
|
|
+extern usb_status_t USB_HostHubSuspendDevice(usb_host_handle hostHandle);
|
|
|
+
|
|
|
+extern usb_status_t USB_HostHubResumeDevice(usb_host_handle hostHandle);
|
|
|
#endif
|
|
|
|
|
|
/*!
|
|
@@ -63,6 +77,15 @@ static void USB_HostReleaseInstance(usb_host_instance_t *hostInstance);
|
|
|
static void USB_HostGetControllerInterface(uint8_t controllerId,
|
|
|
const usb_host_controller_interface_t **controllerTable);
|
|
|
|
|
|
+#if ((defined USB_HOST_CONFIG_COMPLIANCE_TEST) && (USB_HOST_CONFIG_COMPLIANCE_TEST))
|
|
|
+#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI))
|
|
|
+extern void USB_HostEhciTestModeInit(usb_device_handle devHandle);
|
|
|
+#endif /* USB_HOST_CONFIG_COMPLIANCE_TEST */
|
|
|
+#if ((defined USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS))
|
|
|
+extern void USB_HostIp3516HsTestModeInit(usb_device_handle devHandle);
|
|
|
+#endif /* USB_HOST_CONFIG_COMPLIANCE_TEST */
|
|
|
+#endif /* USB_HOST_CONFIG_EHCI */
|
|
|
+
|
|
|
/*******************************************************************************
|
|
|
* Variables
|
|
|
******************************************************************************/
|
|
@@ -71,7 +94,8 @@ usb_host_instance_t g_UsbHostInstance[USB_HOST_CONFIG_MAX_HOST];
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI))
|
|
|
#include "usb_host_ehci.h"
|
|
|
-static const usb_host_controller_interface_t s_EhciInterface = {
|
|
|
+static const usb_host_controller_interface_t s_EhciInterface = \
|
|
|
+{
|
|
|
USB_HostEhciCreate, USB_HostEhciDestory, USB_HostEhciOpenPipe, USB_HostEhciClosePipe,
|
|
|
USB_HostEhciWritePipe, USB_HostEhciReadpipe, USB_HostEhciIoctl,
|
|
|
};
|
|
@@ -79,7 +103,8 @@ static const usb_host_controller_interface_t s_EhciInterface = {
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_KHCI) && (USB_HOST_CONFIG_KHCI))
|
|
|
#include "usb_host_khci.h"
|
|
|
-static const usb_host_controller_interface_t s_KhciInterface = {
|
|
|
+static const usb_host_controller_interface_t s_KhciInterface = \
|
|
|
+{
|
|
|
USB_HostKhciCreate, USB_HostKhciDestory, USB_HostKhciOpenPipe, USB_HostKhciClosePipe,
|
|
|
USB_HostKhciWritePipe, USB_HostKhciReadpipe, USB_HostKciIoctl,
|
|
|
};
|
|
@@ -87,7 +112,8 @@ static const usb_host_controller_interface_t s_KhciInterface = {
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_OHCI) && (USB_HOST_CONFIG_OHCI > 0U))
|
|
|
#include "usb_host_ohci.h"
|
|
|
-static const usb_host_controller_interface_t s_OhciInterface = {
|
|
|
+static const usb_host_controller_interface_t s_OhciInterface = \
|
|
|
+{
|
|
|
USB_HostOhciCreate, USB_HostOhciDestory, USB_HostOhciOpenPipe, USB_HostOhciClosePipe,
|
|
|
USB_HostOhciWritePipe, USB_HostOhciReadPipe, USB_HostOhciIoctl,
|
|
|
};
|
|
@@ -95,67 +121,65 @@ static const usb_host_controller_interface_t s_OhciInterface = {
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS > 0U))
|
|
|
#include "usb_host_ip3516hs.h"
|
|
|
-static const usb_host_controller_interface_t s_Ip3516HsInterface = {
|
|
|
+static const usb_host_controller_interface_t s_Ip3516HsInterface = \
|
|
|
+{
|
|
|
USB_HostIp3516HsCreate, USB_HostIp3516HsDestory, USB_HostIp3516HsOpenPipe, USB_HostIp3516HsClosePipe,
|
|
|
USB_HostIp3516HsWritePipe, USB_HostIp3516HsReadPipe, USB_HostIp3516HsIoctl,
|
|
|
};
|
|
|
#endif /* USB_HOST_CONFIG_IP3516HS */
|
|
|
|
|
|
-USB_DMA_NONINIT_DATA_ALIGN(USB_DATA_ALIGN_SIZE)
|
|
|
-static uint8_t s_Setupbuffer[USB_HOST_CONFIG_MAX_HOST][USB_HOST_CONFIG_MAX_TRANSFERS][USB_DATA_ALIGN_SIZE_MULTIPLE(8)];
|
|
|
+USB_DMA_NONINIT_DATA_ALIGN(USB_DATA_ALIGN_SIZE) static uint8_t s_Setupbuffer[USB_HOST_CONFIG_MAX_HOST][USB_HOST_CONFIG_MAX_TRANSFERS][USB_DATA_ALIGN_SIZE_MULTIPLE(8)];
|
|
|
/*******************************************************************************
|
|
|
- * Code
|
|
|
- ******************************************************************************/
|
|
|
+* Code
|
|
|
+******************************************************************************/
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_COMPLIANCE_TEST) && (USB_HOST_CONFIG_COMPLIANCE_TEST))
|
|
|
/*FUNCTION*----------------------------------------------------------------
|
|
|
- *
|
|
|
- * Function Name : usb_test_mode_init
|
|
|
- * Returned Value : None
|
|
|
- * Comments :
|
|
|
- * This function is called by common class to initialize the class driver. It
|
|
|
- * is called in response to a select interface call by application
|
|
|
- *
|
|
|
- *END*--------------------------------------------------------------------*/
|
|
|
+*
|
|
|
+* Function Name : usb_test_mode_init
|
|
|
+* Returned Value : None
|
|
|
+* Comments :
|
|
|
+* This function is called by common class to initialize the class driver. It
|
|
|
+* is called in response to a select interface call by application
|
|
|
+*
|
|
|
+*END*--------------------------------------------------------------------*/
|
|
|
usb_status_t USB_HostTestModeInit(usb_device_handle deviceHandle)
|
|
|
{
|
|
|
#if (((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI)) || \
|
|
|
((defined USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS)))
|
|
|
usb_host_device_instance_t *deviceInstance = (usb_host_device_instance_t *)deviceHandle;
|
|
|
- usb_host_instance_t *hostInstance = (usb_host_instance_t *)deviceInstance->hostHandle;
|
|
|
+ usb_host_instance_t *hostInstance = (usb_host_instance_t *)deviceInstance->hostHandle;
|
|
|
#endif
|
|
|
uint32_t productId;
|
|
|
uint32_t vendorId;
|
|
|
|
|
|
- (void)usb_echo("usb host test init\r\n");
|
|
|
- (void)USB_HostHelperGetPeripheralInformation(deviceHandle, (uint32_t)kUSB_HostGetDevicePID, &productId);
|
|
|
- (void)USB_HostHelperGetPeripheralInformation(deviceHandle, (uint32_t)kUSB_HostGetDeviceVID, &vendorId);
|
|
|
- (void)usb_echo(" vendor id :0x%x product id:0x%x \r\n", vendorId, productId);
|
|
|
+ usb_echo("usb host test init\r\n");
|
|
|
+ USB_HostHelperGetPeripheralInformation(deviceHandle, kUSB_HostGetDevicePID, &productId);
|
|
|
+ USB_HostHelperGetPeripheralInformation(deviceHandle, kUSB_HostGetDeviceVID, &vendorId);
|
|
|
+ usb_echo(" vendor id :0x%x product id:0x%x \r\n", vendorId, productId);
|
|
|
|
|
|
- if ((productId != 0x0200U) && (productId != 0x0101U) && (productId != 0x0102U) && (productId != 0x0103U) &&
|
|
|
- (productId != 0x0104U) && (productId != 0x0105U) && (productId != 0x0106U) && (productId != 0x0107U) &&
|
|
|
- (productId != 0x0108U))
|
|
|
+ if ((productId != 0x0200U) && (productId != 0x0101) && (productId != 0x0102) && (productId != 0x0103) &&
|
|
|
+ (productId != 0x0104) && (productId != 0x0105) && (productId != 0x0106) && (productId != 0x0107) &&
|
|
|
+ (productId != 0x0108))
|
|
|
{
|
|
|
- (void)usb_echo("Unsupported Device\r\n");
|
|
|
+ usb_echo("Unsupported Device\r\n");
|
|
|
}
|
|
|
|
|
|
if (productId == 0x0200U)
|
|
|
{
|
|
|
- (void)usb_echo("PET test device attached\r\n");
|
|
|
+ usb_echo("PET test device attached\r\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI))
|
|
|
if (hostInstance->controllerTable == &s_EhciInterface)
|
|
|
{
|
|
|
- (void)hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostTestModeInit,
|
|
|
- (void *)deviceHandle);
|
|
|
+ USB_HostEhciTestModeInit(deviceHandle);
|
|
|
}
|
|
|
-#elif ((defined USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS))
|
|
|
+#elif((defined USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS))
|
|
|
if (hostInstance->controllerTable == &s_Ip3516HsInterface)
|
|
|
{
|
|
|
- (void)hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostTestModeInit,
|
|
|
- (void *)deviceHandle);
|
|
|
+ USB_HostIp3516HsTestModeInit(deviceHandle);
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
@@ -166,14 +190,13 @@ usb_status_t USB_HostTestModeInit(usb_device_handle deviceHandle)
|
|
|
|
|
|
static usb_host_instance_t *USB_HostGetInstance(void)
|
|
|
{
|
|
|
- uint8_t i = 0;
|
|
|
+ uint8_t i = 0;
|
|
|
uint32_t index = 0;
|
|
|
- void *temp;
|
|
|
- OSA_SR_ALLOC();
|
|
|
- OSA_ENTER_CRITICAL();
|
|
|
+ USB_OSA_SR_ALLOC();
|
|
|
+ USB_OSA_ENTER_CRITICAL();
|
|
|
for (; i < USB_HOST_CONFIG_MAX_HOST; i++)
|
|
|
{
|
|
|
- if (g_UsbHostInstance[i].occupied != 1U)
|
|
|
+ if (g_UsbHostInstance[i].occupied != 1)
|
|
|
{
|
|
|
uint8_t *buffer = (uint8_t *)&g_UsbHostInstance[i];
|
|
|
for (uint32_t j = 0U; j < sizeof(usb_host_instance_t); j++)
|
|
@@ -181,53 +204,53 @@ static usb_host_instance_t *USB_HostGetInstance(void)
|
|
|
buffer[j] = 0x00U;
|
|
|
}
|
|
|
g_UsbHostInstance[i].occupied = 1;
|
|
|
- OSA_EXIT_CRITICAL();
|
|
|
+ USB_OSA_EXIT_CRITICAL();
|
|
|
for (index = 0; index < USB_HOST_CONFIG_MAX_TRANSFERS; ++index)
|
|
|
{
|
|
|
- temp = (void *)&(s_Setupbuffer[i][index][0]);
|
|
|
- g_UsbHostInstance[i].transferList[index].setupPacket = (usb_setup_struct_t *)temp;
|
|
|
+ g_UsbHostInstance[i].transferList[index].setupPacket =
|
|
|
+ (usb_setup_struct_t *)&(s_Setupbuffer[i][index][0]);
|
|
|
}
|
|
|
return &g_UsbHostInstance[i];
|
|
|
}
|
|
|
}
|
|
|
- OSA_EXIT_CRITICAL();
|
|
|
+ USB_OSA_EXIT_CRITICAL();
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
static void USB_HostReleaseInstance(usb_host_instance_t *hostInstance)
|
|
|
{
|
|
|
- OSA_SR_ALLOC();
|
|
|
- OSA_ENTER_CRITICAL();
|
|
|
+ USB_OSA_SR_ALLOC();
|
|
|
+ USB_OSA_ENTER_CRITICAL();
|
|
|
hostInstance->occupied = 0;
|
|
|
- OSA_EXIT_CRITICAL();
|
|
|
+ USB_OSA_EXIT_CRITICAL();
|
|
|
}
|
|
|
|
|
|
static void USB_HostGetControllerInterface(uint8_t controllerId,
|
|
|
const usb_host_controller_interface_t **controllerTable)
|
|
|
{
|
|
|
#if ((defined USB_HOST_CONFIG_KHCI) && (USB_HOST_CONFIG_KHCI))
|
|
|
- if (controllerId == (uint8_t)kUSB_ControllerKhci0)
|
|
|
+ if (controllerId == kUSB_ControllerKhci0)
|
|
|
{
|
|
|
*controllerTable = &s_KhciInterface;
|
|
|
}
|
|
|
#endif /* USB_HOST_CONFIG_KHCI */
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI))
|
|
|
- if ((controllerId == (uint8_t)kUSB_ControllerEhci0) || (controllerId == (uint8_t)kUSB_ControllerEhci1))
|
|
|
+ if ((controllerId == kUSB_ControllerEhci0) || (controllerId == kUSB_ControllerEhci1))
|
|
|
{
|
|
|
*controllerTable = &s_EhciInterface;
|
|
|
}
|
|
|
#endif /* USB_HOST_CONFIG_EHCI */
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_OHCI) && (USB_HOST_CONFIG_OHCI > 0U))
|
|
|
- if (controllerId == (uint8_t)kUSB_ControllerOhci0)
|
|
|
+ if (controllerId == kUSB_ControllerOhci0)
|
|
|
{
|
|
|
*controllerTable = &s_OhciInterface;
|
|
|
}
|
|
|
#endif /* USB_HOST_CONFIG_OHCI */
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS > 0U))
|
|
|
- if (controllerId == (uint8_t)kUSB_ControllerIp3516Hs0)
|
|
|
+ if (controllerId == kUSB_ControllerIp3516Hs0)
|
|
|
{
|
|
|
*controllerTable = &s_Ip3516HsInterface;
|
|
|
}
|
|
@@ -236,10 +259,10 @@ static void USB_HostGetControllerInterface(uint8_t controllerId,
|
|
|
|
|
|
usb_status_t USB_HostInit(uint8_t controllerId, usb_host_handle *hostHandle, host_callback_t callbackFn)
|
|
|
{
|
|
|
- usb_status_t status = kStatus_USB_Success;
|
|
|
+ usb_status_t status = kStatus_USB_Success;
|
|
|
usb_host_instance_t *hostInstance = NULL;
|
|
|
usb_host_transfer_t *transferPrev = NULL;
|
|
|
- uint8_t i = 0;
|
|
|
+ uint8_t i = 0;
|
|
|
|
|
|
hostInstance = USB_HostGetInstance(); /* get one host instance */
|
|
|
if (hostInstance == NULL)
|
|
@@ -268,11 +291,10 @@ usb_status_t USB_HostInit(uint8_t controllerId, usb_host_handle *hostHandle, hos
|
|
|
}
|
|
|
|
|
|
/* HOST instance init*/
|
|
|
- hostInstance->controllerId = controllerId;
|
|
|
+ hostInstance->controllerId = controllerId;
|
|
|
hostInstance->deviceCallback = callbackFn;
|
|
|
- hostInstance->deviceList = NULL;
|
|
|
- hostInstance->hostMutex = (osa_mutex_handle_t)(&hostInstance->mutexBuffer[0]);
|
|
|
- if (KOSA_StatusSuccess != OSA_MutexCreate(hostInstance->hostMutex))
|
|
|
+ hostInstance->deviceList = NULL;
|
|
|
+ if (kStatus_USB_OSA_Success != USB_OsaMutexCreate(&hostInstance->hostMutex))
|
|
|
{
|
|
|
USB_HostReleaseInstance(hostInstance);
|
|
|
#ifdef HOST_ECHO
|
|
@@ -284,19 +306,19 @@ usb_status_t USB_HostInit(uint8_t controllerId, usb_host_handle *hostHandle, hos
|
|
|
/* initialize transfer list */
|
|
|
|
|
|
hostInstance->transferHead = &hostInstance->transferList[0];
|
|
|
- transferPrev = hostInstance->transferHead;
|
|
|
+ transferPrev = hostInstance->transferHead;
|
|
|
for (i = 1; i < USB_HOST_CONFIG_MAX_TRANSFERS; ++i)
|
|
|
{
|
|
|
transferPrev->next = &hostInstance->transferList[i];
|
|
|
- transferPrev = transferPrev->next;
|
|
|
+ transferPrev = transferPrev->next;
|
|
|
}
|
|
|
|
|
|
- /* controller create, the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
+ /* controller create */
|
|
|
status =
|
|
|
hostInstance->controllerTable->controllerCreate(controllerId, hostInstance, &(hostInstance->controllerHandle));
|
|
|
if ((status != kStatus_USB_Success) || (hostInstance->controllerHandle == NULL))
|
|
|
{
|
|
|
- (void)OSA_MutexDestroy(hostInstance->hostMutex);
|
|
|
+ USB_OsaMutexDestroy(hostInstance->hostMutex);
|
|
|
USB_HostReleaseInstance(hostInstance);
|
|
|
#ifdef HOST_ECHO
|
|
|
usb_echo("host init: controller init fail\r\n");
|
|
@@ -310,8 +332,8 @@ usb_status_t USB_HostInit(uint8_t controllerId, usb_host_handle *hostHandle, hos
|
|
|
|
|
|
usb_status_t USB_HostDeinit(usb_host_handle hostHandle)
|
|
|
{
|
|
|
- usb_status_t status = kStatus_USB_Success;
|
|
|
- usb_host_instance_t *hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
+ usb_status_t status = kStatus_USB_Success;
|
|
|
+ usb_host_instance_t *hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
usb_host_device_instance_t *deviceInstance = NULL;
|
|
|
|
|
|
if (hostHandle == NULL)
|
|
@@ -324,23 +346,23 @@ usb_status_t USB_HostDeinit(usb_host_handle hostHandle)
|
|
|
while (deviceInstance != NULL)
|
|
|
{
|
|
|
deviceInstance = (usb_host_device_instance_t *)hostInstance->deviceList;
|
|
|
- (void)USB_HostDetachDeviceInternal(hostHandle, deviceInstance);
|
|
|
+ USB_HostDetachDeviceInternal(hostHandle, deviceInstance);
|
|
|
}
|
|
|
|
|
|
- /* controller instance destroy, the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
- status = hostInstance->controllerTable->controllerDestory(hostInstance->controllerHandle);
|
|
|
+ /* controller instance destory */
|
|
|
+ status = hostInstance->controllerTable->controllerDestory(hostInstance->controllerHandle);
|
|
|
hostInstance->controllerHandle = NULL;
|
|
|
if (status != kStatus_USB_Success)
|
|
|
{
|
|
|
#ifdef HOST_ECHO
|
|
|
- usb_echo("host controller destroy fail\r\n");
|
|
|
+ usb_echo("host controller destory fail\r\n");
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
/* resource release */
|
|
|
- if (NULL != hostInstance->hostMutex)
|
|
|
+ if (hostInstance->hostMutex)
|
|
|
{
|
|
|
- (void)OSA_MutexDestroy(hostInstance->hostMutex);
|
|
|
+ USB_OsaMutexDestroy(hostInstance->hostMutex);
|
|
|
hostInstance->hostMutex = NULL;
|
|
|
}
|
|
|
USB_HostReleaseInstance(hostInstance);
|
|
@@ -352,7 +374,7 @@ usb_status_t USB_HostOpenPipe(usb_host_handle hostHandle,
|
|
|
usb_host_pipe_handle *pipeHandle,
|
|
|
usb_host_pipe_init_t *pipeInit)
|
|
|
{
|
|
|
- usb_status_t status = kStatus_USB_Success;
|
|
|
+ usb_status_t status = kStatus_USB_Success;
|
|
|
usb_host_instance_t *hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
|
|
|
if ((hostHandle == NULL) || (pipeInit == NULL))
|
|
@@ -360,7 +382,7 @@ usb_status_t USB_HostOpenPipe(usb_host_handle hostHandle,
|
|
|
return kStatus_USB_InvalidHandle;
|
|
|
}
|
|
|
|
|
|
- /* call controller open pipe interface, the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
+ /* call controller open pipe interface */
|
|
|
status = hostInstance->controllerTable->controllerOpenPipe(hostInstance->controllerHandle, pipeHandle, pipeInit);
|
|
|
|
|
|
return status;
|
|
@@ -368,7 +390,7 @@ usb_status_t USB_HostOpenPipe(usb_host_handle hostHandle,
|
|
|
|
|
|
usb_status_t USB_HostClosePipe(usb_host_handle hostHandle, usb_host_pipe_handle pipeHandle)
|
|
|
{
|
|
|
- usb_status_t status = kStatus_USB_Success;
|
|
|
+ usb_status_t status = kStatus_USB_Success;
|
|
|
usb_host_instance_t *hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
|
|
|
if ((hostHandle == NULL) || (pipeHandle == NULL))
|
|
@@ -376,7 +398,7 @@ usb_status_t USB_HostClosePipe(usb_host_handle hostHandle, usb_host_pipe_handle
|
|
|
return kStatus_USB_InvalidHandle;
|
|
|
}
|
|
|
|
|
|
- /* call controller close pipe interface, the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
+ /* call controller close pipe interface */
|
|
|
status = hostInstance->controllerTable->controllerClosePipe(hostInstance->controllerHandle, pipeHandle);
|
|
|
|
|
|
return status;
|
|
@@ -384,7 +406,7 @@ usb_status_t USB_HostClosePipe(usb_host_handle hostHandle, usb_host_pipe_handle
|
|
|
|
|
|
usb_status_t USB_HostSend(usb_host_handle hostHandle, usb_host_pipe_handle pipeHandle, usb_host_transfer_t *transfer)
|
|
|
{
|
|
|
- usb_status_t status = kStatus_USB_Success;
|
|
|
+ usb_status_t status = kStatus_USB_Success;
|
|
|
usb_host_instance_t *hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
|
|
|
if ((hostHandle == NULL) || (pipeHandle == NULL) || (transfer == NULL))
|
|
@@ -394,9 +416,9 @@ usb_status_t USB_HostSend(usb_host_handle hostHandle, usb_host_pipe_handle pipeH
|
|
|
|
|
|
/* initialize transfer */
|
|
|
transfer->transferSofar = 0;
|
|
|
- transfer->direction = USB_OUT;
|
|
|
+ transfer->direction = USB_OUT;
|
|
|
|
|
|
- (void)USB_HostLock(); /* This api can be called by host task and app task */
|
|
|
+ USB_HostLock(); /* This api can be called by host task and app task */
|
|
|
/* keep this code: in normal situation application will guarantee the device is attached when call send/receive function
|
|
|
*/
|
|
|
#if 0
|
|
@@ -413,10 +435,9 @@ usb_status_t USB_HostSend(usb_host_handle hostHandle, usb_host_pipe_handle pipeH
|
|
|
DCACHE_CleanByRange((uint32_t)transfer->transferBuffer, transfer->transferLength);
|
|
|
}
|
|
|
#endif
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerWritePipe(hostInstance->controllerHandle, pipeHandle, transfer);
|
|
|
|
|
|
- (void)USB_HostUnlock();
|
|
|
+ USB_HostUnlock();
|
|
|
return status;
|
|
|
}
|
|
|
|
|
@@ -424,7 +445,7 @@ usb_status_t USB_HostSendSetup(usb_host_handle hostHandle,
|
|
|
usb_host_pipe_handle pipeHandle,
|
|
|
usb_host_transfer_t *transfer)
|
|
|
{
|
|
|
- usb_status_t status = kStatus_USB_Success;
|
|
|
+ usb_status_t status = kStatus_USB_Success;
|
|
|
usb_host_instance_t *hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
|
|
|
if ((hostHandle == NULL) || (pipeHandle == NULL) || (transfer == NULL))
|
|
@@ -434,8 +455,8 @@ usb_status_t USB_HostSendSetup(usb_host_handle hostHandle,
|
|
|
|
|
|
/* initialize transfer */
|
|
|
transfer->transferSofar = 0;
|
|
|
- transfer->next = NULL;
|
|
|
- transfer->setupStatus = 0;
|
|
|
+ transfer->next = NULL;
|
|
|
+ transfer->setupStatus = 0;
|
|
|
if ((transfer->setupPacket->bmRequestType & USB_REQUEST_TYPE_DIR_MASK) == USB_REQUEST_TYPE_DIR_IN)
|
|
|
{
|
|
|
transfer->direction = USB_IN;
|
|
@@ -445,7 +466,7 @@ usb_status_t USB_HostSendSetup(usb_host_handle hostHandle,
|
|
|
transfer->direction = USB_OUT;
|
|
|
}
|
|
|
|
|
|
- (void)USB_HostLock(); /* This API can be called by host task and application task */
|
|
|
+ USB_HostLock(); /* This API can be called by host task and application task */
|
|
|
/* keep this code: in normal situation application will guarantee the device is attached when call send/receive function
|
|
|
*/
|
|
|
#if 0
|
|
@@ -463,16 +484,15 @@ usb_status_t USB_HostSendSetup(usb_host_handle hostHandle,
|
|
|
DCACHE_CleanInvalidateByRange((uint32_t)transfer->transferBuffer, transfer->transferLength);
|
|
|
}
|
|
|
#endif
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerWritePipe(hostInstance->controllerHandle, pipeHandle, transfer);
|
|
|
|
|
|
- (void)USB_HostUnlock();
|
|
|
+ USB_HostUnlock();
|
|
|
return status;
|
|
|
}
|
|
|
|
|
|
usb_status_t USB_HostRecv(usb_host_handle hostHandle, usb_host_pipe_handle pipeHandle, usb_host_transfer_t *transfer)
|
|
|
{
|
|
|
- usb_status_t status = kStatus_USB_Success;
|
|
|
+ usb_status_t status = kStatus_USB_Success;
|
|
|
usb_host_instance_t *hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
|
|
|
if ((hostHandle == NULL) || (pipeHandle == NULL) || (transfer == NULL))
|
|
@@ -482,9 +502,9 @@ usb_status_t USB_HostRecv(usb_host_handle hostHandle, usb_host_pipe_handle pipeH
|
|
|
|
|
|
/* initialize transfer */
|
|
|
transfer->transferSofar = 0;
|
|
|
- transfer->direction = USB_IN;
|
|
|
+ transfer->direction = USB_IN;
|
|
|
|
|
|
- (void)USB_HostLock(); /* This API can be called by host task and application task */
|
|
|
+ USB_HostLock(); /* This API can be called by host task and application task */
|
|
|
/* keep this code: in normal situation application will guarantee the device is attached when call send/receive function
|
|
|
*/
|
|
|
#if 0
|
|
@@ -501,10 +521,9 @@ usb_status_t USB_HostRecv(usb_host_handle hostHandle, usb_host_pipe_handle pipeH
|
|
|
DCACHE_CleanInvalidateByRange((uint32_t)transfer->transferBuffer, transfer->transferLength);
|
|
|
}
|
|
|
#endif
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerReadPipe(hostInstance->controllerHandle, pipeHandle, transfer);
|
|
|
|
|
|
- (void)USB_HostUnlock();
|
|
|
+ USB_HostUnlock();
|
|
|
return status;
|
|
|
}
|
|
|
|
|
@@ -512,7 +531,7 @@ usb_status_t USB_HostCancelTransfer(usb_host_handle hostHandle,
|
|
|
usb_host_pipe_handle pipeHandle,
|
|
|
usb_host_transfer_t *transfer)
|
|
|
{
|
|
|
- usb_status_t status = kStatus_USB_Success;
|
|
|
+ usb_status_t status = kStatus_USB_Success;
|
|
|
usb_host_instance_t *hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
usb_host_cancel_param_t cancelParam;
|
|
|
|
|
@@ -523,10 +542,9 @@ usb_status_t USB_HostCancelTransfer(usb_host_handle hostHandle,
|
|
|
|
|
|
/* initialize cancel parameter */
|
|
|
cancelParam.pipeHandle = pipeHandle;
|
|
|
- cancelParam.transfer = transfer;
|
|
|
+ cancelParam.transfer = transfer;
|
|
|
|
|
|
/* USB_HostLock(); This api can be called by host task and app task */
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostCancelTransfer,
|
|
|
&cancelParam);
|
|
|
/* USB_HostUnlock(); */
|
|
@@ -544,18 +562,18 @@ usb_status_t USB_HostMallocTransfer(usb_host_handle hostHandle, usb_host_transfe
|
|
|
}
|
|
|
|
|
|
/* get one from the transfer_head */
|
|
|
- (void)USB_HostLock();
|
|
|
+ USB_HostLock();
|
|
|
if (hostInstance->transferHead != NULL)
|
|
|
{
|
|
|
- *transfer = hostInstance->transferHead;
|
|
|
+ *transfer = hostInstance->transferHead;
|
|
|
hostInstance->transferHead = hostInstance->transferHead->next;
|
|
|
- (void)USB_HostUnlock();
|
|
|
+ USB_HostUnlock();
|
|
|
return kStatus_USB_Success;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
*transfer = NULL;
|
|
|
- (void)USB_HostUnlock();
|
|
|
+ USB_HostUnlock();
|
|
|
return kStatus_USB_Error;
|
|
|
}
|
|
|
}
|
|
@@ -574,10 +592,10 @@ usb_status_t USB_HostFreeTransfer(usb_host_handle hostHandle, usb_host_transfer_
|
|
|
}
|
|
|
|
|
|
/* release one to the transfer_head */
|
|
|
- (void)USB_HostLock();
|
|
|
- transfer->next = hostInstance->transferHead;
|
|
|
+ USB_HostLock();
|
|
|
+ transfer->next = hostInstance->transferHead;
|
|
|
hostInstance->transferHead = transfer;
|
|
|
- (void)USB_HostUnlock();
|
|
|
+ USB_HostUnlock();
|
|
|
return kStatus_USB_Success;
|
|
|
}
|
|
|
|
|
@@ -586,28 +604,23 @@ usb_status_t USB_HostHelperGetPeripheralInformation(usb_device_handle deviceHand
|
|
|
uint32_t *infoValue)
|
|
|
{
|
|
|
usb_host_device_instance_t *deviceInstance = (usb_host_device_instance_t *)deviceHandle;
|
|
|
- uint32_t *temp;
|
|
|
- usb_host_dev_info_t devInfo;
|
|
|
if ((deviceHandle == NULL) || (infoValue == NULL))
|
|
|
{
|
|
|
return kStatus_USB_InvalidParameter;
|
|
|
}
|
|
|
- devInfo = (usb_host_dev_info_t)infoCode;
|
|
|
- switch (devInfo)
|
|
|
+
|
|
|
+ switch (infoCode)
|
|
|
{
|
|
|
case kUSB_HostGetDeviceAddress: /* device address */
|
|
|
-
|
|
|
*infoValue = (uint32_t)deviceInstance->setAddress;
|
|
|
break;
|
|
|
|
|
|
case kUSB_HostGetDeviceControlPipe: /* device control pipe */
|
|
|
- temp = (uint32_t *)deviceInstance->controlPipe;
|
|
|
- *infoValue = (uint32_t)temp;
|
|
|
+ *infoValue = (uint32_t)deviceInstance->controlPipe;
|
|
|
break;
|
|
|
|
|
|
case kUSB_HostGetHostHandle: /* device host handle */
|
|
|
- temp = (uint32_t *)deviceInstance->hostHandle;
|
|
|
- *infoValue = (uint32_t)temp;
|
|
|
+ *infoValue = (uint32_t)deviceInstance->hostHandle;
|
|
|
break;
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))
|
|
@@ -672,8 +685,7 @@ usb_status_t USB_HostHelperGetPeripheralInformation(usb_device_handle deviceHand
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- /*no action*/
|
|
|
- break;
|
|
|
+ return kStatus_USB_Error;
|
|
|
}
|
|
|
|
|
|
return kStatus_USB_Success;
|
|
@@ -686,27 +698,26 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter
|
|
|
uint32_t endPosition;
|
|
|
usb_descriptor_union_t *unionDes;
|
|
|
usb_host_ep_t *epParse;
|
|
|
- void *temp;
|
|
|
+
|
|
|
if (interfaceHandle == NULL)
|
|
|
{
|
|
|
return kStatus_USB_InvalidHandle;
|
|
|
}
|
|
|
|
|
|
- if (alternateSetting == 0U)
|
|
|
+ if (alternateSetting == 0)
|
|
|
{
|
|
|
return kStatus_USB_InvalidParameter;
|
|
|
}
|
|
|
|
|
|
/* parse configuration descriptor */
|
|
|
- temp = (void *)((usb_host_interface_t *)interfaceHandle)->interfaceDesc;
|
|
|
- ;
|
|
|
- unionDes = (usb_descriptor_union_t *)temp; /* interface extend descriptor start */
|
|
|
+ unionDes = (usb_descriptor_union_t *)((usb_host_interface_t *)interfaceHandle)
|
|
|
+ ->interfaceDesc; /* interface extend descriptor start */
|
|
|
endPosition =
|
|
|
(uint32_t)unionDes +
|
|
|
((usb_host_interface_t *)interfaceHandle)->interfaceExtensionLength; /* interface extend descriptor end */
|
|
|
unionDes = (usb_descriptor_union_t *)((uint32_t)unionDes + unionDes->common.bLength);
|
|
|
|
|
|
- /* search for the alternate setting interface descriptor */
|
|
|
+ /* search for the alternate setting interface descritpor */
|
|
|
while ((uint32_t)unionDes < endPosition)
|
|
|
{
|
|
|
if (unionDes->interface.bDescriptorType == USB_DESCRIPTOR_TYPE_INTERFACE)
|
|
@@ -731,12 +742,12 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter
|
|
|
}
|
|
|
|
|
|
/* initialize interface handle structure instance */
|
|
|
- interface->interfaceDesc = &unionDes->interface;
|
|
|
- interface->alternateSettingNumber = 0U;
|
|
|
- interface->epCount = 0U;
|
|
|
- interface->interfaceExtension = NULL;
|
|
|
- interface->interfaceExtensionLength = 0U;
|
|
|
- interface->interfaceIndex = unionDes->interface.bInterfaceNumber;
|
|
|
+ interface->interfaceDesc = &unionDes->interface;
|
|
|
+ interface->alternateSettingNumber = 0;
|
|
|
+ interface->epCount = 0;
|
|
|
+ interface->interfaceExtension = NULL;
|
|
|
+ interface->interfaceExtensionLength = 0;
|
|
|
+ interface->interfaceIndex = unionDes->interface.bInterfaceNumber;
|
|
|
|
|
|
/* search for endpoint descriptor start position */
|
|
|
unionDes = (usb_descriptor_union_t *)((uint32_t)unionDes + unionDes->common.bLength);
|
|
@@ -759,7 +770,7 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter
|
|
|
}
|
|
|
|
|
|
/* parse endpoint descriptor */
|
|
|
- if (interface->interfaceDesc->bNumEndpoints != 0U)
|
|
|
+ if (interface->interfaceDesc->bNumEndpoints != 0)
|
|
|
{
|
|
|
if ((unionDes->common.bDescriptorType != USB_DESCRIPTOR_TYPE_ENDPOINT) ||
|
|
|
(interface->interfaceDesc->bNumEndpoints > USB_HOST_CONFIG_INTERFACE_MAX_EP))
|
|
@@ -779,12 +790,11 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter
|
|
|
#endif
|
|
|
return kStatus_USB_Error;
|
|
|
}
|
|
|
- epParse = (usb_host_ep_t *)&interface->epList[interface->epCount];
|
|
|
- temp = (void *)unionDes;
|
|
|
- epParse->epDesc = (usb_descriptor_endpoint_t *)temp;
|
|
|
+ epParse = (usb_host_ep_t *)&interface->epList[interface->epCount];
|
|
|
+ epParse->epDesc = (usb_descriptor_endpoint_t *)unionDes;
|
|
|
epParse->epExtensionLength = 0;
|
|
|
- epParse->epExtension = NULL;
|
|
|
- unionDes = (usb_descriptor_union_t *)((uint32_t)unionDes + unionDes->common.bLength);
|
|
|
+ epParse->epExtension = NULL;
|
|
|
+ unionDes = (usb_descriptor_union_t *)((uint32_t)unionDes + unionDes->common.bLength);
|
|
|
while ((uint32_t)unionDes < endPosition)
|
|
|
{
|
|
|
if ((unionDes->common.bDescriptorType != USB_DESCRIPTOR_TYPE_ENDPOINT) &&
|
|
@@ -810,7 +820,7 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter
|
|
|
|
|
|
void USB_HostGetVersion(uint32_t *version)
|
|
|
{
|
|
|
- if (NULL != version)
|
|
|
+ if (version)
|
|
|
{
|
|
|
*version =
|
|
|
(uint32_t)USB_MAKE_VERSION(USB_STACK_VERSION_MAJOR, USB_STACK_VERSION_MINOR, USB_STACK_VERSION_BUGFIX);
|
|
@@ -818,12 +828,12 @@ void USB_HostGetVersion(uint32_t *version)
|
|
|
}
|
|
|
|
|
|
#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
|
|
|
-/* Send BUS or specific device suspend request */
|
|
|
+/* Send BUS or specific device suepend request */
|
|
|
usb_status_t USB_HostSuspendDeviceResquest(usb_host_handle hostHandle, usb_device_handle deviceHandle)
|
|
|
{
|
|
|
usb_host_instance_t *hostInstance;
|
|
|
usb_host_device_instance_t *deviceInstance;
|
|
|
- usb_status_t status = kStatus_USB_Error;
|
|
|
+ usb_status_t status = kStatus_USB_Error;
|
|
|
usb_host_bus_control_t type = kUSB_HostBusSuspend;
|
|
|
|
|
|
if (hostHandle == NULL)
|
|
@@ -839,7 +849,6 @@ usb_status_t USB_HostSuspendDeviceResquest(usb_host_handle hostHandle, usb_devic
|
|
|
#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))
|
|
|
status = USB_HostHubSuspendDevice(hostInstance);
|
|
|
#else
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status =
|
|
|
hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostBusControl, &type);
|
|
|
#endif
|
|
@@ -848,12 +857,11 @@ usb_status_t USB_HostSuspendDeviceResquest(usb_host_handle hostHandle, usb_devic
|
|
|
{
|
|
|
#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))
|
|
|
deviceInstance = (usb_host_device_instance_t *)deviceHandle;
|
|
|
- if (0U == deviceInstance->hubNumber)
|
|
|
+ if (0 == deviceInstance->hubNumber)
|
|
|
{
|
|
|
#endif
|
|
|
if (hostInstance->deviceList == deviceHandle)
|
|
|
{
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle,
|
|
|
kUSB_HostBusControl, &type);
|
|
|
}
|
|
@@ -880,7 +888,7 @@ usb_status_t USB_HostResumeDeviceResquest(usb_host_handle hostHandle, usb_device
|
|
|
{
|
|
|
usb_host_instance_t *hostInstance;
|
|
|
usb_host_device_instance_t *deviceInstance;
|
|
|
- usb_status_t status = kStatus_USB_Error;
|
|
|
+ usb_status_t status = kStatus_USB_Error;
|
|
|
usb_host_bus_control_t type = kUSB_HostBusResume;
|
|
|
|
|
|
if (hostHandle == NULL)
|
|
@@ -897,7 +905,6 @@ usb_status_t USB_HostResumeDeviceResquest(usb_host_handle hostHandle, usb_device
|
|
|
|
|
|
if (NULL == deviceHandle)
|
|
|
{
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status =
|
|
|
hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostBusControl, &type);
|
|
|
}
|
|
@@ -905,12 +912,11 @@ usb_status_t USB_HostResumeDeviceResquest(usb_host_handle hostHandle, usb_device
|
|
|
{
|
|
|
#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))
|
|
|
deviceInstance = (usb_host_device_instance_t *)deviceHandle;
|
|
|
- if (0U == deviceInstance->hubNumber)
|
|
|
+ if (0 == deviceInstance->hubNumber)
|
|
|
{
|
|
|
#endif
|
|
|
if (hostInstance->deviceList == deviceHandle)
|
|
|
{
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle,
|
|
|
kUSB_HostBusControl, &type);
|
|
|
}
|
|
@@ -929,13 +935,13 @@ usb_status_t USB_HostResumeDeviceResquest(usb_host_handle hostHandle, usb_device
|
|
|
return status;
|
|
|
}
|
|
|
#if ((defined(USB_HOST_CONFIG_LPM_L1)) && (USB_HOST_CONFIG_LPM_L1 > 0U))
|
|
|
-/* Send BUS or specific device suspend request */
|
|
|
+/* Send BUS or specific device suepend request */
|
|
|
usb_status_t USB_HostL1SleepDeviceResquest(usb_host_handle hostHandle,
|
|
|
usb_device_handle deviceHandle,
|
|
|
uint8_t sleepType)
|
|
|
{
|
|
|
usb_host_instance_t *hostInstance;
|
|
|
- usb_status_t status = kStatus_USB_Error;
|
|
|
+ usb_status_t status = kStatus_USB_Error;
|
|
|
usb_host_bus_control_t type = kUSB_HostBusL1Sleep;
|
|
|
|
|
|
if (hostHandle == NULL)
|
|
@@ -949,9 +955,8 @@ usb_status_t USB_HostL1SleepDeviceResquest(usb_host_handle hostHandle,
|
|
|
if (1U == sleepType)
|
|
|
{
|
|
|
/*#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))*/
|
|
|
- /*To do, incomplete hub L1 suspend device*/
|
|
|
+ /*To do, implete hub L1 suspend device*/
|
|
|
/*#else*/
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status =
|
|
|
hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostBusControl, &type);
|
|
|
/*#endif*/
|
|
@@ -963,7 +968,6 @@ usb_status_t USB_HostL1SleepDeviceResquest(usb_host_handle hostHandle,
|
|
|
#endif
|
|
|
if (hostInstance->deviceList == deviceHandle)
|
|
|
{
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostBusControl,
|
|
|
&type);
|
|
|
}
|
|
@@ -974,7 +978,7 @@ usb_status_t USB_HostL1SleepDeviceResquest(usb_host_handle hostHandle,
|
|
|
}
|
|
|
return status;
|
|
|
}
|
|
|
-/* Send BUS or specific device suspend request */
|
|
|
+/* Send BUS or specific device suepend request */
|
|
|
usb_status_t USB_HostL1SleepDeviceResquestConfig(usb_host_handle hostHandle, uint8_t *lpmParam)
|
|
|
{
|
|
|
usb_host_instance_t *hostInstance;
|
|
@@ -985,7 +989,7 @@ usb_status_t USB_HostL1SleepDeviceResquestConfig(usb_host_handle hostHandle, uin
|
|
|
return kStatus_USB_InvalidHandle;
|
|
|
}
|
|
|
hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
+
|
|
|
status =
|
|
|
hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostL1Config, lpmParam);
|
|
|
|
|
@@ -999,7 +1003,7 @@ usb_status_t USB_HostL1ResumeDeviceResquest(usb_host_handle hostHandle,
|
|
|
{
|
|
|
usb_host_instance_t *hostInstance;
|
|
|
|
|
|
- usb_status_t status = kStatus_USB_Error;
|
|
|
+ usb_status_t status = kStatus_USB_Error;
|
|
|
usb_host_bus_control_t type = kUSB_HostBusL1Resume;
|
|
|
|
|
|
if (hostHandle == NULL)
|
|
@@ -1010,19 +1014,17 @@ usb_status_t USB_HostL1ResumeDeviceResquest(usb_host_handle hostHandle,
|
|
|
|
|
|
if (1U == sleepType)
|
|
|
{
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status =
|
|
|
hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostBusControl, &type);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))
|
|
|
- /*To do, if device hub number is 0, need suspend the bus ,else suspend the corresponding device*/
|
|
|
+/*To do, if device hub number is 0, need suspend the bus ,else suspend the corresponding device*/
|
|
|
|
|
|
#endif
|
|
|
if (hostInstance->deviceList == deviceHandle)
|
|
|
{
|
|
|
- /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostBusControl,
|
|
|
&type);
|
|
|
}
|
|
@@ -1048,18 +1050,3 @@ usb_status_t USB_HostUpdateHwTick(usb_host_handle hostHandle, uint64_t tick)
|
|
|
return status;
|
|
|
}
|
|
|
#endif
|
|
|
-
|
|
|
-#if ((defined(USB_HOST_CONFIG_BATTERY_CHARGER)) && (USB_HOST_CONFIG_BATTERY_CHARGER > 0U))
|
|
|
-usb_status_t USB_HostSetChargerType(usb_host_handle hostHandle, uint8_t type)
|
|
|
-{
|
|
|
- usb_host_instance_t *hostInstance;
|
|
|
-
|
|
|
- if (hostHandle == NULL)
|
|
|
- {
|
|
|
- return kStatus_USB_InvalidHandle;
|
|
|
- }
|
|
|
- hostInstance = (usb_host_instance_t *)hostHandle;
|
|
|
- return hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostSetChargerType,
|
|
|
- &type);
|
|
|
-}
|
|
|
-#endif
|