USB 键盘枚举问题

Bus Hound 6.01 capture on Windows Vista Service Pack 1 (x64). Complements of www.perisoft.net

Device - Device ID (followed by the endpoint for USB devices) (16) USB Composite Device (19) USB 输入设备 (20) USB 输入设备 (21) HID Keyboard Device (22) 符合 HID 标准的用户控制设备 (23) HID-compliant device (24) USB Composite Device (25) USB Audio DAC (26) USB 输入设备 (27) 符合 HID 标准的用户控制设备 Phase - Phase Type CTL USB control transfer IN Data in transfer OUT Data out transfer USTS USB status Data - Hex dump of the data transferred Descr - Description of the phase Cmd... - Position in the captured data

Device Phase Data Description Cmd.Phase.Ofs(rep) ------ ----- -------------------------------------------------- ---------------- ------------------ 16.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 1.1.0 16.0 IN 12 01 10 01 00 00 00 08 4f 1c 02 00 10 01 01 02 ........O....... 1.2.0 00 01 .. 1.2.16 16.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 2.1.0 16.0 IN 09 02 3b 00 02 01 00 a0 31 ..;.....1 2.2.0 16.0 CTL 80 06 00 02 00 00 3b 00 GET DESCRIPTOR 3.1.0 16.0 IN 09 02 3b 00 02 01 00 a0 31 09 04 00 00 01 03 01 ..;.....1....... 3.2.0 01 00 09 21 10 01 00 01 22 36 00 07 05 81 03 08 ...!...."6...... 3.2.16 00 0a 09 04 01 00 01 03 00 00 00 09 21 10 01 00 ............!... 3.2.32 01 22 32 00 07 05 82 03 03 00 0a ."2........ 3.2.48 16.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 4.1.0 16.0 CTL 80 06 02 03 09 04 04 00 GET DESCRIPTOR 5.1.0(2) 16.0 IN 1a 03 55 00 ..U. 5.2.0 16.0 CTL 80 06 02 03 09 04 1a 00 GET DESCRIPTOR 6.1.0(2) 16.0 IN 1a 03 55 00 53 00 42 00 20 00 4b 00 65 00 79 00 ..U.S.B. .K.e.y. 6.2.0 62 00 6f 00 61 00 72 00 64 00 b.o.a.r.d. 6.2.16 19.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 9.1.0 19.0 IN 12 01 10 01 00 00 00 08 4f 1c 02 00 10 01 01 02 ........O....... 9.2.0 00 01 .. 9.2.16 19.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 10.1.0 19.0 IN 09 02 22 00 01 01 00 a0 31 ..".....1 10.2.0 19.0 CTL 80 06 00 02 00 00 22 00 GET DESCRIPTOR 11.1.0 19.0 IN 09 02 22 00 01 01 00 a0 31 09 04 00 00 01 03 01 ..".....1....... 11.2.0 01 00 09 21 10 01 00 01 22 36 00 07 05 81 03 08 ...!...."6...... 11.2.16 00 0a .. 11.2.32 19.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 12.1.0 19.0 CTL 21 0a 00 00 00 00 00 00 SET IDLE 13.1.0 19.0 CTL 81 06 00 22 00 00 76 00 GET DESCRIPTOR 14.1.0 19.0 IN 05 01 09 06 a1 01 05 08 19 01 29 03 15 00 25 01 ..........)...%. 14.2.0 75 01 95 03 91 02 95 05 91 01 05 07 19 e0 29 e7 u.............). 14.2.16 95 08 81 02 75 08 95 01 81 01 19 00 29 91 26 ff ....u.......).&. 14.2.32 00 95 06 81 00 c0 ...... 14.2.48 20.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 15.1.0 20.0 IN 12 01 10 01 00 00 00 08 4f 1c 02 00 10 01 01 02 ........O....... 15.2.0 00 01 .. 15.2.16 20.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 16.1.0 20.0 IN 09 02 22 00 01 01 00 a0 31 ..".....1 16.2.0 20.0 CTL 80 06 00 02 00 00 22 00 GET DESCRIPTOR 17.1.0 20.0 IN 09 02 22 00 01 01 00 a0 31 09 04 01 00 01 03 00 ..".....1....... 17.2.0 00 00 09 21 10 01 00 01 22 32 00 07 05 82 03 03 ...!...."2...... 17.2.16 00 0a .. 17.2.32 20.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 18.1.0 20.0 CTL 21 0a 00 00 01 00 00 00 SET IDLE 19.1.0 20.0 USTS c0000004 stall pid 19.2.0 20.0 CTL 81 06 00 22 01 00 72 00 GET DESCRIPTOR 20.1.0 20.0 IN 05 0c 09 01 a1 01 85 01 19 00 2a 3c 02 15 00 26 ..........*<...& 20.2.0 3c 02 95 01 75 10 81 00 c0 05 01 09 80 a1 01 85 <...u........... 20.2.16 02 19 81 29 83 25 01 75 01 95 03 81 02 95 05 81 ...).%.u........ 20.2.32 01 c0 .. 20.2.48 19.0 CTL 21 09 00 02 00 00 01 00 SET REPORT 21.1.0 19.0 OUT 01 . 21.2.0 19.1 IN 00 00 00 00 00 00 00 00 ........ 22.1.0

上面的内容是电脑对USB键盘的枚举过程。

请问用CH375操作键盘时是否也需要进行同样的枚举?

上面的16、19、20是不是表示键盘有三个接口?最终通信用的是19号接口?


上面显示的枚举数据是一个复合设备16有两个接口19和20,最终通讯是在19接口上。 实际CH375操作的话只需要枚举一个复合设备(设备描述符、配置描述符),然后分别枚举19和20的HID类描述符。


CH375芯片在连接键盘后,CS#引脚就一直低电平,SETB CS后也一直低电平。加4.7K的上拉电阻也是低电平。这样正常吗?


CS#是输入引脚,电平是由你的单片机控制的。它内部有上拉电阻,不需要再加上拉电阻。


现在出现了无法控制的情况,程序中设置单片机控制CS#引脚的输出为1时,在接上键盘后测量电压为0. 如果拔掉键盘,则正常。


检查一下你的硬件连接,CS与你的单片机连接,怎么可能受键盘控制呢?你的程序上是不是在插入键盘或者拔出键盘CS#做了不同的操作?


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