阅读:1785回复:10
描述符的问题,请各位高手指点
请教各位高手,我的usb设备需要实现一个配置,这个配置含有两个接口,分别使用endpoint1和endpoint2,以下是具体的描述符,请各位高手帮忙看一下写得是否正确,请多多指教!
controlReadTable: deviceDescTable: db (deviceDescTableEnd - deviceDescTable) ; bLength (18 bytes) db 01h db 10h, 01h db 00h db 00h db 00h db 08h db 55h, 66h db 66h, 77h db 01h, 00h db 01h db 02h db 00h db 01h deviceDescTableEnd: configDescTable: db (configDescTableEnd - configDescTable) db 02h db (ep2endpointDescTableEnd- configDescTable), 00h db 02h ; bNumInterfaces (2) db 01h ; bConfigurationValue (1) db 00h ; iConfiguration (USB HID Compliant Mouse) db A0h ; bmAttributes (bus powered, remote wakeup) db 50 ; MaxPower (100mA) configDescTableEnd: interfaceDescTable: db (interfaceDescTableEnd - interfaceDescTable) ; bLength (9 bytes) db 04h ; bDescriptorType db 00h ; bInterfaceNumber db 00h ; bAlternateSetting db 01h ; bNumEndpoints db 03h ; bInterfaceClass db 01h ; bInterfaceSubClass db 02h ; bInterfaceProtocol db 00h ; iInterface interfaceDescTableEnd: hidDescTable: db (hidDescTableEnd - hidDescTable) ; bLength (9 bytes) db 21h ; bDescriptorType db 10h, 01h ; bcdHID (1.10) db 00h ; bCountryCode (US) db 01h ; bNumDescriptors (1) db 22h ; bDescriptorType (HID) db (hidReportDescTableEnd - hidReportDescTable), 00h ; wDescriptorLength (72 bytes) hidDescTableEnd: endpointDescTable: db 07h ; bLength (7 bytes) db 05h ; bDescriptorType (ENDPOINT) db 81h ; bEndpointAddress (IN endpoint, endpoint 1) db 03h ; bmAttributes (interrupt) db 04h, 00h ; wMaxPacketSize (4 bytes) db 0Ah ; bInterval (10ms) endpointDescTableEnd: ep2interfaceDescTable: db (interfaceDescTableEnd - interfaceDescTable) ; bLength (9 bytes) db 04h ; bDescriptorType (INTERFACE) db 01h ; bInterfaceNumber (1) db 00h ; bAlternateSetting (0) db 01h ; bNumEndpoints (1) db 03h ; bInterfaceClass db 01h ; bInterfaceSubClass db 02h ; bInterfaceProtocol db 00h ; iInterface (not supported) ep2interfaceDescTableEnd: ep2hidDescTable: db (hidDescTableEnd - hidDescTable) ; bLength (9 bytes) db 21h ; bDescriptorType (HID) db 10h, 01h ; bcdHID (1.10) db 00h ; bCountryCode (US) db 01h ; bNumDescriptors (1) db 22h ; bDescriptorType (HID) db (ep2hidReportDescTableEnd - ep2hidReportDescTable), 00h ep2hidDescTableEnd: ep2endpointDescTable: db 07h ; bLength (7 bytes) db 05h ; bDescriptorType (ENDPOINT) db 82h ; bEndpointAddress (IN endpoint, endpoint 1) db 03h ; bmAttributes (interrupt) db 08h, 00h ; wMaxPacketSize (8 bytes) db 0Ah ; bInterval (10ms) ep2endpointDescTableEnd: hidReportDescTable: db 05h, 01h ; usage page (generic desktop) db 09h, 02h ; usage (mouse) db A1h, 01h ; collection (application) db 05h, 09h ; usage page (buttons) db 19h, 01h ; usage minimum (1 button) db 29h, 03h ; usage maximum (3 buttons) db 15h, 00h ; logical minimum (0) db 25h, 01h ; logical maximum (1) db 95h, 03h ; report count (3 reports) db 75h, 01h ; report size (1 bit each) db 81h, 02h ; input (Data, Var, Abs) db 95h, 01h ; report count (1 report) db 75h, 05h ; report size (5 bits) db 81h, 03h ; input (Cnst, Ary, Abs) db 05h, 01h ; usage page (generic desktop) db 09h, 01h ; usage (pointer) db A1h, 00h ; collection (linked) db 09h, 30h ; usage (X) db 09h, 31h ; usage (Y) db 15h, 81h ; logical minimum (-127) db 25h, 7Fh ; logical maximum (127) db 75h, 08h ; report size (8 bits each) db 95h, 02h ; report count (2 reports) db 81h, 06h ; input (Cnst, Var, Rel) db C0h ; end collection db 09h, 38h ; wheel db 95h, 01h ; wheel size = 1 byte db 81h, 06h ; variable data bit field with relative position db 09h, 3ch ; motion wake up db 15h, 00h ; 0 no movement db 25h, 01h ; 1 movement db 75h, 01h ; 1st bit represent movement db 95h, 01h ; 1 report db b1h, 22h ; variable data bit field with absolute ; positioning and no preferred state db 95h, 07h ; 7 reports for reversing, upper 7 bits of ; byte 3 db b1h, 01h ; constant array bit field with absolute ; positioning db 0c0h ; end collection, end collection hidReportDescTableEnd: ep2hidReportDescTable: db 05h, 01h ; USAGE_PAGE (Generic Desktop) db 09h, 00h ; USAGE (Undefined) db A1h, 01h ; COLLECTION (Application) db 05h, 10h ; USAGE_PAGE (Unicode) db 19h, 00h ; USAGE_MINIMUM (Unicode Char 0) db 29h, 08h ; USAGE_MAXIMUM (Unicode Char 8) db 15h, 00h ; LOGICAL_MINIMUM (0) db 26h, FFh, 00h ; LOGICAL_MAXIMUM (255) db 75h, 08h ; REPORT_SIZE (8) db 95h, 08h ; REPORT_COUNT (8) db 81h, 00h ; INPUT (Data,Ary,Abs) db C0h ; END_COLLECTION ep2hidReportDescTableEnd: 其中的configDescTable有一项bNumInterfaces是不是代表了接口的数目?我把它设为2时为什么系统发现不了它是两个接口?(只标识为USB人体学输入设备,但却不能启用) 另外,我还想请问一下USB芯片里的endpoint1和2是不是具有同样的功能?都可以向主机传送数据? |
|
最新喜欢:![]()
|
沙发#
发布于:2003-06-29 19:11
用户被禁言,该主题自动屏蔽! |
|
板凳#
发布于:2003-06-28 11:02
jiyu75:我还想请教描述符不是要按照一定的顺序来放的吗?我的理解是这样的:
首先是:device descriptor 然后是:configuration descriptor 然后是:interface1 descriptor *****************三行为一组,有多少个接口就写多少组 hid1class descriptor 1endpoint descriptor 。。。 。。。 。。。 interfaceN descriptor hidNclass descriptor Nendpoint descriptor ****************** 最后是:hid report descriptor *****有多少个接口就写多少个hid report descriptor 这样理解对吗? |
|
|
地板#
发布于:2003-06-26 10:40
用户被禁言,该主题自动屏蔽! |
|
地下室#
发布于:2003-06-26 09:32
jiyu75:能不能请你解释一下以下两行:
db (StringDscr-ConfigDscr) mod 256 ;; Configuration + End Points length (LSB) db (StringDscr-ConfigDscr)/256 ;; Configuration length (MSB) 另外我的程序中有两个接口的描述符,当我把Number of interfaces 项定为1的时候设备能被系统识别,但是把它定为2的时候系统虽然能够识别为人机输入设备,但是带有感叹号,设备不能启用。我想既然配置里有两个接口,那Number of interfaces项应该为2才对,为什么我定为2时设备不能启用? |
|
|
5楼#
发布于:2003-06-25 20:48
》》另外,我还想请问一下USB芯片里的endpoint1和2是不是具有同样
》》功能?都可以向主机传送数据? Endpoint 的功能是由硬件本身来决定的,你可以查一下你所用的UDC的Spec.里面应该有详细的解释。 |
|
6楼#
发布于:2003-06-25 15:47
用户被禁言,该主题自动屏蔽! |
|
7楼#
发布于:2003-06-21 10:11
楼上的老兄你是指bInterfaceNumber行还是bNumEndpoints行?
|
|
|
8楼#
发布于:2003-06-20 16:45
用户被禁言,该主题自动屏蔽! |
|
9楼#
发布于:2003-06-20 12:20
你所说的软件是指芯片里的程序还是指和他对应的驱动程序?如果是前者,我在上面的描述符上还没有做设定吗?芯片里有使用ep2的程序段,可是系统不能启用该设备;如果要对应的驱动程序来设定,操作系统自带的HID驱动程序不能对ep2进行操作吗?现在操作系统只可以认它是USB人体学输入设备,但是不能启用,请继续指点!
|
|
|
10楼#
发布于:2003-06-20 11:58
ep的收发完全要有软件来设定硬体!
|
|