|
枚举过程中发现不成功:
以下是各个描述符的说明
//-----------------------------------------------------------------------------
// F3xx_USB0_Descriptor.c
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "F3xx_USB0_Register.h"
#include "F3xx_USB0_InterruptServiceRoutine.h"
#include "F3xx_USB0_Descriptor.h"
//-----------------------------------------------------------------------------
// Descriptor Declarations
//-----------------------------------------------------------------------------
const device_descriptor code DEVICEDESC =
{
18, // bLength
0x01, // bDescriptorType
0x1001, // bcdUSB
0x00, // bDeviceClass
0x00, // bDeviceSubClass
0x00, // bDeviceProtocol
EP0_PACKET_SIZE, // bMaxPacketSize0
0x2231,// 0xC410, // idVendor
0x4523,// 0xB981, // idProduct
0x0000, // bcdDevice
0x01, // iManufacturer
0x02, // iProduct
0x00, // iSerialNumber
0x01 // bNumConfigurations
}; //end of DEVICEDESC
// From "USB Device Class Definition for Human Interface Devices (HID)".
// Section 7.1:
// "When a Get_Descriptor(Configuration) request is issued,
// it returns the Configuration descriptor, all Interface descriptors,
// all Endpoint descriptors, and the HID descriptor for each interface."
const hid_configuration_descriptor code HIDCONFIGDESC =
{
{ // configuration_descriptor hid_configuration_descriptor
0x09, // Length
0x02, // Type
0x2200, // Totallength (= 9+9+9+7)
0x01, // NumInterfaces
0x01, // bConfigurationValue
0x00, // iConfiguration
0x80, // bmAttributes
0x32 // MaxPower (in 2mA units)
},
{ // interface_descriptor hid_interface_descriptor
0x09, // bLength
0x04, // bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
0x01, // bNumEndpoints
0x03, // bInterfaceClass (3 = HID)
0x01, // bInterfaceSubClass
0x01, // bInterfaceProcotol
0x00 // iInterface
},
{ // class_descriptor hid_descriptor
0x09, // bLength
0x21, // bDescriptorType
0x0101, // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
HID_REPORT_DESCRIPTOR_SIZE_LE // wItemLength (tot. len. of report
// descriptor)
},
// IN endpoint (mandatory for HID)
{ // endpoint_descriptor hid_endpoint_in_descriptor
0x07, // bLength
0x05, // bDescriptorType
0x81, // bEndpointAddress
0x03, // bmAttributes
EP1_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN)
1000 // bInterval
},
// OUT endpoint (optional for HID)
{ // endpoint_descriptor hid_endpoint_out_descriptor
0x07, // bLength
0x05, // bDescriptorType
0x01, // bEndpointAddress
0x03, // bmAttributes
EP2_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN)
1000 // bInterval
}
};
const hid_report_descriptor code HIDREPORTDESC =
{
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x95, 0x05, // REPORT_COUNT (5)
0x75, 0x01, // REPORT_SIZE (1)
0x05, 0x08, // USAGE_PAGE (LEDs)
0x19, 0x01, // USAGE_MINIMUM (Num Lock)
0x29, 0x05, // USAGE_MAXIMUM (Kana)
0x91, 0x02, // OUTPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x03, // REPORT_SIZE (3)
0x91, 0x03, // OUTPUT (Cnst,Var,Abs)
0x95, 0x06, // REPORT_COUNT (6)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x65, // LOGICAL_MAXIMUM (101)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0xc0 // END_COLLECTION
};
#define STR0LEN 4
code unsigned char String0Desc [STR0LEN] =
{
STR0LEN, 0x03, 0x09, 0x04
}; //end of String0Desc
#define STR1LEN sizeof ("SILICON LABORATORIES") * 2
code unsigned char String1Desc [STR1LEN] =
{
STR1LEN, 0x03,
'S', 0,
'I', 0,
'L', 0,
'I', 0,
'C', 0,
'O', 0,
'N', 0,
' ', 0,
'L', 0,
'A', 0,
'B', 0,
'O', 0,
'R', 0,
'A', 0,
'T', 0,
'O', 0,
'R', 0,
'I', 0,
'E', 0,
'S', 0
}; //end of String1Desc
#define STR2LEN sizeof ("C8051F320 Development Board") * 2
code unsigned char String2Desc [STR2LEN] =
{
STR2LEN, 0x03,
'C', 0,
'8', 0,
'0', 0,
'5', 0,
'1', 0,
'F', 0,
'3', 0,
'x', 0,
'x', 0,
' ', 0,
'D', 0,
'e', 0,
'v', 0,
'e', 0,
'l', 0,
'o', 0,
'p', 0,
'm', 0,
'e', 0,
'n', 0,
't', 0,
' ', 0,
'B', 0,
'o', 0,
'a', 0,
'r', 0,
'd', 0
}; //end of String2Desc
unsigned char* const STRINGDESCTABLE [] =
{
String0Desc,
String1Desc,
String2Desc
};
Bus Hound 5.00 capture. Complements of www.perisoft.net
Device - Device ID (followed by the endpoint for USB devices)
(20) Intel(R) ICH9 Family USB Universal Host Controller - 2935
(21) USB Root Hub
(30) USB 人体学输入设备
Phase - Phase Type
CTL USB control transfer
DI Data in
DO Data out
NSTS NT status
USTS USB status
Data - Hex dump of the data transferred
Descr - Description of the phase
Cmd... - Position in the captured data
//以下是枚举成USB键盘的过程 最后SET CONFIG 失败
Device Phase Data Description Cmd.Phase.Ofs(rep)
------ ----- ------------------------------------------------------------------------------------------------------ ---------------- ------------------
21.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 1.1.0(2)
21.0 DI 01 01 01 00 .... 1.2.0
21.0 CTL 23 01 10 00 01 00 00 00 CLEAR FEATURE 3.1.0
21.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 4.1.0(2)
21.0 DI 01 01 00 00 .... 4.2.0
21.0 CTL 23 03 04 00 01 00 00 00 SET FEATURE 6.1.0
21.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 7.1.0
21.0 DI 03 01 10 00 .... 7.2.0
21.0 CTL 23 01 14 00 01 00 00 00 CLEAR FEATURE 8.1.0
21.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 9.1.0(2)
21.0 DI 03 01 00 00 .... 9.2.0
21.0 CTL 23 03 04 00 01 00 00 00 SET FEATURE 11.1.0
21.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 12.1.0
21.0 DI 03 01 10 00 .... 12.2.0
21.0 CTL 23 01 14 00 01 00 00 00 CLEAR FEATURE 13.1.0
21.0 CTL 80 06 00 02 00 00 ff 00 GET DESCRIPTOR 14.1.0
21.0 DI 09 02 22 00 01 01 00 80 32 09 04 00 00 01 03 01 01 00 09 21 01 01 00 01 22 44 00 07 05 81 03 40 ..".....2....... 14.2.0
21.0 CTL a3 00 00 00 02 00 04 00 GET STATUS 15.1.0
21.0 DI 00 01 00 00 .... 15.2.0
30.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 16.1.0
30.0 DI 12 01 10 01 00 00 00 40 22 31 45 23 00 00 01 02 00 01 .......@"1E#.... 16.2.0
30.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 17.1.0
30.0 DI 09 02 22 00 01 01 00 80 32 ..".....2 17.2.0
30.0 CTL 80 06 00 02 00 00 22 00 GET DESCRIPTOR 18.1.0
30.0 DI 09 02 22 00 01 01 00 80 32 09 04 00 00 01 03 01 01 00 09 21 01 01 00 01 22 44 00 07 05 81 03 40 ..".....2....... 18.2.0
30.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 19.1.0
30.0 USTS 00 20 00 c0 set config fail 19.2.0
21.0 CTL 23 01 01 00 01 00 00 00 CLEAR FEATURE 20.1.0
21.0 CTL 80 00 00 00 00 00 02 00 GET STATUS 21.1.0(2)
21.0 DI 01 00 .. 21.2.0
30.0 CTL 80 06 00 02 00 00 22 00 GET DESCRIPTOR 23.1.0
30.0 DO 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 23.2.0
30.0 NSTS 11 00 00 80 busy 23.3.0
请高人帮忙指点一二!非常感谢
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|