OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 6040|回复: 4

USB设备枚举成功,但是通信不了,这是为什么??求大神帮忙

[复制链接]

6

主题

18

帖子

0

精华

初级会员

Rank: 2

积分
165
金钱
165
注册时间
2013-6-3
在线时间
24 小时
发表于 2015-7-6 22:13:19 | 显示全部楼层 |阅读模式
5金钱
我用usb鼠标的历程改了一个USB游戏控制设备,枚举是成功了,可是数据一直通信不上,无论是输入还是输出,用BUS Hound监控,发现输入的数据总是只有四个,原来鼠标的报告描述符里面设定的的确是4个字节的输入,可是我已经改了啊,而且在端点描述符上面我也有定义啊,怎么还是不能用呢??是还要改动哪边呢??
const u8 Joystick_DeviceDescriptor[JOYSTICK_SIZ_DEVICE_DESC] =
  {
    0x12,                       /*bLength */
    USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
    0x00,                       /*bcdUSB usb2.0*/
    0x02,
    0x00,                       /*bDeviceClass*/
    0x00,                       /*bDeviceSubClass*/
    0x00,                       /*bDeviceProtocol*/
    0x40,                       /*bMaxPacketSize40*/
    0x33,                       /*idVendor */
    0x21,
    0x12,                       /*idProduct*/
    0x54,
    0x01,                       /*bcdDevice rel. 2.00*/
    0x02,
    1,                          /*Index of string descriptor describing
                                                  manufacturer */
    2,                          /*Index of string descriptor describing
                                                 product*/
    3,                          /*Index of string descriptor describing the
                                                 device serial number */
    0x01                        /*bNumConfigurations*/
  }
  ; /* Joystick_DeviceDescriptor */


/* USB Configuration Descriptor */
/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const u8 Joystick_ConfigDescriptor[JOYSTICK_SIZ_CONFIG_DESC] =
  {
    0x09, /* bLength: Configuation Descriptor size */
    USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
    JOYSTICK_SIZ_CONFIG_DESC,
    /* wTotalLength: Bytes returned */
    0x00,
    0x01,         /*bNumInterfaces: 1 interface*/
    0x01,         /*bConfigurationValue: Configuration value*/
    0x00,         /*iConfiguration: Index of string descriptor describing
                                     the configuration*/
    0x80,         /*bmAttributes: bus powered */
    0x28,         /*MaxPower 200 mA: this current is used for detecting Vbus*/

    /************** Descriptor of Joystick Mouse interface ****************/
    /* 09 */
    0x09,         /*bLength: Interface Descriptor size*/
    USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/
    0x00,         /*bInterfaceNumber: Number of Interface*/
    0x00,         /*bAlternateSetting: Alternate setting*/
    0x02,         /*bNumEndpoints*/
    0x03,         /*bInterfaceClass: HID*/
    0x00,         /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
    0x00,         /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
    0,            /*iInterface: Index of string descriptor*/
    /******************** Descriptor of Joystick Mouse HID ********************/
    /* 18 */
    0x09,         /*bLength: HID Descriptor size*/
    HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
    0x10,         /*bcdHID: HID Class Spec release number*/
    0x01,
    0x00,         /*bCountryCode: Hardware target country*/
    0x01,         /*bNumDescriptors: Number of HID class descriptors to follow*/
    0x22,         /*bDescriptorType*/
    JOYSTICK_SIZ_REPORT_DESC,/*wItemLength: Total length of Report descriptor*/
    0x00,
    /******************** Descriptor of Joystick Mouse endpoint ********************/
    /* 27 */
    0x07,          /*bLength: Endpoint Descriptor size*/
    USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/

    0x81,          /*bEndpointAddress: Endpoint Address (IN)*/
    0x03,          /*bmAttributes: Interrupt endpoint*/
    0x40,          /*wMaxPacketSize: 4 Byte max */
    0x00,
    0x02,          /*bInterval: Polling Interval (32 ms)*/
    /* 34 */
0x07,          /*bLength: Endpoint Descriptor size*/
    USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/

    0x01,          /*bEndpointAddress: Endpoint Address (IN)*/
    0x03,          /*bmAttributes: Interrupt endpoint*/
    0x40,          /*wMaxPacketSize: 4 Byte max */
    0x00,
    0x02,          /*bInterval: Polling Interval (32 ms)*/
    /* 41 */
  }
  ; /* MOUSE_ConfigDescriptor */
const u8 Joystick_ReportDescriptor[JOYSTICK_SIZ_REPORT_DESC] =
  {
    0x05,0x01,
0x09,0x04,
0xa1,0x01,
0x05,0x02,
0x09,0xbb,
0x15,0x81,
0x25,0x7F,
0x75,0x08,
0x95,0x01,
0x81,0x02,
0x05,0x01,
0x09,0x01,
0xa1,0x00,
0x09,0x30,
0x09,0x31,
0x09,0x32,
0x09,0x33,
0x09,0x34,
0x09,0x35,
0x95,0x06,
0x81,0x02,
0xc0,
0x09,0x39,
0x15,0x00,
0x25,0x03,
0x35,0x00,
0x46,0x0e,0x01,
0x65,0x14,
0x55,0x00,
0x75,0x04,
0x95,0x01,
0x81,0x42,
0x05,0x09,
0x19,0x01,
0x29,0x13,
0x15,0x00,
0x25,0x01,
0x35,0x00,
0x45,0x01,
0x75,0x01,
0x95,0x13,
0x65,0x00,
0x81,0x02,
0x95,0x07,
0x06,0x00,0xff,
0x09,0x02, 
0x91,0x02,
0xc0,
  }
  ; /* Joystick_ReportDescriptor */

最佳答案

查看完整内容[请看2#楼]

回复【3楼】htcq: ------------------------------ 问题终于解决了,大家要小心设置发送数据字节数寄存器,我就是设置的字节数和报告描述符里定义的字节数不符才导致通信不成功的。。。。。usb_prop.c的函数好好重新看下,问题就解决了
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

6

主题

18

帖子

0

精华

初级会员

Rank: 2

积分
165
金钱
165
注册时间
2013-6-3
在线时间
24 小时
 楼主| 发表于 2015-7-6 22:13:20 | 显示全部楼层
回复【3楼】htcq:
------------------------------
问题终于解决了,大家要小心设置发送数据字节数寄存器,我就是设置的字节数和报告描述符里定义的字节数不符才导致通信不成功的。。。。。usb_prop.c的函数好好重新看下,问题就解决了
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2015-7-6 23:10:17 | 显示全部楼层
帮顶....
回复

使用道具 举报

6

主题

18

帖子

0

精华

初级会员

Rank: 2

积分
165
金钱
165
注册时间
2013-6-3
在线时间
24 小时
 楼主| 发表于 2015-7-7 11:21:04 | 显示全部楼层
回复【2楼】正点原子:
-----------------------------
原子哥,就是我觉得这是端点的发送数据字节数寄存器没配好,发送数据字节数寄存器在哪里配置呢?还是说它是根据端点描述符中的wMaxPacketSize来设定的??
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2015-7-7 22:31:53 | 显示全部楼层
回复【4楼】htcq:
---------------------------------
谢谢分享
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-20 16:03

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表