mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
831 lines
30 KiB
C
831 lines
30 KiB
C
/********************************** (C) COPYRIGHT *******************************
|
||
* File Name : CH58x_usbhost.c
|
||
* Author : WCH
|
||
* Version : V1.2
|
||
* Date : 2021/11/17
|
||
* Description
|
||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||
* SPDX-License-Identifier: Apache-2.0
|
||
*******************************************************************************/
|
||
|
||
#include "CH58x_common.h"
|
||
#if DISK_LIB_ENABLE
|
||
#include "CHRV3UFI.H"
|
||
#endif
|
||
|
||
/* <20><><EFBFBD><EFBFBD>HID<49>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD> */
|
||
__attribute__((aligned(4))) const uint8_t SetupSetHIDIdle[] = {0x21, HID_SET_IDLE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||
/* <20><>ȡHID<49>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||
__attribute__((aligned(4))) const uint8_t SetupGetHIDDevReport[] = {0x81, USB_GET_DESCRIPTOR, 0x00, USB_DESCR_TYP_REPORT,
|
||
0x00, 0x00, 0x41, 0x00};
|
||
/* <20><>ȡHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||
__attribute__((aligned(4))) const uint8_t SetupGetHubDescr[] = {HUB_GET_HUB_DESCRIPTOR, HUB_GET_DESCRIPTOR, 0x00,
|
||
USB_DESCR_TYP_HUB, 0x00, 0x00, sizeof(USB_HUB_DESCR), 0x00};
|
||
|
||
__attribute__((aligned(4))) uint8_t Com_Buffer[128]; // <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ö<><C3B6>ʱ<EFBFBD><CAB1><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ö<>ٽ<EFBFBD><D9BD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
/*********************************************************************
|
||
* @fn AnalyzeHidIntEndp
|
||
*
|
||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>HID<49>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ,<2C><><EFBFBD><EFBFBD>HubPortIndex<65><78>0<EFBFBD><30><EFBFBD>浽ROOTHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ֵ<EFBFBD>浽HUB<55>½ṹ<C2BD><E1B9B9>
|
||
*
|
||
* @param buf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ HubPortIndex<65><78>0<EFBFBD><30>ʾ<EFBFBD><CABE>HUB<55><42><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD>ⲿHUB<55>µĶ˿ں<CBBF>
|
||
*
|
||
* @return <20>˵<EFBFBD><CBB5><EFBFBD>
|
||
*/
|
||
uint8_t AnalyzeHidIntEndp(uint8_t *buf, uint8_t HubPortIndex)
|
||
{
|
||
uint8_t i, s, l;
|
||
s = 0;
|
||
|
||
if(HubPortIndex)
|
||
{
|
||
memset(DevOnHubPort[HubPortIndex - 1].GpVar, 0, sizeof(DevOnHubPort[HubPortIndex - 1].GpVar)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
else
|
||
{
|
||
memset(ThisUsbDev.GpVar, 0, sizeof(ThisUsbDev.GpVar)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
|
||
for(i = 0; i < ((PUSB_CFG_DESCR)buf)->wTotalLength; i += l) // <20><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͽӿ<CDBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
{
|
||
if(((PUSB_ENDP_DESCR)(buf + i))->bDescriptorType == USB_DESCR_TYP_ENDP // <20>Ƕ˵<C7B6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
&& (((PUSB_ENDP_DESCR)(buf + i))->bmAttributes & USB_ENDP_TYPE_MASK) == USB_ENDP_TYPE_INTER // <20><><EFBFBD>ж϶˵<CFB6>
|
||
&& (((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_DIR_MASK)) // <20><>IN<49>˵<EFBFBD>
|
||
{ // <20><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ,λ7<CEBB><37><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>־λ,<2C><>0
|
||
if(HubPortIndex)
|
||
{
|
||
DevOnHubPort[HubPortIndex - 1].GpVar[s] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||
}
|
||
else
|
||
{
|
||
ThisUsbDev.GpVar[s] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK; // <20>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>wMaxPacketSize<7A><65>bInterval
|
||
}
|
||
PRINT("%02x ", (uint16_t)ThisUsbDev.GpVar[s]);
|
||
s++;
|
||
if(s >= 4)
|
||
{
|
||
break; //ֻ<><D6BB><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD>˵<EFBFBD>
|
||
}
|
||
}
|
||
l = ((PUSB_ENDP_DESCR)(buf + i))->bLength; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>
|
||
if(l > 16)
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
PRINT("\n");
|
||
return (s);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn AnalyzeBulkEndp
|
||
*
|
||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>,GpVar[0]<5D><>GpVar[1]<5D><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>˵㡣GpVar[2]<5D><>GpVar[3]<5D><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4>˵<EFBFBD>
|
||
*
|
||
* @param buf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ HubPortIndex<65><78>0<EFBFBD><30>ʾ<EFBFBD><CABE>HUB<55><42><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD>ⲿHUB<55>µĶ˿ں<CBBF>
|
||
*
|
||
* @return 0
|
||
*/
|
||
uint8_t AnalyzeBulkEndp(uint8_t *buf, uint8_t HubPortIndex)
|
||
{
|
||
uint8_t i, s1, s2, l;
|
||
s1 = 0;
|
||
s2 = 2;
|
||
|
||
if(HubPortIndex)
|
||
{
|
||
memset(DevOnHubPort[HubPortIndex - 1].GpVar, 0, sizeof(DevOnHubPort[HubPortIndex - 1].GpVar)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
else
|
||
{
|
||
memset(ThisUsbDev.GpVar, 0, sizeof(ThisUsbDev.GpVar)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
|
||
for(i = 0; i < ((PUSB_CFG_DESCR)buf)->wTotalLength; i += l) // <20><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͽӿ<CDBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
{
|
||
if((((PUSB_ENDP_DESCR)(buf + i))->bDescriptorType == USB_DESCR_TYP_ENDP) // <20>Ƕ˵<C7B6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
&& ((((PUSB_ENDP_DESCR)(buf + i))->bmAttributes & USB_ENDP_TYPE_MASK) == USB_ENDP_TYPE_BULK)) // <20><><EFBFBD>ж϶˵<CFB6>
|
||
|
||
{
|
||
if(HubPortIndex)
|
||
{
|
||
if(((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_DIR_MASK)
|
||
{
|
||
DevOnHubPort[HubPortIndex - 1].GpVar[s1++] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||
}
|
||
else
|
||
{
|
||
DevOnHubPort[HubPortIndex - 1].GpVar[s2++] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_DIR_MASK)
|
||
{
|
||
ThisUsbDev.GpVar[s1++] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||
}
|
||
else
|
||
{
|
||
ThisUsbDev.GpVar[s2++] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||
}
|
||
}
|
||
|
||
if(s1 == 2)
|
||
{
|
||
s1 = 1;
|
||
}
|
||
if(s2 == 4)
|
||
{
|
||
s2 = 3;
|
||
}
|
||
}
|
||
l = ((PUSB_ENDP_DESCR)(buf + i))->bLength; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>
|
||
if(l > 16)
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
return (0);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn InitRootDevice
|
||
*
|
||
* @brief <20><>ʼ<EFBFBD><CABC>ָ<EFBFBD><D6B8>ROOT-HUB<55>˿ڵ<CBBF>USB<53>豸
|
||
*
|
||
* @param none
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t InitRootDevice(void)
|
||
{
|
||
uint8_t i, s;
|
||
uint8_t cfg, dv_cls, if_cls;
|
||
|
||
PRINT("Reset host port\n");
|
||
ResetRootHubPort(); // <20><><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>,<2C><>λ<EFBFBD><CEBB>Ӧ<EFBFBD>˿ڵ<CBBF>USB<53><42><EFBFBD><EFBFBD>
|
||
for(i = 0, s = 0; i < 100; i++)
|
||
{ // <20>ȴ<EFBFBD>USB<53>豸<EFBFBD><E8B1B8>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,100mS<6D><53>ʱ
|
||
mDelaymS(1);
|
||
if(EnableRootHubPort() == ERR_SUCCESS)
|
||
{ // ʹ<>ܶ˿<DCB6>
|
||
i = 0;
|
||
s++;
|
||
if(s > 100)
|
||
{
|
||
break; // <20>Ѿ<EFBFBD><D1BE>ȶ<EFBFBD><C8B6><EFBFBD><EFBFBD><EFBFBD>100mS
|
||
}
|
||
}
|
||
}
|
||
if(i)
|
||
{ // <20><>λ<EFBFBD><CEBB><EFBFBD>豸û<E8B1B8><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
DisableRootHubPort();
|
||
PRINT("Disable host port because of disconnect\n");
|
||
return (ERR_USB_DISCON);
|
||
}
|
||
SetUsbSpeed(ThisUsbDev.DeviceSpeed); // <20><><EFBFBD>õ<EFBFBD>ǰUSB<53>ٶ<EFBFBD>
|
||
|
||
PRINT("GetDevDescr: ");
|
||
s = CtrlGetDeviceDescr(); // <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
for(i = 0; i < ((PUSB_SETUP_REQ)SetupGetDevDescr)->wLength; i++)
|
||
{
|
||
PRINT("x%02X ", (uint16_t)(Com_Buffer[i]));
|
||
}
|
||
PRINT("\n");
|
||
|
||
ThisUsbDev.DeviceVID = ((PUSB_DEV_DESCR)Com_Buffer)->idVendor; //<2F><><EFBFBD><EFBFBD>VID PID<49><44>Ϣ
|
||
ThisUsbDev.DevicePID = ((PUSB_DEV_DESCR)Com_Buffer)->idProduct;
|
||
dv_cls = ((PUSB_DEV_DESCR)Com_Buffer)->bDeviceClass;
|
||
|
||
s = CtrlSetUsbAddress(((PUSB_SETUP_REQ)SetupSetUsbAddr)->wValue);
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
ThisUsbDev.DeviceAddress = ((PUSB_SETUP_REQ)SetupSetUsbAddr)->wValue; // <20><><EFBFBD><EFBFBD>USB<53><42>ַ
|
||
|
||
PRINT("GetCfgDescr: ");
|
||
s = CtrlGetConfigDescr();
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
for(i = 0; i < ((PUSB_CFG_DESCR)Com_Buffer)->wTotalLength; i++)
|
||
{
|
||
PRINT("x%02X ", (uint16_t)(Com_Buffer[i]));
|
||
}
|
||
PRINT("\n");
|
||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ȡ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ַ/<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>С<EFBFBD><D0A1>,<2C><><EFBFBD>±<EFBFBD><C2B1><EFBFBD>endp_addr<64><72>endp_size<7A><65> */
|
||
cfg = ((PUSB_CFG_DESCR)Com_Buffer)->bConfigurationValue;
|
||
if_cls = ((PUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceClass; // <20>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
if((dv_cls == 0x00) && (if_cls == USB_DEV_CLASS_STORAGE))
|
||
{ // <20><>USB<53>洢<EFBFBD><E6B4A2><EFBFBD>豸,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>U<EFBFBD><55>
|
||
#ifdef FOR_ROOT_UDISK_ONLY
|
||
CHRV3DiskStatus = DISK_USB_ADDR;
|
||
return (ERR_SUCCESS);
|
||
}
|
||
else
|
||
{
|
||
return (ERR_USB_UNSUPPORT);
|
||
}
|
||
#else
|
||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||
ThisUsbDev.DeviceType = USB_DEV_CLASS_STORAGE;
|
||
PRINT("USB-Disk Ready\n");
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (ERR_SUCCESS);
|
||
}
|
||
}
|
||
else if((dv_cls == 0x00) && (if_cls == USB_DEV_CLASS_PRINTER) && ((PUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceSubClass == 0x01)
|
||
{ // <20>Ǵ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD>豸
|
||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
// <09>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||
ThisUsbDev.DeviceType = USB_DEV_CLASS_PRINTER;
|
||
PRINT("USB-Print Ready\n");
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (ERR_SUCCESS);
|
||
}
|
||
}
|
||
else if((dv_cls == 0x00) && (if_cls == USB_DEV_CLASS_HID) && ((PUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceSubClass <= 0x01)
|
||
{ // <20><>HID<49><44><EFBFBD>豸,<2C><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>HID<49>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ
|
||
s = AnalyzeHidIntEndp(Com_Buffer, 0); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>HID<49>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ
|
||
PRINT("AnalyzeHidIntEndp %02x\n", (uint16_t)s);
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ,λ7<CEBB><37><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>־λ,<2C><>0
|
||
if_cls = ((PUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceProtocol;
|
||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
// Set_Idle( );
|
||
// <09>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||
if(if_cls == 1)
|
||
{
|
||
ThisUsbDev.DeviceType = DEV_TYPE_KEYBOARD;
|
||
// <09><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>,<2C><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>LED<45><44>
|
||
PRINT("USB-Keyboard Ready\n");
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (ERR_SUCCESS);
|
||
}
|
||
else if(if_cls == 2)
|
||
{
|
||
ThisUsbDev.DeviceType = DEV_TYPE_MOUSE;
|
||
// Ϊ<><CEAA><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>״̬,Ӧ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ȡ<><C8A1><EFBFBD>ж϶˿ڵĵ<DAB5>ַ,<2C><><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>Ϣ
|
||
PRINT("USB-Mouse Ready\n");
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (ERR_SUCCESS);
|
||
}
|
||
s = ERR_USB_UNSUPPORT;
|
||
}
|
||
}
|
||
else if(dv_cls == USB_DEV_CLASS_HUB)
|
||
{ // <20><>HUB<55><42><EFBFBD>豸,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
s = CtrlGetHubDescr();
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
PRINT("Max Port:%02X ", (((PXUSB_HUB_DESCR)Com_Buffer)->bNbrPorts));
|
||
ThisUsbDev.GpHUBPortNum = ((PXUSB_HUB_DESCR)Com_Buffer)->bNbrPorts; // <20><><EFBFBD><EFBFBD>HUB<55>Ķ˿<C4B6><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||
if(ThisUsbDev.GpHUBPortNum > HUB_MAX_PORTS)
|
||
{
|
||
ThisUsbDev.GpHUBPortNum = HUB_MAX_PORTS; // <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ṹDevOnHubPortʱ<74><CAB1>Ϊ<EFBFBD>ٶ<EFBFBD>ÿ<EFBFBD><C3BF>HUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB_MAX_PORTS<54><53><EFBFBD>˿<EFBFBD>
|
||
}
|
||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||
ThisUsbDev.DeviceType = USB_DEV_CLASS_HUB;
|
||
//<2F>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB<55>¼<EFBFBD>֪ͨ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ò<EFBFBD>ѯ״̬<D7B4><CCAC><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
//<2F><>HUB<55><42><EFBFBD>˿<EFBFBD><CBBF>ϵ<EFBFBD>,<2C><>ѯ<EFBFBD><D1AF><EFBFBD>˿<EFBFBD>״̬,<2C><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>ӵ<EFBFBD>HUB<55>˿<EFBFBD>,<2C><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||
for(i = 1; i <= ThisUsbDev.GpHUBPortNum; i++) // <20><>HUB<55><42><EFBFBD>˿ڶ<CBBF><DAB6>ϵ<EFBFBD>
|
||
{
|
||
DevOnHubPort[i - 1].DeviceStatus = ROOT_DEV_DISCONNECT; // <20><><EFBFBD>ⲿHUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>״̬
|
||
s = HubSetPortFeature(i, HUB_PORT_POWER);
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
PRINT("Ext-HUB Port_%1d# power on error\n", (uint16_t)i); // <20>˿<EFBFBD><CBBF>ϵ<EFBFBD>ʧ<EFBFBD><CAA7>
|
||
}
|
||
}
|
||
PRINT("USB-HUB Ready\n");
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (ERR_SUCCESS);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{ // <20><><EFBFBD>Խ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
// <09>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||
ThisUsbDev.DeviceType = DEV_TYPE_UNKNOW;
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (ERR_SUCCESS); /* δ֪<CEB4>豸<EFBFBD><E8B1B8>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD> */
|
||
}
|
||
}
|
||
#endif
|
||
}
|
||
}
|
||
}
|
||
|
||
PRINT("InitRootDev Err = %02X\n", (uint16_t)s);
|
||
#ifdef FOR_ROOT_UDISK_ONLY
|
||
CHRV3DiskStatus = DISK_CONNECT;
|
||
#else
|
||
ThisUsbDev.DeviceStatus = ROOT_DEV_FAILED;
|
||
#endif
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (s);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn InitDevOnHub
|
||
*
|
||
* @brief <20><>ʼ<EFBFBD><CABC>ö<EFBFBD><C3B6><EFBFBD>ⲿHUB<55><42><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>USB<53>豸
|
||
*
|
||
* @param HubPortIndex - ָ<><D6B8><EFBFBD>ⲿHUB
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t InitDevOnHub(uint8_t HubPortIndex)
|
||
{
|
||
uint8_t i, s, cfg, dv_cls, if_cls;
|
||
uint8_t ifc;
|
||
PRINT("Init dev @ExtHub-port_%1d ", (uint16_t)HubPortIndex);
|
||
if(HubPortIndex == 0)
|
||
{
|
||
return (ERR_USB_UNKNOWN);
|
||
}
|
||
SelectHubPort(HubPortIndex); // ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿ڵ<CBBF><DAB5>ⲿHUB<55><42>ָ<EFBFBD><D6B8><EFBFBD>˿<EFBFBD>,ѡ<><D1A1><EFBFBD>ٶ<EFBFBD>
|
||
PRINT("GetDevDescr: ");
|
||
s = CtrlGetDeviceDescr(); // <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
DevOnHubPort[HubPortIndex - 1].DeviceVID = ((uint16_t)((PUSB_DEV_DESCR)Com_Buffer)->idVendor); //<2F><><EFBFBD><EFBFBD>VID PID<49><44>Ϣ
|
||
DevOnHubPort[HubPortIndex - 1].DevicePID = ((uint16_t)((PUSB_DEV_DESCR)Com_Buffer)->idProduct);
|
||
|
||
dv_cls = ((PUSB_DEV_DESCR)Com_Buffer)->bDeviceClass; // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
cfg = (1 << 4) + HubPortIndex; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>USB<53><42>ַ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ص<EFBFBD>
|
||
s = CtrlSetUsbAddress(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>ַ
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
DevOnHubPort[HubPortIndex - 1].DeviceAddress = cfg; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42>ַ
|
||
PRINT("GetCfgDescr: ");
|
||
s = CtrlGetConfigDescr(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
cfg = ((PUSB_CFG_DESCR)Com_Buffer)->bConfigurationValue;
|
||
for(i = 0; i < ((PUSB_CFG_DESCR)Com_Buffer)->wTotalLength; i++)
|
||
{
|
||
PRINT("x%02X ", (uint16_t)(Com_Buffer[i]));
|
||
}
|
||
PRINT("\n");
|
||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ȡ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ַ/<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>С<EFBFBD><D0A1>,<2C><><EFBFBD>±<EFBFBD><C2B1><EFBFBD>endp_addr<64><72>endp_size<7A><65> */
|
||
if_cls = ((PXUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceClass; // <20>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if(dv_cls == 0x00 && if_cls == USB_DEV_CLASS_STORAGE) // <20><>USB<53>洢<EFBFBD><E6B4A2><EFBFBD>豸,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>U<EFBFBD><55>
|
||
{
|
||
AnalyzeBulkEndp(Com_Buffer, HubPortIndex);
|
||
for(i = 0; i != 4; i++)
|
||
{
|
||
PRINT("%02x ", (uint16_t)DevOnHubPort[HubPortIndex - 1].GpVar[i]);
|
||
}
|
||
PRINT("\n");
|
||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
DevOnHubPort[HubPortIndex - 1].DeviceStatus = ROOT_DEV_SUCCESS;
|
||
DevOnHubPort[HubPortIndex - 1].DeviceType = USB_DEV_CLASS_STORAGE;
|
||
PRINT("USB-Disk Ready\n");
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (ERR_SUCCESS);
|
||
}
|
||
}
|
||
else if((dv_cls == 0x00) && (if_cls == USB_DEV_CLASS_HID) && (((PXUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceSubClass <= 0x01)) // <20><>HID<49><44><EFBFBD>豸,<2C><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
{
|
||
ifc = ((PXUSB_CFG_DESCR_LONG)Com_Buffer)->cfg_descr.bNumInterfaces;
|
||
s = AnalyzeHidIntEndp(Com_Buffer, HubPortIndex); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>HID<49>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ
|
||
PRINT("AnalyzeHidIntEndp %02x\n", (uint16_t)s);
|
||
if_cls = ((PXUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceProtocol;
|
||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
for(dv_cls = 0; dv_cls < ifc; dv_cls++)
|
||
{
|
||
s = CtrlGetHIDDeviceReport(dv_cls); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
for(i = 0; i < 64; i++)
|
||
{
|
||
PRINT("x%02X ", (uint16_t)(Com_Buffer[i]));
|
||
}
|
||
PRINT("\n");
|
||
}
|
||
}
|
||
//<2F>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||
DevOnHubPort[HubPortIndex - 1].DeviceStatus = ROOT_DEV_SUCCESS;
|
||
if(if_cls == 1)
|
||
{
|
||
DevOnHubPort[HubPortIndex - 1].DeviceType = DEV_TYPE_KEYBOARD;
|
||
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>,<2C><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>LED<45><44>
|
||
if(ifc > 1)
|
||
{
|
||
PRINT("USB_DEV_CLASS_HID Ready\n");
|
||
DevOnHubPort[HubPortIndex - 1].DeviceType = USB_DEV_CLASS_HID; //<2F><><EFBFBD><EFBFBD>HID<49>豸
|
||
}
|
||
PRINT("USB-Keyboard Ready\n");
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
|
||
return (ERR_SUCCESS);
|
||
}
|
||
else if(if_cls == 2)
|
||
{
|
||
DevOnHubPort[HubPortIndex - 1].DeviceType = DEV_TYPE_MOUSE;
|
||
//Ϊ<><CEAA><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>״̬,Ӧ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ȡ<><C8A1><EFBFBD>ж϶˿ڵĵ<DAB5>ַ,<2C><><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>Ϣ
|
||
if(ifc > 1)
|
||
{
|
||
PRINT("USB_DEV_CLASS_HID Ready\n");
|
||
DevOnHubPort[HubPortIndex - 1].DeviceType = USB_DEV_CLASS_HID; //<2F><><EFBFBD><EFBFBD>HID<49>豸
|
||
}
|
||
PRINT("USB-Mouse Ready\n");
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
|
||
return (ERR_SUCCESS);
|
||
}
|
||
s = ERR_USB_UNSUPPORT;
|
||
}
|
||
}
|
||
else if(dv_cls == USB_DEV_CLASS_HUB) // <20><>HUB<55><42><EFBFBD>豸,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
{
|
||
DevOnHubPort[HubPortIndex - 1].DeviceType = USB_DEV_CLASS_HUB;
|
||
PRINT("This program don't support Level 2 HUB\n"); // <20><>Ҫ֧<D2AA>ֶ༶HUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><CEBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ
|
||
s = HubClearPortFeature(i, HUB_PORT_ENABLE); // <20><>ֹHUB<55>˿<EFBFBD>
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
s = ERR_USB_UNSUPPORT;
|
||
}
|
||
else //<2F><><EFBFBD><EFBFBD><EFBFBD>豸
|
||
{
|
||
AnalyzeBulkEndp(Com_Buffer, HubPortIndex); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>
|
||
for(i = 0; i != 4; i++)
|
||
{
|
||
PRINT("%02x ", (uint16_t)DevOnHubPort[HubPortIndex - 1].GpVar[i]);
|
||
}
|
||
PRINT("\n");
|
||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
if(s == ERR_SUCCESS)
|
||
{
|
||
//<2F>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||
DevOnHubPort[HubPortIndex - 1].DeviceStatus = ROOT_DEV_SUCCESS;
|
||
DevOnHubPort[HubPortIndex - 1].DeviceType = dv_cls ? dv_cls : if_cls;
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (ERR_SUCCESS); //δ֪<CEB4>豸<EFBFBD><E8B1B8>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>
|
||
}
|
||
}
|
||
PRINT("InitDevOnHub Err = %02X\n", (uint16_t)s);
|
||
DevOnHubPort[HubPortIndex - 1].DeviceStatus = ROOT_DEV_FAILED;
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
return (s);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn EnumHubPort
|
||
*
|
||
* @brief ö<><C3B6>ָ<EFBFBD><D6B8>ROOT-HUB<55>˿<EFBFBD><CBBF>ϵ<EFBFBD><CFB5>ⲿHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>˿<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB>Ƴ<EFBFBD><C6B3>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸
|
||
*
|
||
* @param RootHubIndex - ROOT_HUB0<42><30>ROOT_HUB1
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t EnumHubPort()
|
||
{
|
||
uint8_t i, s;
|
||
|
||
for(i = 1; i <= ThisUsbDev.GpHUBPortNum; i++) // <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ˿<C4B6><CBBF>Ƿ<EFBFBD><C7B7>б仯
|
||
{
|
||
SelectHubPort(0); // ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD>,<2C><><EFBFBD>õ<EFBFBD>ǰUSB<53>ٶ<EFBFBD><D9B6>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>USB<53><42>ַ
|
||
s = HubGetPortStatus(i); // <20><>ȡ<EFBFBD>˿<EFBFBD>״̬
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||
}
|
||
if(((Com_Buffer[0] & (1 << (HUB_PORT_CONNECTION & 0x07))) && (Com_Buffer[2] & (1 << (HUB_C_PORT_CONNECTION & 0x07)))) || (Com_Buffer[2] == 0x10))
|
||
{ // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
DevOnHubPort[i - 1].DeviceStatus = ROOT_DEV_CONNECTED; // <20><><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
DevOnHubPort[i - 1].DeviceAddress = 0x00;
|
||
s = HubGetPortStatus(i); // <20><>ȡ<EFBFBD>˿<EFBFBD>״̬
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||
}
|
||
DevOnHubPort[i - 1].DeviceSpeed = Com_Buffer[1] & (1 << (HUB_PORT_LOW_SPEED & 0x07)) ? 0 : 1; // <20><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>ȫ<EFBFBD><C8AB>
|
||
if(DevOnHubPort[i - 1].DeviceSpeed)
|
||
{
|
||
PRINT("Found full speed device on port %1d\n", (uint16_t)i);
|
||
}
|
||
else
|
||
{
|
||
PRINT("Found low speed device on port %1d\n", (uint16_t)i);
|
||
}
|
||
mDelaymS(200); // <20>ȴ<EFBFBD><C8B4>豸<EFBFBD>ϵ<EFBFBD><CFB5>ȶ<EFBFBD>
|
||
s = HubSetPortFeature(i, HUB_PORT_RESET); // <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>ӵĶ˿ڸ<CBBF>λ
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||
}
|
||
PRINT("Reset port and then wait in\n");
|
||
do // <20><>ѯ<EFBFBD><D1AF>λ<EFBFBD>˿<EFBFBD>,ֱ<><D6B1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>״̬<D7B4><CCAC>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||
{
|
||
mDelaymS(1);
|
||
s = HubGetPortStatus(i);
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||
}
|
||
} while(Com_Buffer[0] & (1 << (HUB_PORT_RESET & 0x07))); // <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>ڸ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ȴ<EFBFBD>
|
||
mDelaymS(100);
|
||
s = HubClearPortFeature(i, HUB_C_PORT_RESET); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ɱ<EFBFBD>־
|
||
// s = HubSetPortFeature( i, HUB_PORT_ENABLE ); // <20><><EFBFBD><EFBFBD>HUB<55>˿<EFBFBD>
|
||
s = HubClearPortFeature(i, HUB_C_PORT_CONNECTION); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB>Ƴ<EFBFBD><C6B3>仯<EFBFBD><E4BBAF>־
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
s = HubGetPortStatus(i); // <20>ٶ<EFBFBD>ȡ״̬,<2C><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
if((Com_Buffer[0] & (1 << (HUB_PORT_CONNECTION & 0x07))) == 0)
|
||
{
|
||
DevOnHubPort[i - 1].DeviceStatus = ROOT_DEV_DISCONNECT; // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
s = InitDevOnHub(i); // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
}
|
||
else if(Com_Buffer[2] & (1 << (HUB_C_PORT_ENABLE & 0x07))) // <20>豸<EFBFBD><E8B1B8><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD>
|
||
{
|
||
HubClearPortFeature(i, HUB_C_PORT_ENABLE); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD>־
|
||
PRINT("Device on port error\n");
|
||
s = HubSetPortFeature(i, HUB_PORT_RESET); // <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>ӵĶ˿ڸ<CBBF>λ
|
||
if(s != ERR_SUCCESS)
|
||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||
do // <20><>ѯ<EFBFBD><D1AF>λ<EFBFBD>˿<EFBFBD>,ֱ<><D6B1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>״̬<D7B4><CCAC>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||
{
|
||
mDelaymS(1);
|
||
s = HubGetPortStatus(i);
|
||
if(s != ERR_SUCCESS)
|
||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||
} while(Com_Buffer[0] & (1 << (HUB_PORT_RESET & 0x07))); // <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>ڸ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ȴ<EFBFBD>
|
||
}
|
||
else if((Com_Buffer[0] & (1 << (HUB_PORT_CONNECTION & 0x07))) == 0) // <20>豸<EFBFBD>Ѿ<EFBFBD><D1BE>Ͽ<EFBFBD>
|
||
{
|
||
if(DevOnHubPort[i - 1].DeviceStatus >= ROOT_DEV_CONNECTED)
|
||
{
|
||
PRINT("Device on port %1d removed\n", (uint16_t)i);
|
||
}
|
||
DevOnHubPort[i - 1].DeviceStatus = ROOT_DEV_DISCONNECT; // <20><><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
if(Com_Buffer[2] & (1 << (HUB_C_PORT_CONNECTION & 0x07)))
|
||
{
|
||
HubClearPortFeature(i, HUB_C_PORT_CONNECTION); // <20><><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><C6B3>仯<EFBFBD><E4BBAF>־
|
||
}
|
||
}
|
||
}
|
||
return (ERR_SUCCESS); // <20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn EnumAllHubPort
|
||
*
|
||
* @brief ö<><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>ⲿHUB<55><42><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>USB<53>豸
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t EnumAllHubPort(void)
|
||
{
|
||
uint8_t s;
|
||
|
||
if((ThisUsbDev.DeviceStatus >= ROOT_DEV_SUCCESS) && (ThisUsbDev.DeviceType == USB_DEV_CLASS_HUB)) // HUBö<42>ٳɹ<D9B3>
|
||
{
|
||
SelectHubPort(0); // ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD>,<2C><><EFBFBD>õ<EFBFBD>ǰUSB<53>ٶ<EFBFBD><D9B6>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>USB<53><42>ַ
|
||
s = EnumHubPort(); // ö<><C3B6>ָ<EFBFBD><D6B8>ROOT-HUB<55>˿<EFBFBD><CBBF>ϵ<EFBFBD><CFB5>ⲿHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>˿<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB>Ƴ<EFBFBD><C6B3>¼<EFBFBD>
|
||
if(s != ERR_SUCCESS) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||
{
|
||
PRINT("EnumAllHubPort err = %02X\n", (uint16_t)s);
|
||
}
|
||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||
}
|
||
return (ERR_SUCCESS);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn SearchTypeDevice
|
||
*
|
||
* @brief <20><>ROOT-HUB<55>Լ<EFBFBD><D4BC>ⲿHUB<55><42><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5>豸<EFBFBD><E8B1B8><EFBFBD>ڵĶ˿ں<CBBF>,<2C><><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>Ϊ0xFFFF<46><46>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||
* <20><>ȻҲ<C8BB><D2B2><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD>USB<53>ij<EFBFBD><C4B3><EFBFBD>VID<49><44>ƷPID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>¼<EFBFBD><C2BC><EFBFBD>豸<EFBFBD><E8B1B8>VID<49><44>PID),<2C>Լ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*
|
||
* @param type - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8λΪROOT-HUB<55>˿ں<CBBF>,<2C><>8λΪ<CEBB>ⲿHUB<55>Ķ˿ں<CBBF>,<2C><>8λΪ0<CEAA><30><EFBFBD>豸ֱ<E8B1B8><D6B1><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD><CBBF><EFBFBD>
|
||
*/
|
||
uint16_t SearchTypeDevice(uint8_t type)
|
||
{
|
||
uint8_t RootHubIndex; //CH554ֻ<34><D6BB>һ<EFBFBD><D2BB>USB<53><42>,RootHubIndex = 0,ֻ<>迴<EFBFBD><E8BFB4><EFBFBD><EFBFBD>ֵ<EFBFBD>ĵͰ<C4B5>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||
uint8_t HubPortIndex;
|
||
|
||
RootHubIndex = 0;
|
||
if((ThisUsbDev.DeviceType == USB_DEV_CLASS_HUB) && (ThisUsbDev.DeviceStatus >= ROOT_DEV_SUCCESS)) // <20>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB<55><42>ö<EFBFBD>ٳɹ<D9B3>
|
||
{
|
||
for(HubPortIndex = 1; HubPortIndex <= ThisUsbDev.GpHUBPortNum; HubPortIndex++) // <20><><EFBFBD><EFBFBD><EFBFBD>ⲿHUB<55>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>˿<EFBFBD>
|
||
{
|
||
if(DevOnHubPort[HubPortIndex - 1].DeviceType == type && DevOnHubPort[HubPortIndex - 1].DeviceStatus >= ROOT_DEV_SUCCESS)
|
||
{
|
||
return (((uint16_t)RootHubIndex << 8) | HubPortIndex); // <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ö<EFBFBD>ٳɹ<D9B3>
|
||
}
|
||
}
|
||
}
|
||
if((ThisUsbDev.DeviceType == type) && (ThisUsbDev.DeviceStatus >= ROOT_DEV_SUCCESS))
|
||
{
|
||
return ((uint16_t)RootHubIndex << 8); // <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ö<EFBFBD>ٳɹ<D9B3>,<2C><>ROOT-HUB<55>˿<EFBFBD><CBBF><EFBFBD>
|
||
}
|
||
|
||
return (0xFFFF);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn SETorOFFNumLock
|
||
*
|
||
* @brief NumLock<63>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>ж<EFBFBD>
|
||
*
|
||
* @param buf - <20><><EFBFBD>Ƽ<EFBFBD>ֵ
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t SETorOFFNumLock(uint8_t *buf)
|
||
{
|
||
uint8_t tmp[] = {0x21, 0x09, 0x00, 0x02, 0x00, 0x00, 0x01, 0x00};
|
||
uint8_t len, s;
|
||
if((buf[2] == 0x53) & (buf[0] | buf[1] | buf[3] | buf[4] | buf[5] | buf[6] | buf[7] == 0))
|
||
{
|
||
for(s = 0; s != sizeof(tmp); s++)
|
||
{
|
||
((uint8_t *)pSetupReq)[s] = tmp[s];
|
||
}
|
||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
}
|
||
return (ERR_SUCCESS);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn CtrlGetHIDDeviceReport
|
||
*
|
||
* @brief <20><>ȡHID<49>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TxBuffer<65><72>
|
||
*
|
||
* @param none
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t CtrlGetHIDDeviceReport(uint8_t infc)
|
||
{
|
||
uint8_t s;
|
||
uint8_t len;
|
||
|
||
CopySetupReqPkg((int8_t *)SetupSetHIDIdle);
|
||
pSetupReq->wIndex = infc;
|
||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
|
||
CopySetupReqPkg((int8_t *)SetupGetHIDDevReport);
|
||
pSetupReq->wIndex = infc;
|
||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
|
||
return (ERR_SUCCESS);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn CtrlGetHubDescr
|
||
*
|
||
* @brief <20><>ȡHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Com_Buffer<65><72>
|
||
*
|
||
* @param none
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t CtrlGetHubDescr(void)
|
||
{
|
||
uint8_t s;
|
||
uint8_t len;
|
||
|
||
CopySetupReqPkg((int8_t *)SetupGetHubDescr);
|
||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
if(len < ((PUSB_SETUP_REQ)SetupGetHubDescr)->wLength)
|
||
{
|
||
return (ERR_USB_BUF_OVER); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||
}
|
||
// if ( len < 4 ) return( ERR_USB_BUF_OVER ); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||
return (ERR_SUCCESS);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn HubGetPortStatus
|
||
*
|
||
* @brief <20><>ѯHUB<55>˿<EFBFBD>״̬,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Com_Buffer<65><72>
|
||
*
|
||
* @param HubPortIndex - <20>˿ں<CBBF>
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t HubGetPortStatus(uint8_t HubPortIndex)
|
||
{
|
||
uint8_t s;
|
||
uint8_t len;
|
||
|
||
pSetupReq->bRequestType = HUB_GET_PORT_STATUS;
|
||
pSetupReq->bRequest = HUB_GET_STATUS;
|
||
pSetupReq->wValue = 0x0000;
|
||
pSetupReq->wIndex = 0x0000 | HubPortIndex;
|
||
pSetupReq->wLength = 0x0004;
|
||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||
if(s != ERR_SUCCESS)
|
||
{
|
||
return (s);
|
||
}
|
||
if(len < 4)
|
||
{
|
||
return (ERR_USB_BUF_OVER); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||
}
|
||
return (ERR_SUCCESS);
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn HubSetPortFeature
|
||
*
|
||
* @brief <20><><EFBFBD><EFBFBD>HUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||
*
|
||
* @param HubPortIndex - <20>˿ں<CBBF>
|
||
* @param FeatureSelt - <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t HubSetPortFeature(uint8_t HubPortIndex, uint8_t FeatureSelt)
|
||
{
|
||
pSetupReq->bRequestType = HUB_SET_PORT_FEATURE;
|
||
pSetupReq->bRequest = HUB_SET_FEATURE;
|
||
pSetupReq->wValue = 0x0000 | FeatureSelt;
|
||
pSetupReq->wIndex = 0x0000 | HubPortIndex;
|
||
pSetupReq->wLength = 0x0000;
|
||
return (HostCtrlTransfer(NULL, NULL)); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn HubClearPortFeature
|
||
*
|
||
* @brief <20><><EFBFBD><EFBFBD>HUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||
*
|
||
* @param HubPortIndex - <20>˿ں<CBBF>
|
||
* @param FeatureSelt - <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||
*
|
||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t HubClearPortFeature(uint8_t HubPortIndex, uint8_t FeatureSelt)
|
||
{
|
||
pSetupReq->bRequestType = HUB_CLEAR_PORT_FEATURE;
|
||
pSetupReq->bRequest = HUB_CLEAR_FEATURE;
|
||
pSetupReq->wValue = 0x0000 | FeatureSelt;
|
||
pSetupReq->wIndex = 0x0000 | HubPortIndex;
|
||
pSetupReq->wLength = 0x0000;
|
||
return (HostCtrlTransfer(NULL, NULL)); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||
}
|