|
@@ -1,34 +1,12 @@
|
|
|
/*
|
|
|
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
|
|
- * Copyright 2016 NXP
|
|
|
+ * Copyright 2016 - 2019 NXP
|
|
|
+ * All rights reserved.
|
|
|
*
|
|
|
- * 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.
|
|
|
+ * SPDX-License-Identifier: BSD-3-Clause
|
|
|
*/
|
|
|
|
|
|
-#include <usb/include/usb_device_config.h>
|
|
|
+#include <usb/include/usb_host_config.h>
|
|
|
#include "fsl_common.h"
|
|
|
#include "usb_host.h"
|
|
|
#include "usb_host_hci.h"
|
|
@@ -42,16 +20,24 @@
|
|
|
* 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))
|
|
|
|
|
|
-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);
|
|
|
+#include "usb_host_hub.h"
|
|
|
+#include "usb_host_hub_app.h"
|
|
|
#endif
|
|
|
|
|
|
/*!
|
|
@@ -77,15 +63,6 @@ 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
|
|
|
******************************************************************************/
|
|
@@ -94,8 +71,7 @@ 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,
|
|
|
};
|
|
@@ -103,8 +79,7 @@ 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,
|
|
|
};
|
|
@@ -112,8 +87,7 @@ 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,
|
|
|
};
|
|
@@ -121,65 +95,67 @@ 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;
|
|
|
|
|
|
- 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);
|
|
|
+ (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);
|
|
|
|
|
|
- if ((productId != 0x0200U) && (productId != 0x0101) && (productId != 0x0102) && (productId != 0x0103) &&
|
|
|
- (productId != 0x0104) && (productId != 0x0105) && (productId != 0x0106) && (productId != 0x0107) &&
|
|
|
- (productId != 0x0108))
|
|
|
+ if ((productId != 0x0200U) && (productId != 0x0101U) && (productId != 0x0102U) && (productId != 0x0103U) &&
|
|
|
+ (productId != 0x0104U) && (productId != 0x0105U) && (productId != 0x0106U) && (productId != 0x0107U) &&
|
|
|
+ (productId != 0x0108U))
|
|
|
{
|
|
|
- usb_echo("Unsupported Device\r\n");
|
|
|
+ (void)usb_echo("Unsupported Device\r\n");
|
|
|
}
|
|
|
|
|
|
if (productId == 0x0200U)
|
|
|
{
|
|
|
- usb_echo("PET test device attached\r\n");
|
|
|
+ (void)usb_echo("PET test device attached\r\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI))
|
|
|
if (hostInstance->controllerTable == &s_EhciInterface)
|
|
|
{
|
|
|
- USB_HostEhciTestModeInit(deviceHandle);
|
|
|
+ (void)hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostTestModeInit,
|
|
|
+ (void *)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)
|
|
|
{
|
|
|
- USB_HostIp3516HsTestModeInit(deviceHandle);
|
|
|
+ (void)hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostTestModeInit,
|
|
|
+ (void *)deviceHandle);
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
@@ -190,13 +166,14 @@ 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;
|
|
|
- USB_OSA_SR_ALLOC();
|
|
|
- USB_OSA_ENTER_CRITICAL();
|
|
|
+ void *temp;
|
|
|
+ OSA_SR_ALLOC();
|
|
|
+ OSA_ENTER_CRITICAL();
|
|
|
for (; i < USB_HOST_CONFIG_MAX_HOST; i++)
|
|
|
{
|
|
|
- if (g_UsbHostInstance[i].occupied != 1)
|
|
|
+ if (g_UsbHostInstance[i].occupied != 1U)
|
|
|
{
|
|
|
uint8_t *buffer = (uint8_t *)&g_UsbHostInstance[i];
|
|
|
for (uint32_t j = 0U; j < sizeof(usb_host_instance_t); j++)
|
|
@@ -204,53 +181,53 @@ static usb_host_instance_t *USB_HostGetInstance(void)
|
|
|
buffer[j] = 0x00U;
|
|
|
}
|
|
|
g_UsbHostInstance[i].occupied = 1;
|
|
|
- USB_OSA_EXIT_CRITICAL();
|
|
|
+ OSA_EXIT_CRITICAL();
|
|
|
for (index = 0; index < USB_HOST_CONFIG_MAX_TRANSFERS; ++index)
|
|
|
{
|
|
|
- g_UsbHostInstance[i].transferList[index].setupPacket =
|
|
|
- (usb_setup_struct_t *)&(s_Setupbuffer[i][index][0]);
|
|
|
+ temp = (void *)&(s_Setupbuffer[i][index][0]);
|
|
|
+ g_UsbHostInstance[i].transferList[index].setupPacket = (usb_setup_struct_t *)temp;
|
|
|
}
|
|
|
return &g_UsbHostInstance[i];
|
|
|
}
|
|
|
}
|
|
|
- USB_OSA_EXIT_CRITICAL();
|
|
|
+ OSA_EXIT_CRITICAL();
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
static void USB_HostReleaseInstance(usb_host_instance_t *hostInstance)
|
|
|
{
|
|
|
- USB_OSA_SR_ALLOC();
|
|
|
- USB_OSA_ENTER_CRITICAL();
|
|
|
+ OSA_SR_ALLOC();
|
|
|
+ OSA_ENTER_CRITICAL();
|
|
|
hostInstance->occupied = 0;
|
|
|
- USB_OSA_EXIT_CRITICAL();
|
|
|
+ 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 == kUSB_ControllerKhci0)
|
|
|
+ if (controllerId == (uint8_t)kUSB_ControllerKhci0)
|
|
|
{
|
|
|
*controllerTable = &s_KhciInterface;
|
|
|
}
|
|
|
#endif /* USB_HOST_CONFIG_KHCI */
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI))
|
|
|
- if ((controllerId == kUSB_ControllerEhci0) || (controllerId == kUSB_ControllerEhci1))
|
|
|
+ if ((controllerId == (uint8_t)kUSB_ControllerEhci0) || (controllerId == (uint8_t)kUSB_ControllerEhci1))
|
|
|
{
|
|
|
*controllerTable = &s_EhciInterface;
|
|
|
}
|
|
|
#endif /* USB_HOST_CONFIG_EHCI */
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_OHCI) && (USB_HOST_CONFIG_OHCI > 0U))
|
|
|
- if (controllerId == kUSB_ControllerOhci0)
|
|
|
+ if (controllerId == (uint8_t)kUSB_ControllerOhci0)
|
|
|
{
|
|
|
*controllerTable = &s_OhciInterface;
|
|
|
}
|
|
|
#endif /* USB_HOST_CONFIG_OHCI */
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS > 0U))
|
|
|
- if (controllerId == kUSB_ControllerIp3516Hs0)
|
|
|
+ if (controllerId == (uint8_t)kUSB_ControllerIp3516Hs0)
|
|
|
{
|
|
|
*controllerTable = &s_Ip3516HsInterface;
|
|
|
}
|
|
@@ -259,10 +236,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)
|
|
@@ -291,10 +268,11 @@ 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;
|
|
|
- if (kStatus_USB_OSA_Success != USB_OsaMutexCreate(&hostInstance->hostMutex))
|
|
|
+ hostInstance->deviceList = NULL;
|
|
|
+ hostInstance->hostMutex = (osa_mutex_handle_t)(&hostInstance->mutexBuffer[0]);
|
|
|
+ if (KOSA_StatusSuccess != OSA_MutexCreate(hostInstance->hostMutex))
|
|
|
{
|
|
|
USB_HostReleaseInstance(hostInstance);
|
|
|
#ifdef HOST_ECHO
|
|
@@ -306,19 +284,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 */
|
|
|
+ /* controller create, the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status =
|
|
|
hostInstance->controllerTable->controllerCreate(controllerId, hostInstance, &(hostInstance->controllerHandle));
|
|
|
if ((status != kStatus_USB_Success) || (hostInstance->controllerHandle == NULL))
|
|
|
{
|
|
|
- USB_OsaMutexDestroy(hostInstance->hostMutex);
|
|
|
+ (void)OSA_MutexDestroy(hostInstance->hostMutex);
|
|
|
USB_HostReleaseInstance(hostInstance);
|
|
|
#ifdef HOST_ECHO
|
|
|
usb_echo("host init: controller init fail\r\n");
|
|
@@ -332,8 +310,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)
|
|
@@ -346,23 +324,23 @@ usb_status_t USB_HostDeinit(usb_host_handle hostHandle)
|
|
|
while (deviceInstance != NULL)
|
|
|
{
|
|
|
deviceInstance = (usb_host_device_instance_t *)hostInstance->deviceList;
|
|
|
- USB_HostDetachDeviceInternal(hostHandle, deviceInstance);
|
|
|
+ (void)USB_HostDetachDeviceInternal(hostHandle, deviceInstance);
|
|
|
}
|
|
|
|
|
|
- /* controller instance destory */
|
|
|
- status = hostInstance->controllerTable->controllerDestory(hostInstance->controllerHandle);
|
|
|
+ /* controller instance destroy, the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
+ status = hostInstance->controllerTable->controllerDestory(hostInstance->controllerHandle);
|
|
|
hostInstance->controllerHandle = NULL;
|
|
|
if (status != kStatus_USB_Success)
|
|
|
{
|
|
|
#ifdef HOST_ECHO
|
|
|
- usb_echo("host controller destory fail\r\n");
|
|
|
+ usb_echo("host controller destroy fail\r\n");
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
/* resource release */
|
|
|
- if (hostInstance->hostMutex)
|
|
|
+ if (NULL != hostInstance->hostMutex)
|
|
|
{
|
|
|
- USB_OsaMutexDestroy(hostInstance->hostMutex);
|
|
|
+ (void)OSA_MutexDestroy(hostInstance->hostMutex);
|
|
|
hostInstance->hostMutex = NULL;
|
|
|
}
|
|
|
USB_HostReleaseInstance(hostInstance);
|
|
@@ -374,7 +352,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))
|
|
@@ -382,7 +360,7 @@ usb_status_t USB_HostOpenPipe(usb_host_handle hostHandle,
|
|
|
return kStatus_USB_InvalidHandle;
|
|
|
}
|
|
|
|
|
|
- /* call controller open pipe interface */
|
|
|
+ /* call controller open pipe interface, the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerOpenPipe(hostInstance->controllerHandle, pipeHandle, pipeInit);
|
|
|
|
|
|
return status;
|
|
@@ -390,7 +368,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))
|
|
@@ -398,7 +376,7 @@ usb_status_t USB_HostClosePipe(usb_host_handle hostHandle, usb_host_pipe_handle
|
|
|
return kStatus_USB_InvalidHandle;
|
|
|
}
|
|
|
|
|
|
- /* call controller close pipe interface */
|
|
|
+ /* call controller close pipe interface, the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerClosePipe(hostInstance->controllerHandle, pipeHandle);
|
|
|
|
|
|
return status;
|
|
@@ -406,7 +384,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))
|
|
@@ -416,9 +394,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;
|
|
|
|
|
|
- USB_HostLock(); /* This api can be called by host task and app task */
|
|
|
+ (void)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
|
|
@@ -435,9 +413,10 @@ 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);
|
|
|
|
|
|
- USB_HostUnlock();
|
|
|
+ (void)USB_HostUnlock();
|
|
|
return status;
|
|
|
}
|
|
|
|
|
@@ -445,7 +424,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))
|
|
@@ -455,8 +434,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;
|
|
@@ -466,7 +445,7 @@ usb_status_t USB_HostSendSetup(usb_host_handle hostHandle,
|
|
|
transfer->direction = USB_OUT;
|
|
|
}
|
|
|
|
|
|
- USB_HostLock(); /* This API can be called by host task and application task */
|
|
|
+ (void)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
|
|
@@ -484,15 +463,16 @@ 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);
|
|
|
|
|
|
- USB_HostUnlock();
|
|
|
+ (void)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))
|
|
@@ -502,9 +482,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;
|
|
|
|
|
|
- USB_HostLock(); /* This API can be called by host task and application task */
|
|
|
+ (void)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
|
|
@@ -521,9 +501,10 @@ 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);
|
|
|
|
|
|
- USB_HostUnlock();
|
|
|
+ (void)USB_HostUnlock();
|
|
|
return status;
|
|
|
}
|
|
|
|
|
@@ -531,7 +512,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;
|
|
|
|
|
@@ -542,9 +523,10 @@ 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(); */
|
|
@@ -562,18 +544,18 @@ usb_status_t USB_HostMallocTransfer(usb_host_handle hostHandle, usb_host_transfe
|
|
|
}
|
|
|
|
|
|
/* get one from the transfer_head */
|
|
|
- USB_HostLock();
|
|
|
+ (void)USB_HostLock();
|
|
|
if (hostInstance->transferHead != NULL)
|
|
|
{
|
|
|
- *transfer = hostInstance->transferHead;
|
|
|
+ *transfer = hostInstance->transferHead;
|
|
|
hostInstance->transferHead = hostInstance->transferHead->next;
|
|
|
- USB_HostUnlock();
|
|
|
+ (void)USB_HostUnlock();
|
|
|
return kStatus_USB_Success;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
*transfer = NULL;
|
|
|
- USB_HostUnlock();
|
|
|
+ (void)USB_HostUnlock();
|
|
|
return kStatus_USB_Error;
|
|
|
}
|
|
|
}
|
|
@@ -592,10 +574,10 @@ usb_status_t USB_HostFreeTransfer(usb_host_handle hostHandle, usb_host_transfer_
|
|
|
}
|
|
|
|
|
|
/* release one to the transfer_head */
|
|
|
- USB_HostLock();
|
|
|
- transfer->next = hostInstance->transferHead;
|
|
|
+ (void)USB_HostLock();
|
|
|
+ transfer->next = hostInstance->transferHead;
|
|
|
hostInstance->transferHead = transfer;
|
|
|
- USB_HostUnlock();
|
|
|
+ (void)USB_HostUnlock();
|
|
|
return kStatus_USB_Success;
|
|
|
}
|
|
|
|
|
@@ -604,23 +586,28 @@ 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;
|
|
|
}
|
|
|
-
|
|
|
- switch (infoCode)
|
|
|
+ devInfo = (usb_host_dev_info_t)infoCode;
|
|
|
+ switch (devInfo)
|
|
|
{
|
|
|
case kUSB_HostGetDeviceAddress: /* device address */
|
|
|
+
|
|
|
*infoValue = (uint32_t)deviceInstance->setAddress;
|
|
|
break;
|
|
|
|
|
|
case kUSB_HostGetDeviceControlPipe: /* device control pipe */
|
|
|
- *infoValue = (uint32_t)deviceInstance->controlPipe;
|
|
|
+ temp = (uint32_t *)deviceInstance->controlPipe;
|
|
|
+ *infoValue = (uint32_t)temp;
|
|
|
break;
|
|
|
|
|
|
case kUSB_HostGetHostHandle: /* device host handle */
|
|
|
- *infoValue = (uint32_t)deviceInstance->hostHandle;
|
|
|
+ temp = (uint32_t *)deviceInstance->hostHandle;
|
|
|
+ *infoValue = (uint32_t)temp;
|
|
|
break;
|
|
|
|
|
|
#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))
|
|
@@ -685,7 +672,8 @@ usb_status_t USB_HostHelperGetPeripheralInformation(usb_device_handle deviceHand
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- return kStatus_USB_Error;
|
|
|
+ /*no action*/
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
return kStatus_USB_Success;
|
|
@@ -698,26 +686,27 @@ 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 == 0)
|
|
|
+ if (alternateSetting == 0U)
|
|
|
{
|
|
|
return kStatus_USB_InvalidParameter;
|
|
|
}
|
|
|
|
|
|
/* parse configuration descriptor */
|
|
|
- unionDes = (usb_descriptor_union_t *)((usb_host_interface_t *)interfaceHandle)
|
|
|
- ->interfaceDesc; /* interface extend descriptor start */
|
|
|
+ temp = (void *)((usb_host_interface_t *)interfaceHandle)->interfaceDesc;
|
|
|
+ ;
|
|
|
+ unionDes = (usb_descriptor_union_t *)temp; /* 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 descritpor */
|
|
|
+ /* search for the alternate setting interface descriptor */
|
|
|
while ((uint32_t)unionDes < endPosition)
|
|
|
{
|
|
|
if (unionDes->interface.bDescriptorType == USB_DESCRIPTOR_TYPE_INTERFACE)
|
|
@@ -742,12 +731,12 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter
|
|
|
}
|
|
|
|
|
|
/* initialize interface handle structure instance */
|
|
|
- interface->interfaceDesc = &unionDes->interface;
|
|
|
- interface->alternateSettingNumber = 0;
|
|
|
- interface->epCount = 0;
|
|
|
- interface->interfaceExtension = NULL;
|
|
|
- interface->interfaceExtensionLength = 0;
|
|
|
- interface->interfaceIndex = unionDes->interface.bInterfaceNumber;
|
|
|
+ interface->interfaceDesc = &unionDes->interface;
|
|
|
+ interface->alternateSettingNumber = 0U;
|
|
|
+ interface->epCount = 0U;
|
|
|
+ interface->interfaceExtension = NULL;
|
|
|
+ interface->interfaceExtensionLength = 0U;
|
|
|
+ interface->interfaceIndex = unionDes->interface.bInterfaceNumber;
|
|
|
|
|
|
/* search for endpoint descriptor start position */
|
|
|
unionDes = (usb_descriptor_union_t *)((uint32_t)unionDes + unionDes->common.bLength);
|
|
@@ -770,7 +759,7 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter
|
|
|
}
|
|
|
|
|
|
/* parse endpoint descriptor */
|
|
|
- if (interface->interfaceDesc->bNumEndpoints != 0)
|
|
|
+ if (interface->interfaceDesc->bNumEndpoints != 0U)
|
|
|
{
|
|
|
if ((unionDes->common.bDescriptorType != USB_DESCRIPTOR_TYPE_ENDPOINT) ||
|
|
|
(interface->interfaceDesc->bNumEndpoints > USB_HOST_CONFIG_INTERFACE_MAX_EP))
|
|
@@ -790,11 +779,12 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter
|
|
|
#endif
|
|
|
return kStatus_USB_Error;
|
|
|
}
|
|
|
- epParse = (usb_host_ep_t *)&interface->epList[interface->epCount];
|
|
|
- epParse->epDesc = (usb_descriptor_endpoint_t *)unionDes;
|
|
|
+ epParse = (usb_host_ep_t *)&interface->epList[interface->epCount];
|
|
|
+ temp = (void *)unionDes;
|
|
|
+ epParse->epDesc = (usb_descriptor_endpoint_t *)temp;
|
|
|
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) &&
|
|
@@ -820,7 +810,7 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter
|
|
|
|
|
|
void USB_HostGetVersion(uint32_t *version)
|
|
|
{
|
|
|
- if (version)
|
|
|
+ if (NULL != version)
|
|
|
{
|
|
|
*version =
|
|
|
(uint32_t)USB_MAKE_VERSION(USB_STACK_VERSION_MAJOR, USB_STACK_VERSION_MINOR, USB_STACK_VERSION_BUGFIX);
|
|
@@ -828,12 +818,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 suepend request */
|
|
|
+/* Send BUS or specific device suspend 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)
|
|
@@ -849,6 +839,7 @@ 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
|
|
@@ -857,11 +848,12 @@ 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 (0 == deviceInstance->hubNumber)
|
|
|
+ if (0U == deviceInstance->hubNumber)
|
|
|
{
|
|
|
#endif
|
|
|
if (hostInstance->deviceList == deviceHandle)
|
|
|
{
|
|
|
+ /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle,
|
|
|
kUSB_HostBusControl, &type);
|
|
|
}
|
|
@@ -888,7 +880,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)
|
|
@@ -905,6 +897,7 @@ 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);
|
|
|
}
|
|
@@ -912,11 +905,12 @@ 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 (0 == deviceInstance->hubNumber)
|
|
|
+ if (0U == deviceInstance->hubNumber)
|
|
|
{
|
|
|
#endif
|
|
|
if (hostInstance->deviceList == deviceHandle)
|
|
|
{
|
|
|
+ /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status = hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle,
|
|
|
kUSB_HostBusControl, &type);
|
|
|
}
|
|
@@ -935,13 +929,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 suepend request */
|
|
|
+/* Send BUS or specific device suspend 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)
|
|
@@ -955,8 +949,9 @@ usb_status_t USB_HostL1SleepDeviceResquest(usb_host_handle hostHandle,
|
|
|
if (1U == sleepType)
|
|
|
{
|
|
|
/*#if ((defined USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB))*/
|
|
|
- /*To do, implete hub L1 suspend device*/
|
|
|
+ /*To do, incomplete hub L1 suspend device*/
|
|
|
/*#else*/
|
|
|
+ /* the callbackFn is initialized in USB_HostGetControllerInterface */
|
|
|
status =
|
|
|
hostInstance->controllerTable->controllerIoctl(hostInstance->controllerHandle, kUSB_HostBusControl, &type);
|
|
|
/*#endif*/
|
|
@@ -968,6 +963,7 @@ 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);
|
|
|
}
|
|
@@ -978,7 +974,7 @@ usb_status_t USB_HostL1SleepDeviceResquest(usb_host_handle hostHandle,
|
|
|
}
|
|
|
return status;
|
|
|
}
|
|
|
-/* Send BUS or specific device suepend request */
|
|
|
+/* Send BUS or specific device suspend request */
|
|
|
usb_status_t USB_HostL1SleepDeviceResquestConfig(usb_host_handle hostHandle, uint8_t *lpmParam)
|
|
|
{
|
|
|
usb_host_instance_t *hostInstance;
|
|
@@ -989,7 +985,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);
|
|
|
|
|
@@ -1003,7 +999,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)
|
|
@@ -1014,17 +1010,19 @@ 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);
|
|
|
}
|
|
@@ -1050,3 +1048,18 @@ 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
|