打印

STM32 USB 2个接口描述符的问题

[复制链接]
5030|10
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lattice1|  楼主 | 2011-2-18 14:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在一个接口描述符工作正常,,在这个基础是增加一个接口描述符,HID描述符,Endpoint描述符,就不行了,没法枚举,这是为什么?》
沙发
vigia| | 2011-2-18 16:55 | 只看该作者
把你改后的描述符贴出来看看

有没有申明是USB复合设备,具有2个借口描述符?

使用特权

评论回复
板凳
lattice1|  楼主 | 2011-2-19 09:26 | 只看该作者
本帖最后由 lattice1 于 2011-2-19 09:28 编辑

/* USB Configuration Descriptor */
/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const u8 ConfigDescriptor[CONFIG_DESC] =
  {
    0x09, /* bLength: Configuation Descriptor size */
    USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
    CONFIG_DESC,
    /* wTotalLength: Bytes returned */
    0x00,
    0x01,// 0x02,         /*bNumInterfaces: 2 interface*/
    0x01,         /*bConfigurationValue: Configuration value*/
    0x00,         /*iConfiguration: Index of string descriptor describing
                                     the configuration*/
    0xe0,         /*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,          //wMaxPacketSiz e: 64 Byte max */
    0x00,
    0x01,          //bInterval: Polling Interval (1 ms)*/
   
  /**********************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, //查询时间

使用特权

评论回复
地板
lattice1|  楼主 | 2011-2-19 14:58 | 只看该作者
有没有人知道哦!

使用特权

评论回复
5
lattice1|  楼主 | 2011-3-14 14:29 | 只看该作者
寂寞的问题,寂寞的很

使用特权

评论回复
6
szdianzijie| | 2011-3-14 15:38 | 只看该作者
这里高手如云,放心了

使用特权

评论回复
7
vigia| | 2011-3-14 17:03 | 只看该作者
描述符没看出问题

我猜最有可能的问题是

你有没有根据接口号上传第二个接口的REPORT描述符?

使用特权

评论回复
8
lattice1|  楼主 | 2011-3-15 11:43 | 只看该作者
在枚举时,上传了,

使用特权

评论回复
9
lattice1|  楼主 | 2011-3-15 11:43 | 只看该作者
PC就没有读配置描述符了

使用特权

评论回复
10
lattice1|  楼主 | 2013-7-10 16:34 | 只看该作者
前东家工作时发的帖子。现在看起来蛮亲切。顶下

使用特权

评论回复
评论
不明所以 2019-9-20 13:34 回复TA
时隔几年,你的问题解决了吗? 
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

99

主题

300

帖子

3

粉丝