21ic电子技术开发论坛 单片机与嵌入式系统 ST MCU 帮忙看看, STM32 USB 描述2个接口无法枚举
发新帖我要提问
返回列表
打印

帮忙看看, STM32 USB 描述2个接口无法枚举

[复制链接]
2965|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lattice1|  楼主 | 2011-4-1 18:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个问题困扰我一段时间了,实在不知道怎么了,问问大家:

1.为了在win7 (touch设备) 和 xp (鼠标设备) 系统下发送不同的数据(数据长度不同),在配置描述符中描述2个接口/*bNumInterfaces: 2 interface*/,无法完成枚举,把/*bNumInterfaces: 1 interface*/ 修改为1,可以正常枚举,不知道为什么?

2.我的要求就是在不同系统下,可以发送不同长度的数据, 针对这样的应用大家有什么经验,和建议?

3.我把配置描述符发上来

const u8 ConfigDescriptor[CONFIG_DESC] =
  {
    0x09, /* bLength: Configuation Descriptor size */
    USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
    CONFIG_DESC,
    0x00,/* wTotalLength: Bytes returned */
    0x01,         /*bNumInterfaces: 2 interface*/
    0x01,         /*bConfigurationValue: Configuration value*/
    0x00,         /*iConfiguration: Index of string descriptor describing
                                     the configuration*/
    0xc0,         /*bmAttributes: bus powered */
    0x32,         /*MaxPower 100 mA: this current is used for detecting Vbus*/
   
    /************** Descriptor 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*/
    0x02,         /*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*/
    0x10,         /*bcdHID: HID Class Spec release number*/
    0x01,
    0x00,         /*bCountryCode: Hardware target country*/
    0x01,         /*bNumDescriptors: Number of HID class descriptors to follow*/
    0x22,         /*bDescriptorType*/
    REPORT_DESC ,// 0x0f,         /*wItemLength: Total length of Report descriptor*/
    0, //0x01,         //报告描述符长度,0x010f ,271 bytes
    /****************** Endpoint 1 Descriptor************/
    /* 27 */
    0x07,           //bLength: Endpoint Descriptor size*/
    USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
   
    0x81,          //bEndpointAddress: Endpoint 1 Address (IN)*/
    0x03,          //bmAttributes: Interrupt endpoint*/
    0x40,          //wMaxPacketSize: 64 Byte max */
    0x00,
    0x01,          //bInterval: Polling Interval (1 ms)*/    34 bytes
   
  /**********************Endpoint 1 Descriptor***********************/  
    0x07,  // bLength: Endpoint Descriptor size
    USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType:  
   
    0x01, // bEndpointAddress: Endpoint Address (OUT)
    0x03, // bmAttributes: Interrupt endpoint  
    0x40, // wMaxPacketSize: 64 Bytes max   
    0x00,
    0x01, // bInterval: Polling Interval (1 ms)  
   
    //==================2 接口描述符======================
    0x09, //接口描述符长度
    0x04, //接口描述符
    0x01, //接口编号从1开始      
    0x00, //备用编号
    0x02, //该接口使用的端点数
    0x03, //接口使用的类,0x03 是HID  
    0x00, //no boot
    0x00, //keyboard
    0x00, //接口字符串的Index
    //===================2 HID描述符========================
    0x09, //HID 描述符 长度
    0x21, //HID 描述符
    0x10, //版本
    0x01,
    0x00, //
    0x01, //
    0x22, //type
    0x41, //报告描述符的长度         
    0x00,
   //======================2 端点描述符===================
    0x07, //端点描述符长度
    0x05, //端点描述符
    0x82, //输入端点地址
    0x03, //interrupt
    0x40, //字节数目
    0x00, //
    0x01, //查询时间
   
    0x07, //端点描述符长度
    0x05, //端点描述符
    0x02, //输出端点地址
    0x03,//interrupt
    0x40, //字节数目
    0x00,
    0x01, //查询时间

                              
  }; /* HID ConfigDescriptor */


谢谢了
沙发
lattice1|  楼主 | 2011-4-2 09:30 | 只看该作者
自己D下

使用特权

评论回复
板凳
johnsenchen| | 2011-5-7 16:26 | 只看该作者
楼主,我现在也在做usb,能不能一起探讨下
我的qq:541625212
谢谢楼主了

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

99

主题

300

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部