自己想做个基于2148的USB口与PC通讯的固件驱动,是在KEIL带的HID例子的基础上改,在改动usbdesc.c这个文件的时候,我把KEIL带的虚拟串口例子的描述搬上去,下载到板子上后,系统可以找到一个USB兼容设备,并且找到了两个虚拟的串口,但是我把他改成了只有一个接口的描述后,系统就找不到USB兼容设备了,只是找到了一个未知设备,但是里面的字符串描述符都没问题,哪位大侠可以指点一下 #include "type.h" #include "usb.h" #include "usbcfg.h" #include "usbdesc.h"
/* Two interface descriptor for 2 Virtual COM port,, each VCOM uses 3 endpoints */ /* The total number of endpoints are 6, 2 interrupt IN for modem status reading, 2 BULK OUT for COM TX, and 2 BULK IN for COM RX */ #define NUM_ENDPOINTS 2
/* USB Standard Device Descriptor */ const BYTE USB_DeviceDescriptor[] = { USB_DEVICE_DESC_SIZE, /* bLength */ USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0100), /* 1.00 */ /* bcdUSB */ 0x00, /* bDeviceClass */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ 64, /* bMaxPacketSize0 */ WBVAL(0xC251), /* idVendor */ WBVAL(0x1305), /* idProduct */ WBVAL(0x0110), /* 1.10 */ /* bcdDevice */ 0x04, /* iManufacturer */ 0x24, /* iProduct */ 0x4A, /* iSerialNumber */ 0x01 /* bNumConfigurations */ };
/* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */ const BYTE USB_ConfigDescriptor[] = { /* Configuration 1 */ USB_CONFIGUARTION_DESC_SIZE, /* bLength */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL( /* wTotalLength */ USB_CONFIGUARTION_DESC_SIZE + USB_INTERFACE_DESC_SIZE + NUM_ENDPOINTS * USB_ENDPOINT_DESC_SIZE ), 0x01, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ USB_CONFIG_BUS_POWERED | /* bmAttributes */ USB_CONFIG_REMOTE_WAKEUP, USB_CONFIG_POWER_MA(100), /* bMaxPower */ /* Interface 0, Alternate Setting 0, Class Code Unknown */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ NUM_ENDPOINTS, /* bNumEndpoints */ USB_DEVICE_CLASS_VENDOR_SPECIFIC, /* bInterfaceClass, USB_CLASS_VENDOR_SPECIFIC */ 0xFF, /* bInterfaceSubClass, USB_SUBCLASS_CODE_UNKNOWN */ 0xFF, /* bInterfaceProtocol, USB_PROTOCOL_CODE_UNKNOWN */ 0x00, /* iInterface, STR_INDEX_INTERFACE = no_string */ /* Endpoint, EP1 Interrupt In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(1), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0040), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* Endpoint, EP2 Bulk Out */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_OUT(1), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0040), /* wMaxPacketSize */ 0x20, /* 32ms */ /* Terminator */ 0 /* bLength */ }; |