OpenEdv-开源电子网

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

STM32复合设备的描述符配置问题

[复制链接]

13

主题

68

帖子

0

精华

初级会员

Rank: 2

积分
153
金钱
153
注册时间
2012-3-24
在线时间
3 小时
发表于 2012-7-15 16:48:26 | 显示全部楼层 |阅读模式
现在定义了两个Interface,一个是JoystickMouse,一个是多媒体键盘。现在把usb线插在电脑上只有鼠标功能能够实现,另一个设备提示不能启动。
鼠标只用了端点1,多媒体键盘用了端点2
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

13

主题

68

帖子

0

精华

初级会员

Rank: 2

积分
153
金钱
153
注册时间
2012-3-24
在线时间
3 小时
 楼主| 发表于 2012-7-15 17:26:24 | 显示全部楼层
贴个设备描述符,实在不想耗费flash的寿命了。。。。请玩过usb的朋友看看
前面是鼠标的描述,后面是键盘的描述
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,
    0x02,         /*bNumInterfaces: 2 interface*/
    0x01,         /*bConfigurationValue: Configuration value*/
    0x00,         /*iConfiguration: Index of string descriptor describing
                                     the configuration*/
    0xA0,         /*bmAttributes: bus powered 总线供电,支持远程唤醒;供电模式选择.Bit4-0保留,D7:总线供电,D6:自供电,D5:远程唤醒
 */
    0x64,         /*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*/
    0x01,         /*bNumEndpoints*/
    0x03,         /*bInterfaceClass: HID*/
    0x01,         /*bInterfaceSubClass: 1=BOOT, 0=no boot*/
    0x02,         /*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*/
    0x00,         /*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*/
    0x04,          /*wMaxPacketSize: 4 Byte max*/
    0x00,
    0x20,          /*bInterval: olling Interval (32 ms)*/

/*-------------------------------------------------------------------*/
/************** Descriptor of keyboard interface ****************/

    /************** Descriptor of interface ****************/
    /* 09 */
    0x09,         /*bLength: Interface Descriptor size*/
    USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/
    0x01,         /*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 HID ********************/
    /* 18 */
    0x09,         /*bLength: HID Descriptor size*/
    HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
    0x00,         /*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_KP,/*wItemLength: Total length of Report descriptor*/
    0x00,
    /******************** Descriptor of  endpoint ********************/
    /* 27 */
    0x07,          /*bLength: Endpoint Descriptor size*/
    USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/

    0x82,          /*bEndpointAddress: Endpoint Address (IN)*/
    0x03,          /*bmAttributes: Interrupt endpoint*/
    0x40,          /*wMaxPacketSize: 64 Byte max */
    0x00,
    0x0A,          /*bInterval: olling Interval (10 ms)*/
    /* 34 */
    /******************** Descriptor of  endpoint ********************/
    /* 27 */
    0x07,          /*bLength: Endpoint Descriptor size*/
    USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/

    0x02,          /*bEndpointAddress: Endpoint Address (OUT)*/
    0x03,          /*bmAttributes: Interrupt endpoint*/
    0x40,          /*wMaxPacketSize: 64 Byte max */
    0x00,
    0x0A,          /*bInterval: olling Interval (10 ms)*/
    /* 34 */
}
回复 支持 反对

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2012-7-15 18:55:37 | 显示全部楼层
这个没研究...
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

13

主题

68

帖子

0

精华

初级会员

Rank: 2

积分
153
金钱
153
注册时间
2012-3-24
在线时间
3 小时
 楼主| 发表于 2012-7-15 19:52:04 | 显示全部楼层
回复【3楼】正点原子:
---------------------------------
。。。连教程都写了
回复 支持 反对

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2012-7-15 23:14:59 | 显示全部楼层
回复【4楼】kurooruan:
---------------------------------
我的USB部分介绍很少的,呵呵.
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

7

主题

85

帖子

0

精华

初级会员

Rank: 2

积分
163
金钱
163
注册时间
2011-3-3
在线时间
12 小时
发表于 2012-7-16 22:47:42 | 显示全部楼层
首先, 这个是配置描述符, 不是设备描述符。
对于双HID类设备,建议用增加报告ID形式,别用增加接口形式,如果用增加接口方式,最好两个中断端点的中断时间间隔成10被或更多(简单测过),不然一个报告容易丢失,只能有一个设备工作。
回复 支持 反对

使用道具 举报

13

主题

68

帖子

0

精华

初级会员

Rank: 2

积分
153
金钱
153
注册时间
2012-3-24
在线时间
3 小时
 楼主| 发表于 2012-7-16 22:56:22 | 显示全部楼层
回复【6楼】爱上cmu:
---------------------------------
嗯,这就是配置描述符。我用圈圈的方法,通过report id 来区分设备,已经成功了。。谢谢关注
回复 支持 反对

使用道具 举报

6

主题

39

帖子

0

精华

初级会员

Rank: 2

积分
103
金钱
103
注册时间
2014-10-21
在线时间
7 小时
发表于 2014-12-11 14:23:39 | 显示全部楼层
回复【7楼】kurooruan:
---------------------------------
请教我使用圈圈的方法,在报告描述的地方把两种报告糅合在一块,可以识别为USB设备,但是安装驱动失败,请问你是怎么做到的?
爱电子,爱科技,爱新技术
回复 支持 反对

使用道具 举报

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

本版积分规则



关闭

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

正点原子公众号

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

GMT+8, 2025-6-28 02:10

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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