阅读:2436回复:9
我这样实现我的HID设备,但是有问题,欢迎探讨!
我用一个片CY68013(56pin),外接了几个按键(4个方向键+8个功能键)。其主要功能类似一个简单的游戏摇杆。因为它是一个典型的HID设备,所以我不想另外编写驱动程序,想干脆让它在系统中(WIN2000PF)表现成一个游戏摇杆。
至于设备内的固件程序我是这样做的: 1.因为我用的是CYPRESS的68013,所以我就直接借用他们提供的一个所谓FW程序(FRAMWORK),即固件框架程序。 2.我在他们的FW程序中这样修改,将一个描述表文件修改成如下内容(不修改设备描述符和高速部分的描述符,因为不用到高速部分): FullSpeedConfigDscr: db DSCR_CONFIG_LEN ;; Descriptor length db DSCR_CONFIG ;; Descriptor type db (FullSpeedConfigDscrEnd-FullSpeedConfigDscr) mod 256 ;; Total Length (LSB) db (FullSpeedConfigDscrEnd-FullSpeedConfigDscr) / 256 ;; Total Length (MSB) db 1 ;; Number of interfaces db 1 ;; Configuration number db 0 ;; Configuration string db 10100000b ;; Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu) db 10 ;; Power requirement (div 2 ma) ;; Interface Descriptor db DSCR_INTRFC_LEN ;; Descriptor length db DSCR_INTRFC ;; Descriptor type db 0 ;; Zero-based index of this interface db 0 ;; Alternate setting db 1 ;; Number of end points db 03H ;; Interface class db 00H ;; Interface sub class db 00H ;; Interface sub sub class db 0 ;; Interface descriptor string index ;; hid descriptor db 0x09 /* descriptor size (9 bytes) */ db 0x21 /* descriptor type (HID) */ db 0x10, 0x01/* class specification (1.10) */ db 0x00 /* hardware target country */ db 0x01 /* number of hid class desriptors to follow */ db 0x22 /* report descriptor type (2) */ db end_hid_report_desc_table-hid_report_desc_table db 0x00 ;; HID Report Descriptor hid_report_desc_table: db 05h, 01h ; Usage Page (Generic Desktop) db 09h, 04h ; Usage (joystick) db 0xA1, 01h ; Collection (Application) db 05h, 01h ; Usage Page (Generic Desktop) db 09h, 01h ; Usage (Pointer) db 0xA1, 00h ; Collection (Physical) ; x and y axes db 09h, 30h ; Usage (X) db 09h, 31h ; Usage (Y) db 15h, 00h ; Logical Minimum (0) db 26h, 00h,0xFF ; Logical Maximum (255) db 75h, 10h ; Report Size (16) (bits) db 95h, 02h ; Report Count (2) (fields) db 81h, 02h ; Input (Data, Variable, Absolute) ; z axis, twist db 09h, 35h ; Usage (Rotation about z-axis) ; user can change z-axis to other functions besides twist db 15h, 00h ; Logical Minimum (0) db 26h, 00h,0xFF ; Logical Maximum (255) db 75h, 10h ; Report Size (16) (bits) db 95h, 01h ; Report Count (1) (fields) db 81h, 02h ; Input (Data, Variable, Absolute) ; hat switch db 09h, 39h ; Usage (Hat switch) db 15h, 01h ; Logical Minimum (1) db 25h, 08h ; Logical Maximum (8) db 75h, 08h ; Report Size (8) (bits) db 95h, 01h ; Report Count (1) (fields) db 81h, 02h ; Input (Data, Variable, Absolute) db 0xC0 ; End Collection ;buttons db 05h, 09h ; Usage page (buttons) db 19h, 01h ; Usage minimum (1) db 29h, 08h ; Usage maximum (8) db 15h, 00h ; Logical Minimum (0) db 25h, 01h ; Logical Maximum (1) db 75h, 01h ; Report Size (1) db 95h, 08h ; Report Count (8) db 81h, 02h ; Input (Data, Variable, Absolute) db 0xC0 ; End Collection end_hid_report_desc_table: ;; Endpoint Descriptor db DSCR_ENDPNT_LEN ;; Descriptor length db DSCR_ENDPNT ;; Descriptor type db 81H ;; Endpoint number, and direction db ET_INT ;; Endpoint type db 08H ;; Maximun packet size (LSB) db 00H ;; Max packect size (MSB) db 0AH ;; Polling interval FullSpeedConfigDscrEnd: 3.主程序不做任何修改,现在将设备插到系统上,会将CPU利用率提高到100%。进而导致系统速度严重下降。 请各位高手指点一二!若有表达不清之处请提出!谢谢! [编辑 - 2/9/04 by sean_wang] |
|
沙发#
发布于:2004-02-09 17:26
顶
|
|
板凳#
发布于:2004-02-10 10:39
没人懂吗?
|
|
地板#
发布于:2004-02-10 16:06
你到底要问什么? :D
|
|
地下室#
发布于:2004-02-11 11:26
终于有人回答了,谢谢。
我的问题是按照如上的做法,当我将设备插到PC时会使PC的CPU利用率一下子变成100%,然后PC机就会变得其慢无比!但不会死机。这是什么原因造成的呢?我知道肯定是我的固件程序有问题,但一时摸不到头绪。 |
|
5楼#
发布于:2004-02-11 11:37
usb bus上有没有数据在传输?一般hid设备插入后系统会加载hidserver程序在后台,定时的查询。检查一下这部分
|
|
6楼#
发布于:2004-02-11 12:14
总线上有数据在传输,这点我肯定。我向可能和HID报告描述符有关,因为当我将报告描述符的位置换一下以上的情况就消失了,而且系统也“看”到了我的HID设备,但系统无法正常将设备启动。在设备列表里有一个大大的“!”并说设备无法启动。
DX,你能告诉我HID报告描述符和HID描述符分别应该在什么时候提交给主机呢?我是说具体些,比如当设备收到哪个8字节的SETUP命令时要提交这两个描述符呢? |
|
7楼#
发布于:2004-02-16 10:05
很简单的原因.
你的HID INPUT的描述有问题,这样就导致电脑在读你的USB输入的时候,总得不到正确得数据,就停在那里不动. www.eyeteck.com |
|
8楼#
发布于:2004-02-16 10:18
8 CTL 80 06 00 02 - 00 00 22 00 GET DESCRIPTR 42us 23.1.0 8 DI 09 02 22 00 - 01 01 00 80 .."..... 11ms 23.2.0 32 09 04 00 - 00 01 03 01 2....... 23.2.8 01 03 09 21 - 00 01 00 01 ...!.... 23.2.16 22 3f 00 07 - 05 81 03 08 "?...... 23.2.24 00 0a .. 23.2.32 8 CTL 00 09 01 00 - 00 00 00 00 SET CONFIG 27us 24.1.0 8 CTL 21 0a 00 00 - 00 00 00 00 CLASS 3.2ms 25.1.0 8 CTL 80 06 00 22 - 00 00 7f 00 GET DESCRIPTR 2.7ms 26.1.0 8 DI 05 01 09 06 - a1 01 05 07 ........ 18ms 26.2.0 19 e0 29 e7 - 15 00 25 01 ..)...%. 26.2.8 75 01 95 08 - 81 02 95 01 u....... 26.2.16 75 08 81 01 - 95 05 75 01 u.....u. 26.2.24 05 08 19 01 - 29 03 91 02 ....)... 26.2.32 95 01 75 03 - 91 01 95 06 ..u..... 26.2.40 75 08 15 00 - 25 65 05 07 u...%e.. 26.2.48 19 00 29 65 - 81 00 c0 ..)e... 自己可以抓一下嘛。这个是以前抓的 |
|
9楼#
发布于:2004-02-16 13:12
机器都跑不动了,怎么个抓法儿??
不过现在问题搞定了,关键还是没有在适当的时间将REPORT描述符提交。 谢谢各位指点! |
|