forked from xuos/xiuos
fix third_party_usb/usbhost data format bugs
This commit is contained in:
parent
a21ca4af2a
commit
a7baf1e7ed
|
@ -58,6 +58,10 @@ menu "aiit-riscv64-board feature"
|
||||||
bool "mount cd card"
|
bool "mount cd card"
|
||||||
default n
|
default n
|
||||||
select BSP_USING_SDIO
|
select BSP_USING_SDIO
|
||||||
|
config MOUNT_USB
|
||||||
|
bool "mount usb"
|
||||||
|
default n
|
||||||
|
select BSP_USING_USB
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
@ -64,13 +64,24 @@ extern int HwRtcInit(void);
|
||||||
extern int HwTouchBusInit(void);
|
extern int HwTouchBusInit(void);
|
||||||
extern int HwCh376Init(void);
|
extern int HwCh376Init(void);
|
||||||
|
|
||||||
#if defined(FS_VFS) && defined(MOUNT_SDCARD)
|
#ifdef FS_CH376
|
||||||
#include <iot-vfs.h>
|
#include <iot-vfs.h>
|
||||||
|
#ifdef MOUNT_USB
|
||||||
/**
|
/**
|
||||||
* @description: Mount SD card
|
* @description: Mount USB
|
||||||
* @return 0
|
* @return 0
|
||||||
*/
|
*/
|
||||||
|
int MountUSB(void)
|
||||||
|
{
|
||||||
|
if (MountFilesystem(USB_BUS_NAME, USB_DEVICE_NAME, USB_DRIVER_NAME, FSTYPE_CH376, "/") == 0)
|
||||||
|
KPrintf("usb mount to '/'");
|
||||||
|
else
|
||||||
|
KPrintf("usb mount to '/' failed!");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef MOUNT_SDCARD
|
||||||
/**
|
/**
|
||||||
* @description: Mount SD card
|
* @description: Mount SD card
|
||||||
* @return 0
|
* @return 0
|
||||||
|
@ -85,6 +96,7 @@ int MountSDCard(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
void init_bss(void)
|
void init_bss(void)
|
||||||
{
|
{
|
||||||
|
@ -185,6 +197,9 @@ struct InitSequenceDesc _board_init[] =
|
||||||
#ifdef BSP_USING_SDIO
|
#ifdef BSP_USING_SDIO
|
||||||
{ "hw_sdio", HwCh376Init},
|
{ "hw_sdio", HwCh376Init},
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef BSP_USING_USB
|
||||||
|
{ "hw_usb", HwCh376Init},
|
||||||
|
#endif
|
||||||
#ifdef BSP_USING_TOUCH
|
#ifdef BSP_USING_TOUCH
|
||||||
{ "hw_touch", HwTouchBusInit},
|
{ "hw_touch", HwTouchBusInit},
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,6 +43,7 @@ extern int Ch376fsInit(void);
|
||||||
extern int LibcSystemInit(void);
|
extern int LibcSystemInit(void);
|
||||||
extern int RtcNtpSyncInit(void);
|
extern int RtcNtpSyncInit(void);
|
||||||
extern int MountSDCard(void);
|
extern int MountSDCard(void);
|
||||||
|
extern int MountUSB(void);
|
||||||
extern int DfsMountTable(void);
|
extern int DfsMountTable(void);
|
||||||
extern int userShellInit(void);
|
extern int userShellInit(void);
|
||||||
extern int STM32USBHostRegister(void);
|
extern int STM32USBHostRegister(void);
|
||||||
|
|
|
@ -109,6 +109,10 @@ struct InitSequenceDesc env_init[] =
|
||||||
{ "MountSDCard", MountSDCard },
|
{ "MountSDCard", MountSDCard },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MOUNT_USB
|
||||||
|
{ "MountUSB", MountUSB },
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FS_VFS_MNTTABLE
|
#ifdef FS_VFS_MNTTABLE
|
||||||
{ "DfsMountTable", DfsMountTable },
|
{ "DfsMountTable", DfsMountTable },
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,6 +40,12 @@ Modification:
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARCH_CPU_64BIT
|
||||||
|
typedef uint64 x_usb_format;
|
||||||
|
#else
|
||||||
|
typedef uint32 x_usb_format;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define USB_MAX_DEVICE 0x20
|
#define USB_MAX_DEVICE 0x20
|
||||||
#define USB_MAX_INTERFACE 0x08
|
#define USB_MAX_INTERFACE 0x08
|
||||||
#define USB_HUB_PORT_NUM 0x04
|
#define USB_HUB_PORT_NUM 0x04
|
||||||
|
|
|
@ -491,14 +491,14 @@ x_err_t UsbhClearFeature(UinstPointer device, int endpoint, int feature)
|
||||||
x_err_t UsbhGetInterfaceDescriptor(UcfgDescPointer CfgDesc, int num,
|
x_err_t UsbhGetInterfaceDescriptor(UcfgDescPointer CfgDesc, int num,
|
||||||
UintfDescPointer* IntfDesc)
|
UintfDescPointer* IntfDesc)
|
||||||
{
|
{
|
||||||
uint32 ptr, depth = 0;
|
x_usb_format ptr, depth = 0;
|
||||||
UdescPointer desc;
|
UdescPointer desc;
|
||||||
|
|
||||||
|
|
||||||
NULL_PARAM_CHECK(CfgDesc);
|
NULL_PARAM_CHECK(CfgDesc);
|
||||||
|
|
||||||
ptr = (uint32)CfgDesc + CfgDesc->bLength;
|
ptr = (x_usb_format)CfgDesc + CfgDesc->bLength;
|
||||||
while(ptr < (uint32)CfgDesc + CfgDesc->wTotalLength)
|
while(ptr < (x_usb_format)CfgDesc + CfgDesc->wTotalLength)
|
||||||
{
|
{
|
||||||
if(depth++ > 0x20)
|
if(depth++ > 0x20)
|
||||||
{
|
{
|
||||||
|
@ -517,7 +517,7 @@ x_err_t UsbhGetInterfaceDescriptor(UcfgDescPointer CfgDesc, int num,
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr = (uint32)desc + desc->bLength;
|
ptr = (x_usb_format)desc + desc->bLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
KPrintf("usb_get_interface_descriptor %d failed\n", num);
|
KPrintf("usb_get_interface_descriptor %d failed\n", num);
|
||||||
|
@ -538,7 +538,7 @@ x_err_t UsbhGetEndpointDescriptor(UintfDescPointer IntfDesc, int num,
|
||||||
UepDescPointer* EpDesc)
|
UepDescPointer* EpDesc)
|
||||||
{
|
{
|
||||||
int count = 0, depth = 0;
|
int count = 0, depth = 0;
|
||||||
uint32 ptr;
|
x_usb_format ptr;
|
||||||
UdescPointer desc;
|
UdescPointer desc;
|
||||||
|
|
||||||
|
|
||||||
|
@ -546,7 +546,7 @@ x_err_t UsbhGetEndpointDescriptor(UintfDescPointer IntfDesc, int num,
|
||||||
CHECK(num < IntfDesc->bNumEndpoints);
|
CHECK(num < IntfDesc->bNumEndpoints);
|
||||||
*EpDesc = NONE;
|
*EpDesc = NONE;
|
||||||
|
|
||||||
ptr = (uint32)IntfDesc + IntfDesc->bLength;
|
ptr = (x_usb_format)IntfDesc + IntfDesc->bLength;
|
||||||
while(count < IntfDesc->bNumEndpoints)
|
while(count < IntfDesc->bNumEndpoints)
|
||||||
{
|
{
|
||||||
if(depth++ > 0x20)
|
if(depth++ > 0x20)
|
||||||
|
@ -567,7 +567,7 @@ x_err_t UsbhGetEndpointDescriptor(UintfDescPointer IntfDesc, int num,
|
||||||
}
|
}
|
||||||
else count++;
|
else count++;
|
||||||
}
|
}
|
||||||
ptr = (uint32)desc + desc->bLength;
|
ptr = (x_usb_format)desc + desc->bLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
KPrintf("usb_get_endpoint_descriptor %d failed\n", num);
|
KPrintf("usb_get_endpoint_descriptor %d failed\n", num);
|
||||||
|
|
|
@ -43,13 +43,13 @@ static x_err_t RootHubCtrl(struct uhcd *hcd, uint16 port, uint8 cmd, void *args)
|
||||||
switch(cmd)
|
switch(cmd)
|
||||||
{
|
{
|
||||||
case RH_GET_PORT_STATUS:
|
case RH_GET_PORT_STATUS:
|
||||||
(*(uint32 *)args) = hcd->roothub->PortStatus[port-1];
|
(*(x_usb_format *)args) = hcd->roothub->PortStatus[port-1];
|
||||||
break;
|
break;
|
||||||
case RH_SET_PORT_STATUS:
|
case RH_SET_PORT_STATUS:
|
||||||
hcd->roothub->PortStatus[port-1] = (*(uint32 *)args);
|
hcd->roothub->PortStatus[port-1] = (*(x_usb_format *)args);
|
||||||
break;
|
break;
|
||||||
case RH_CLEAR_PORT_FEATURE:
|
case RH_CLEAR_PORT_FEATURE:
|
||||||
switch(((uint32)args))
|
switch(((x_usb_format)args))
|
||||||
{
|
{
|
||||||
case PORT_FEAT_C_CONNECTION:
|
case PORT_FEAT_C_CONNECTION:
|
||||||
hcd->roothub->PortStatus[port-1] &= ~PORT_CCSC;
|
hcd->roothub->PortStatus[port-1] &= ~PORT_CCSC;
|
||||||
|
@ -69,7 +69,7 @@ static x_err_t RootHubCtrl(struct uhcd *hcd, uint16 port, uint8 cmd, void *args)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RH_SET_PORT_FEATURE:
|
case RH_SET_PORT_FEATURE:
|
||||||
switch((uint32)args)
|
switch((x_usb_format)args)
|
||||||
{
|
{
|
||||||
case PORT_FEAT_CONNECTION:
|
case PORT_FEAT_CONNECTION:
|
||||||
hcd->roothub->PortStatus[port-1] |= PORT_CCSC;
|
hcd->roothub->PortStatus[port-1] |= PORT_CCSC;
|
||||||
|
@ -222,7 +222,7 @@ x_err_t UsbhHubClearPortFeature(UhubPointer hub, uint16 port, uint16 feature)
|
||||||
if(hub->IsRoothub)
|
if(hub->IsRoothub)
|
||||||
{
|
{
|
||||||
RootHubCtrl(hub->hcd, port, RH_CLEAR_PORT_FEATURE,
|
RootHubCtrl(hub->hcd, port, RH_CLEAR_PORT_FEATURE,
|
||||||
(void*)(uint32)feature);
|
(void*)(x_usb_format)feature);
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ x_err_t UsbhHubSetPortFeature(UhubPointer hub, uint16 port,
|
||||||
if(hub->IsRoothub)
|
if(hub->IsRoothub)
|
||||||
{
|
{
|
||||||
RootHubCtrl(hub->hcd, port, RH_SET_PORT_FEATURE,
|
RootHubCtrl(hub->hcd, port, RH_SET_PORT_FEATURE,
|
||||||
(void*)(uint32)feature);
|
(void*)(x_usb_format)feature);
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue