打印

U盘+串口只可以看到U盘

[复制链接]
1211|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
mfkihc|  楼主 | 2013-10-29 18:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这是我的设备描符和配置描述符
const uint8_t USB_DeviceDescriptor[] =
{
        LEN_DEVICE,                    /* bLength */
        DESC_DEVICE,            /* bDescriptorType */
        0x00, 0x02,                    /* bcdUSB */
        0x00,                            /* bDeviceClass */
        0x00,                            /* bDeviceSubClass */
        0x00,                            /* bDeviceProtocol */
        MAX_PACKET_SIZE_CTRL,        /* bMaxPacketSize0 */
        /* idVendor */
        USB_VID & 0x00FF,
        (USB_VID & 0xFF00) >> 8,
        /* idProduct */
        USB_PID & 0x00FF,
        (USB_PID & 0xFF00) >> 8,
        0x00, 0x00,                    /* bcdDevice */
        0x01,                            /* iManufacture */
        0x02,                            /* iProduct */
        0x01,                            /* iSerialNumber */
        0x01                            /* bNumConfigurations */
};


/*!<USB Configure Descriptor */
const uint8_t USB_ConfigDescriptor[] =
{
        LEN_CONFIG,                                                        /* bLength */
        DESC_CONFIG,                                                /* bDescriptorType */
        ((LEN_CONFIG+LEN_INTERFACE+LEN_ENDPOINT*2)+58+16), 0x00,                /* wTotalLength */
        0x03,                                                                /* bNumInterfaces */
        0x01,                                                                /* bConfigurationValue */
        0x00,                                                                /* iConfiguration */
        0xC0,                                                                /* bmAttributes */
        0x32,                                                                /* MaxPower */


//--------------------------------------------------------------------
// IAD
    0x08,        //描述符大小
    0x0B,        //IAD描述符类型
    0x00,        // bFirstInterface
    0x02,        // bInterfaceCount
    0x02,        // bFunctionClass: CDC Class
    0x02,        // bFunctionSubClass
    0x01,        // bFunctionProtocol
    0x00,        // iFunction         

        //在这里增加CDC用到的端点和接口描述符
        /* INTERFACE descriptor */
        LEN_INTERFACE,        /* bLength              */
        DESC_INTERFACE,        /* bDescriptorType      */
        0x00,                        /* bInterfaceNumber    接口编号1 */
        0x00,                        /* bAlternateSetting    */
        0x01,                        /* bNumEndpoints        该接口下面端点数目*/
        0x02,                        /* bInterfaceClass      */
        0x02,                        /* bInterfaceSubClass   */
        0x01,                        /* bInterfaceProtocol   */
        0x00,                        /* iInterface           */

        /* Communication Class Specified INTERFACE descriptor */
    0x05,           /* Size of the descriptor, in bytes */
    0x24,           /* CS_INTERFACE descriptor type */
    0x00,           /* Header functional descriptor subtype */
    0x10, 0x01,     /* Communication device compliant to the communication spec. ver. 1.10 */
   
        /* Communication Class Specified INTERFACE descriptor */
    0x05,           /* Size of the descriptor, in bytes */
    0x24,           /* CS_INTERFACE descriptor type */
    0x01,           /* Call management functional descriptor */
    0x00,           /* BIT0: Whether device handle call management itself. */
                    /* BIT1: Whether device can send/receive call management information over a Data Class Interface 0 */
    0x01,           /* Interface number of data class interface optionally used for call management */

        /* Communication Class Specified INTERFACE descriptor */
    0x04,           /* Size of the descriptor, in bytes */
    0x24,           /* CS_INTERFACE descriptor type */
    0x02,           /* Abstract control management funcational descriptor subtype */
    0x00,           /* bmCapabilities       */
   
        /* Communication Class Specified INTERFACE descriptor */
    0x05,           /* bLength              */
    0x24,           /* bDescriptorType: CS_INTERFACE descriptor type */
    0x06,           /* bDescriptorSubType   */
    0x00,           /* bMasterInterface     */
    0x01,           /* bSlaveInterface0     */
   
        /* ENDPOINT descriptor */
        LEN_ENDPOINT,                        /* bLength          */
        DESC_ENDPOINT,                        /* bDescriptorType  */
        (EP_INPUT | INT_IN_EP_NUM),     /* bEndpointAddress //端点地址:3,中断IN */
        EP_INT,                                    /* bmAttributes     */
        MAX_PACKET_SIZE_BULK, 0x00,            /* wMaxPacketSize   */
        0x01,                                /* bInterval        */   //间隔 1ms

//--------------------------------------------------------------                       
        /* INTERFACE descriptor */
        LEN_INTERFACE,        /* bLength              */
        DESC_INTERFACE,        /* bDescriptorType      */
        0x01,                        /* bInterfaceNumber     接口编号为2*/
        0x00,                        /* bAlternateSetting    */
        0x02,                        /* bNumEndpoints       该接口有两个端点 */
        0x0A,                        /* bInterfaceClass      */
        0x00,                        /* bInterfaceSubClass   */
        0x00,                        /* bInterfaceProtocol   */
        0x00,                        /* iInterface           */
                       
        /* ENDPOINT descriptor */
        LEN_ENDPOINT,                        /* bLength          */
        DESC_ENDPOINT,                        /* bDescriptorType  */
        (EP_INPUT | BULK_IN_EP_NUM),        /* bEndpointAddress     //端点地址:1, Bulk in*/
        EP_BULK,                                /* bmAttributes     */
        MAX_PACKET_SIZE_BULK, 0x00,            /* wMaxPacketSize   */
        0x00,                                        /* bInterval        */

        /* ENDPOINT descriptor */
        LEN_ENDPOINT,                        /* bLength          */
        DESC_ENDPOINT,                        /* bDescriptorType  */
        (EP_OUTPUT | BULK_OUT_EP_NUM),        /* bEndpointAddress */     //端点地址:2, Bulk out
        EP_BULK,                                /* bmAttributes     */
        MAX_PACKET_SIZE_BULK, 0x00,     /* wMaxPacketSize   */
        0x00,                                        /* bInterval        */

        //--------------------------------------------------------------------------
          // IAD
    0x08,        //描述符大小
    0x0B,        //IAD描述符类型
    0x02,        // bFirstInterface
    0x01,        // bInterfaceCount
    0x08,        // bFunctionClass: MASS STORAGE Class
    0x06,        // bFunctionSubClass
    0x50,        // bFunctionProtocol
    0x01,        // iFunction         

/* const BYTE cbyInterfaceDescriptor[LEN_INTERFACE] = */
        LEN_INTERFACE,        /* bLength */
        DESC_INTERFACE,        /* bDescriptorType */
        0x02,                        /* bInterfaceNumber */
        0x00,                        /* bAlternateSetting */
        0x02,                        /* bNumEndpoints */
        0x08,                        /* bInterfaceClass */
        0x05,                        /* bInterfaceSubClass */
        0x50,                        /* bInterfaceProtocol */
        0x00,                        /* iInterface */

/* const BYTE cbyEndpointDescriptor1[LEN_ENDPOINT] = */
        LEN_ENDPOINT,                /* bLength */
        DESC_ENDPOINT,                /* bDescriptorType */
        0x82,                                /* bEndpointAddress */
        EP_BULK,                        /* bmAttributes */
        MAX_PACKET_SIZE_BULK, 0x00,        /* wMaxPacketSize */
        0x00,                                /* bInterval */

/* const BYTE cbyEndpointDescriptor2[LEN_ENDPOINT] = */
        LEN_ENDPOINT,                /* bLength */
        DESC_ENDPOINT,                /* bDescriptorType */
        0x03,                                /* bEndpointAddress */
        EP_BULK,                        /* bmAttributes */
        MAX_PACKET_SIZE_BULK, 0x00,        /* wMaxPacketSize */
        0x00,                                /* bInterval */
};
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

15

帖子

0

粉丝