各位大师,请教一个USB接口的问题 ,我现在用F340做了一个双HID的接口程序,用的是新华龙官方的Keyboard的例程改的。程序中已经将端口1口设置为keyboard 的通讯口,我用同样的方式设置端口2 为另外一个HID的端口,用BUS hound抓的数据 显示 是USTS c0000004 ,我看论坛里有人说是端口没有设置。我想问一下,除了在接口配置符那里设置好端口,C8051F340还有哪里需要设置。接口初始化部分我已经看过,端口2 是打开的。
下面是USB 口初始化 ,配置符 ,和BUS hound的数据,麻烦帮忙看一下,谢谢
POLL_WRITE_BYTE(POWER, 0x08); // Force Asynchronous USB Reset
POLL_WRITE_BYTE(IN1IE, 0x07); // Enable Endpoint 0-2 in interrupts 07
POLL_WRITE_BYTE(OUT1IE, 0x07); // Enable Endpoint 0¡¤-2 out interrupts 07
POLL_WRITE_BYTE(CMIE, 0x07); // Enable Reset,Resume,Suspend interrupts ¹«¹²ÖжÏÔÊÐí¼Ä´æÆ÷
USB0XCN = 0xE0; // Enable transceiver; select full speed
POLL_WRITE_BYTE(CLKREC, 0x89); // Enable clock recovery, single-step mode disabled
EIE1 |= 0x02; // Enable USB0 Interrupts
EIP1 |= 0x02;
POLL_WRITE_BYTE(POWER, 0x01); //USB0½øÈë¹ÒÆð·½Ê½
USB_Switch = USB_ENABLE;
端口配置符
//struct HID_DESCRIPTOR Hid_Desc;
{
0x07, // bLength
0x05, // bDescriptorType
0x82, // bEndpointAddress 82
0x03, // bmAttributes
SWAP16( EP2_PACKET_SIZE ), // MaxPacketSize (LITTLE ENDIAN)
EP_INTERVAL // bInterval
},
{
0x07, // bLength
0x05, // bDescriptorType
0x02, // bEndpointAddress 82
0x03, // bmAttributes
SWAP16( EP2_PACKET_SIZE ), // MaxPacketSize (LITTLE ENDIAN)
EP_INTERVAL // bInterval
}
bus hound 数据
Bus Hound 6.01 capture on Windows Vista Service Pack 1 (x64).
Device - Device ID (followed by the endpoint for USB devices)
(35) USB 输入设备
(37) HID-compliant device
(42) USB 输入设备
(44) HID-compliant device
Phase - Phase Type
CTL USB control transfer
IN Data in transfer
RESET bus reset
USTS USB status
ok command complete
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)
------ ----- ------------------------------------------------------------------------------------------------------ -------------------------------- ------------------
42.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 1.1.0
42.0 IN 12 01 10 01 00 00 00 40 0f f0 56 56 00 01 01 02 03 01 .........VV...... 1.2.0
42.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 2.1.0
42.0 IN 09 02 29 00 01 01 00 80 fa ..)...... 2.2.0
42.0 CTL 80 06 00 02 00 00 29 00 GET DESCRIPTOR 3.1.0
42.0 IN 09 02 29 00 01 01 00 80 fa 09 04 01 00 02 03 00 00 00 09 21 10 01 21 01 22 27 00 07 05 82 03 40 ..)................!..!."'..... 3.2.0
00 0a 07 05 02 03 40 00 0a ......@.. 3.2.32
42.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 4.1.0
42.0 CTL 21 0a 00 00 01 00 00 00 SET IDLE 5.1.0
42.0 USTS c0000004 stall pid 5.2.0
42.0 CTL 81 06 00 22 01 00 67 00 GET DESCRIPTOR 6.1.0
42.0 IN 05 ff 09 30 a1 01 05 01 19 00 29 ff 15 00 25 ff 75 08 95 40 81 02 05 02 19 00 29 ff 15 00 25 ff ...0......)...%.u..@......)...%. 6.2.0
95 40 75 08 91 02 c0 .@u.... 6.2.32
42.2 USTS c0000004 stall pid 7.1.0(11)
42 RESET 8.1.0(11)
42 ok 8.2.0
42.2 RESET 9.1.0(11)
42.2 USTS c0000004 stall pid 9.2.0
42 RESET 41.1.0(7)
42.2 USTS c0007000 no device 42.1.0(7)
42 ok 41.2.0
42.2 RESET 43.1.0(7)
42.2 USTS c0000004 stall pid 43.2.0
42 RESET 69.1.0
42.2 USTS c0000004 stall pid 70.1.0
42 ok 69.2.0
42.2 RESET 71.1.0
42.2 USTS c0000004 stall pid 71.2.0
|