Comments (6)
主机能用就用,不能用就不用,这个 port 并不完善
from cherryusb_wch.
请把失败的所有log贴上来。
from cherryusb_wch.
请把失败的所有log贴上来。
只开启了打印错误的日志,返回-116,一直等待信号量超时,仿真发现是在SETUP(正常)->OUT(出错,程序机制再尝试发送一次就可以成功进入下一个状态IN,但数据应该没发出去,DEVICE端的设备查看日志根本没收到HOST端的数据)->IN(到这个状态就一直收不到DEVICE端的应答,就一直到信号量等待超时了,返回-116)。我使用WCH官方的例程验证上面这个流程是正常的,DEVICE端可以收到这个指令并响应,但它例程处理收发方式是查询寄存器方式,不是采用中断的方式,我对比很久找不出问题来。
`UINT8 HostCtrlTransfer(PUINT8 databuf,PUINT8 len)
{
UINT8 ret;
UINT8 tog = 1;
PUINT8 pBuf;
UINT16 relen;
PUINT8 pLen;
UINT32 rxlen;
pBuf = databuf;
pLen = len;
if( pLen ) *pLen = 0;
Delay_Us( 100 );
USBHSH->HOST_TX_LEN = 8;
ret = USBHostTransact( (USB_PID_SETUP<<4)|DEF_ENDP_0, 0, 200000 );
if(ret != ERR_SUCCESS) return ( ret ); //error
relen = pSetupReq->wLength;
if(relen && pBuf) //data stage
{
if( (pSetupReq->bRequestType) & USB_REQ_TYP_IN ) //device to host
{
while(relen)
{
if( thisUsbDev.DeviceSpeed != USB_HIGH_SPEED )
Delay_Us( 100 );
USBHSH->HOST_RX_DMA = (UINT32)databuf + *pLen;
ret = USBHostTransact( (USB_PID_IN<<4)| DEF_ENDP_0, tog<<3, 20000 );
if(ret != ERR_SUCCESS) return ( ret );
tog ^=1;
rxlen = (USBHSH->RX_LEN < relen) ? USBHSH->RX_LEN : relen;
relen -= rxlen;
if(pLen) *pLen += rxlen;
if( ( USBHSH->RX_LEN == 0 ) || (USBHSH->RX_LEN & ( UsbDevEndp0Size - 1 ))) break;
}
USBHSH->HOST_TX_LEN = 0 ;
}
else
{ // host to device
while(relen)
{
if( thisUsbDev.DeviceSpeed != USB_HIGH_SPEED )
Delay_Us( 100 );
USBHSH->HOST_TX_DMA = (UINT32)databuf + *pLen;
USBHSH->HOST_TX_LEN = (relen >= UsbDevEndp0Size)? UsbDevEndp0Size : relen;
ret = USBHostTransact((USB_PID_OUT<<4)|DEF_ENDP_0, tog<<3, 20000);
if(ret != ERR_SUCCESS) return ( ret );
tog ^=1;
relen -= USBHSH->HOST_TX_LEN;
if( pLen ) *pLen += USBHSH->HOST_TX_LEN;
}
}
}
if( thisUsbDev.DeviceSpeed != USB_HIGH_SPEED )
Delay_Us( 100 );
ret = USBHostTransact( ((USBHSH->HOST_TX_LEN) ? USB_PID_IN<<4|DEF_ENDP_0 : USB_PID_OUT<<4|DEF_ENDP_0),
UH_R_TOG_1|UH_T_TOG_1, 20000 );
if(ret != ERR_SUCCESS) return( ret );
if ( USBHSH->HOST_TX_LEN == 0 ) return( ERR_SUCCESS ); //status stage is out, send a zero-length packet.
if ( USBHSH->RX_LEN == 0 ) return( ERR_SUCCESS ); //status stage is in, a zero-length packet is returned indicating success.
return ERR_USB_BUF_OVER;
}`
from cherryusb_wch.
把log等级开到最大,再看一下log。
from cherryusb_wch.
把log等级开到最大,再看一下log。
[15:50:23.839]收←◆[INFO]APP VER: V1.0.0 Aug 12 2023 20:04:58
[INFO]SystemClk:96000000
[INFO]ChipID:30700528
[INFO]FreeRTOS Kernel Version:V10.4.6
[INFO]RT-Thread AT server (V1.3.1) initialize success.[I/USB] Dev connect
[D/USB] Port change:0x02
[D/USB] Port 1 change
[D/USB] port 1, status:0x03, change:0x03
[D/USB] Port 1, status:0x03, change:0x00
[D/USB] Port 1, status:0x03, change:0x00
[15:50:23.896]收←◆[D/USB] Port 1, status:0x03, change:0x00
[D/USB] Port 1, status:0x03, change:0x00
[15:50:23.946]收←◆[D/USB] Port 1, status:0x03, change:0x00
[I/USB] Reset port
[I/USB] Dev USB_SPEED_FULL
[15:50:24.159]收←◆[I/USB] New full-speed device on Hub 1, Port 1 connected
[D/USB] USBHS_HOST->HOST_TX_CTRL:20
[D/USB] USBHS_HOST->HOST_RX_CTRL:28
[D/USB] ep0 rx_len:8
[D/USB] USBHS_HOST->HOST_TX_CTRL:28
[D/USB] S-> I-> O-status stage: In:8
[D/USB] Device rev=0200 cls=ef sub=02 proto=01 size=64
[D/USB] USBHS_HOST->HOST_TX_CTRL:20
[D/USB] USBHS_HOST->HOST_RX_CTRL:28
[D/USB] S-> O-> In-status stage: Out:0
[D/USB] USBHS_HOST->HOST_TX_CTRL:20
[D/USB] USBHS_HOST->HOST_RX_CTRL:28
[D/USB] ep0 rx_len:18
[D/USB] USBHS_HOST->HOST_TX_CTRL:28
[D/USB] S-> I-> O-status stage: In:18
[I/USB] New device found,idVendor:ffff,idProduct:ffff,bcdDevice:0100
[D/USB] USBHS_HOST->HOST_TX_CTRL:20
[D/USB] USBHS_HOST->HOST_RX_CTRL:28
[D/USB] ep0 rx_len:9
[D/USB] USBHS_HOST->HOST_TX_CTRL:28
[D/USB] S-> I-> O-status stage: In:9
[D/USB] USBHS_HOST->HOST_TX_CTRL:20
[D/USB] USBHS_HOST->HOST_RX_CTRL:28
[D/USB] ep0 rx_len:64
[D/USB] ep0 rx_len:11
[D/USB] USBHS_HOST->HOST_TX_CTRL:28
[D/USB] S-> I-> O-status stage: In:75
[I/USB] Interface Descriptor:
[I/USB] bLength: 0x09
[I/USB] bDescriptorType: 0x04
[I/USB] bInterfaceNumber: 0x00
[I/USB] bAlternateSetting: 0x00
[I/USB] bNumEndpoints: 0x01
[I/USB] bInterfaceClass: 0x02
[I/USB] bInterfaceSubClass: 0x02
[I/USB] bInterfaceProtocol: 0x01
[I/USB] iInterface: 0x02
[I/USB] Ep=83 Attr=03 Mps=8 Interval=10 Mult=00
[I/USB] Interface Descriptor:
[I/USB] bLength: 0x09
[I/USB] bDescriptorType: 0x04
[I/USB] bInterfaceNumber: 0x01
[I/USB] bAlternateSetting: 0x00
[I/USB] bNumEndpoints: 0x02
[I/USB] bInterfaceClass: 0x0a
[I/USB] bInterfaceSubClass: 0x00
[I/USB] bInterfaceProtocol: 0x00
[I/USB] iInterface: 0x00
[I/USB] Ep=02 Attr=02 Mps=64 Interval=00 Mult=00
[I/USB] Ep=81 Attr=02 Mps=64 Interval=00 Mult=00
[I/USB] The device has 2 interfaces
[D/USB] USBHS_HOST->HOST_TX_CTRL:20
[D/USB] USBHS_HOST->HOST_RX_CTRL:28
[D/USB] S-> O-> In-status stage: Out:0
[I/USB] Enumeration success, start loading class driver
[I/USB] Loading cdc_acm class driver
[D/USB] USBHS_HOST->HOST_TX_CTRL:20
[D/USB] USBHS_HOST->HOST_RX_CTRL:28
[D/USB] ep0 rx_len:7
[D/USB] USBHS_HOST->HOST_TX_CTRL:28
[D/USB] S-> I-> O-status stage: In:7
[I/USB] Get linecoding 2000000 0 0 8
[D/USB] USBHS_HOST->HOST_TX_CTRL:20
[D/USB] USBHS_HOST->HOST_RX_CTRL:28
[D/USB] S-> O-> In-status stage: Out:0
[D/USB] USBHS_HOST->HOST_TX_CTRL:20
[D/USB] USBHS_HOST->HOST_TX_CTRL:28
[D/USB] Control endpoint out nak and retry, length:7
[D/USB] ep0 tx_len:7
[D/USB] USBHS_HOST->HOST_RX_CTRL:28
[15:50:25.185]收←◆[E/USB] Fail to set linecoding, ret: -116
[I/USB] Loading cdc_data class driver
from cherryusb_wch.
No more support host
from cherryusb_wch.
Related Issues (12)
- USB Host low-speed device enumeration HOT 12
- ch32 usbFS HOT 9
- 有计划支持CH569吗? HOT 10
- 请问是否可以通过cherryUSB库同时使用CH582或CH32V307的两个USB口。 HOT 1
- Has USB HS devices been tested on CH32V307? HOT 2
- audio_v1_mic_multichan_template not working properly HOT 9
- Multiple USB instances on MCU with multiple USB ports HOT 6
- 有大佬试过V307的host吗? HOT 2
- CH32V307 USB HS UVC is ok? HOT 3
- Compiling RISC-V toolchain HOT 5
- ch32v103 HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cherryusb_wch.