打印

编译 stm32 usb 实现 ch340 usb串口,cpu 返回的SET_CONFIGURATION 带参数0

[复制链接]
2862|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ljxh401|  楼主 | 2021-1-28 17:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
配置不成功,描述符 都是 抄网上的 demo的
SET_CONFIGURATION 附带的配置 0
网上查到的资料 :如果配置值为零,则设备将处于地址状态(Address state),等待新的Set Configuration请求进行配置

/* USB Standard Device Descriptor */
const uint8_t Virtual_Com_Port_DeviceDescriptor[] =
  {
    0x12,   /* bLength */
    USB_DEVICE_DESCRIPTOR_TYPE,     /* bDescriptorType */
    0x10,
    0x01,   /* bcdUSB = 1.1 */
    0xFF,   /* bDeviceClass: Vendor */
    0x00,   /* bDeviceSubClass */
    0x00,   /* bDeviceProtocol */
    0x08,   /* bMaxPacketSize0 = 8 */
    0x86,
    0x1A,   /* idVendor = 0x1A86 */
    0x23,
    0x75,   /* idProduct = 0x7523 */
    0x54,
    0x02,   /* bcdDevice = 2.54 */
    1,              /* Index of string descriptor describing manufacturer */
    2,              /* Index of string descriptor describing product */
    3,              /* Index of string descriptor describing the device's serial number */
    0x01    /* bNumConfigurations */
  };

const uint8_t Virtual_Com_Port_ConfigDescriptor[] =
  {
    /*Configuration Descriptor*/
    0x09,   /* bLength: Configuration Descriptor size */
    USB_CONFIGURATION_DESCRIPTOR_TYPE,      /* bDescriptorType: Configuration */
    VIRTUAL_COM_PORT_SIZ_CONFIG_DESC,       /* wTotalLength:no of returned bytes */
    0x00,
    0x01,   /* bNumInterfaces: 1 interface */
    0x01,   /* bConfigurationValue: Configuration value */
    0x00,   /* iConfiguration: Index of string descriptor describing the configuration */
    0x80,   /* bmAttributes: self powered */
    0x32,   /* MaxPower 100 mA */
    /*Interface Descriptor*/
    0x09,   /* bLength: Interface Descriptor size */
    USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: Interface */
    /* Interface descriptor type */
    0x00,   /* bInterfaceNumber: Number of Interface */
    0x00,   /* bAlternateSetting: Alternate setting */
    0x03,   /* bNumEndpoints: 3 endpoints used */
    0xFF,   /* bInterfaceClass: Vendor Interface Class */
    0x01,   /* bInterfaceSubClass */
    0x02,   /* bInterfaceProtocol */
    0x00,   /* iInterface: */
    /* Endpoint 2 IN Descriptor*/
    0x07,   /* bLength: Endpoint Descriptor size */
    USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
    0x82,   /* bEndpointAddress: (IN2) */
    0x02,   /* bmAttributes: Bulk */
    VIRTUAL_COM_PORT_DATA_SIZE,      /* wMaxPacketSize: */
    0x00,
    0x00,   /* bInterval: */
    /* Endpoint 2 OUT Descriptor*/
    0x07,   /* bLength: Endpoint Descriptor size */
    USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
    0x02,   /* bEndpointAddress: (OUT2) */
    0x02,   /* bmAttributes: Bulk */
    VIRTUAL_COM_PORT_DATA_SIZE,             /* wMaxPacketSize: */
    0x00,
    0x00,   /* bInterval: ignore for Bulk transfer */
    /* Endpoint 1 IN Descriptor*/
    0x07,   /* bLength: Endpoint Descriptor size */
    USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
    0x81,   /* bEndpointAddress: (IN1) */
    0x03,   /* bmAttributes: Interrupt */
    VIRTUAL_COM_PORT_INT_SIZE,             /* wMaxPacketSize: */
    0x00,
    0x01    /* bInterval */
  };

使用特权

评论回复

相关帖子

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

本版积分规则

49

主题

220

帖子

3

粉丝