CH559模拟CH9326,SET IDLE 失败

用技术社区提供的CH559模拟CH9326例程程序,做的USB HID 读卡器。电脑端口发送 SET idle 指令,设备无法识别。

)R[)EHP$()$J3U1{YE8S}UT.png

现象:读卡器插入后,设备管理器提示输入设备,收发数据。过一段时间读写卡,提示描述符错误,打开设备类在通用串行总线控制器中设备有黄色标识。

问题如下:CH599如何实现HID设备set_idle响应?官方例程是否有不完善地方?应该怎么解决这个问题?


image.png

屏蔽len = 0xFF; 即可


Many of the examples including also their bootloaders have a bug which results in wrong behavour after an unsuported Setup request. When a Setup ocures any possible Stall from previous requests has to bei cleared. Spec requires that.

From the trace it looks like you run into this case. Idle is not supported and fails. Also the next setup fails. Then it works again....

I reported this bug a long time ago but nothing changed.


Solution:


case SETUP:

          UEP0_CTL &= 0xF2;

          ......


作为hid设备不是每条类命令都是强制回复的,所以例程中只做了标准请求的处理,setidle不回复也是不影响枚举过程的。当然你在处理非标准请求的过程中将len等于0xff去掉,让它不回复stall也可以。这个例程是做一个hid转串口功能的简单实现。


@WCH-IC

No thats not correct. The spec clearly states that the response to every unknown request has to be a STALL handshake.


When you check the trace you can see a reenumeration of the device  at 787.1.0. At 792.1.0 you can see that Getdesc(HID) fails because of the bug i am describing and therefore reenum fails.


How would you explain the STALL response to SetIdle at 791.2.0 when he never put len=0xFF; in the code.


代码中做了判断,如图image.png

屏蔽len = 0xff之后的抓包数据如下:

image.png


只有登录才能回复,可以选择微信账号登录