芯片:STM32F103C8T6
定义了三个USB接口设备。
在USB_Prop.c中定义了将三个接口的字符串描述符上传给HOST,
ONE_DESCRIPTOR String_Descriptor[5] =
{
{(uint8_t*)SMARTCARD_StringLangID, SMARTCARD_SIZ_STRING_LANGID},
{(uint8_t*)SMARTCARD_StringProduct, SMARTCARD_SIZ_STRING_PRODUCT},
{(uint8_t*)SMARTCARD_StringSerial5, SMARTCARD_SIZ_STRING_SERIAL5},
{(uint8_t*)SMARTCARD_StringSerial4, SMARTCARD_SIZ_STRING_SERIAL4},
{(uint8_t*)SMARTCARD_StringSerial3, SMARTCARD_SIZ_STRING_SERIAL3}
};
枚举时通过USB Monitor可以观察到:
SMARTCARD_StringSerial4的传输:
000110: Get Descriptor Request (DOWN), 29.03.2011 08:23:16.015 +0.0
Descriptor Type: String
Descriptor Index: 0x3
Transfer Buffer Size: 0x2e bytes
LanguageId: 0x409
000111: Control Transfer (UP), 29.03.2011 08:23:16.031 +0.015. Status: 0x00000000
Pipe Handle: 0x893d8470
2E 03 43 00 6F 00 6E 00 74 00 61 00 63 00 74 00
6C 65 73 73 00 20 00 52 00 65 00 61 00 64 00 65
00 72 00 20 00 00 00 00 00 00 00 00 00 00
Setup Packet
80 06 03 03 09 04 2E 00
SMARTCARD_StringSerial3 的传输:
000125: Get Descriptor Request (DOWN), 29.03.2011 08:23:16.046 +0.0
Descriptor Type: String
Descriptor Index: 0x4
Transfer Buffer Size: 0x1e bytes
LanguageId: 0x409
000126: Control Transfer (UP), 29.03.2011 08:23:16.046 +0.0. Status: 0x00000000
Pipe Handle: 0x893d8470
1E 03 53 00 41 00 4D 00 20 00 52 00 65 00 61 00 .
64 00 65 00 72 00 20 00 00 00 00 00 00 00
Setup Packet
80 06 04 03 09 04 1E 00
这两个字符串描述符的传输是正常的
而
SMARTCARD_StringSerial5 不正确!!!
000102: Control Transfer (UP), 29.03.2011 08:23:16.015 +0.015. Status: 0x00000000
Pipe Handle: 0x893d8470
47 08 B5 00 21 4F F0 00 60 00 F0 4B F8 4F F4 A0
60 00 F0 3D F8 FF 20 8D F8 00 00 01 20 8D F8 01
00 00 21 8D F8 02 10 8D F8 03 00 68 46 00 F0 01
F8 08 BD F0 B5 0F 23 C4 78 01 78 4F F0 E0 22 01
27 E4 B1 D2 F8 0C 4D 86 78 04 F4 E0 64 C4 F5 E0 IPTOR).
64 24 0A C4 F1 04 05 E3 40 44 78 1E 40 AC 40 26
43 33 01 11 44 81 F8 00 34 00 78 41 09 00 F0 1F
00 02 EB 81 01 87 40 C1 F8 00 71 F0 BD 01 F0 1F
00 87 40 48 09 02 EB 80 00 C0 F8 80 71 F0 BD 02 C.I.`pG....?..?J
49 08 43 02 49 08 60 70 47 00 00 00 00 FA 05 0C .@.C.H.`pG??..
ED 00 E0 02 4A 11 40 01 43 02 48 01 60 70 47 80
FF FF 1F 08 ED 00 E0 70 B5 30 4D 28 68 01 78 44
78 4A 06 28 D1 09 2C 02 D1 00 F0 55 FE 37 E0 05 0 0001.......7?,
2C 09 D1 C1 78 7F 29 3E D8 81 78 00 29 3B D1 81
88 B9 BB 80 7A 36 E0 03 2C 0A D1 C1 78 01 29 27
D1 81 88 29 BB 40 7A 80 06 22 D5 00 F0 58 FE
Setup Packet
80 06 05 03 09 04 FF 00 ?....?
主机第一次不知道数据长度,要了FF字节数据。
根据第一次的数据,第二次是取47H字节
000141: Control Transfer (UP), 29.03.2011 08:23:16.078 +0.0. Status: 0x00000000
Pipe Handle: 0x893d8470
47 08 B5 00 21 4F F0 00 60 00 F0 4B F8 4F F4 A0
60 00 F0 3D F8 FF 20 8D F8 00 00 01 20 8D F8 01
00 00 21 8D F8 02 10 8D F8 03 00 68 46 00 F0 01
F8 08 BD F0 B5 0F 23 C4 78 01 78 4F F0 E0 22 01
27 E4 B1 D2 F8 0C 4D ....?.
Setup Packet
80 06 05 03 09 04 47 00 ?....G.
问题:
我在USB_desc.c中定义的SMARTCARD_StringSerial5并不是上述数据!
26 03 43 00 6F 00 6E 00 74 00 61 00 63 00 74 00 20 00 52 00 65 00 61 00 64 00 65 00 72 00 20 00 00 00 00 00 00 00 这是我在
SMARTCARD_StringSerial5定义的字符串描述符.
且我将ONE_DESCRIPTOR String_Descriptor[5]中SMARTCARD_StringSerial3,SMARTCARD_StringSerial4,SMARTCARD_StringSerial5的顺序打乱,发现
只是这个数组中的第三个字符串传输时会出问题,其它都正常。比如SMARTCARD_StringSerial5的位置和SMARTCARD_StringSerial3对调,出问题的变为
SMARTCARD_StringSerial3
HOST已能识别三个接口设备,但在设备列表时只能找到2个设备的字符串,即有一个得字符串描述符没能正确传输给HOST。
请各位大侠指点一下解决思路,谢谢。 |