将双串口改成单串口主要就修改USB配置参数,配置参数改完就识别成一个串口设备了:
- char code DEVICEDESC[18] =
- {
- 0x12, //bLength(18);
- 0x01, //bDescriptorType(Device);
- 0x00,0x02, //bcdUSB(2.00);
- 0x02, //bDeviceClass(2:Communication Device Class);
- 0x00, //bDeviceSubClass0);
- 0x00, //bDeviceProtocol(0);
- 0x40, //bMaxPacketSize0(64);
- 0xbf,0x34, //idVendor(34bf);
- 0x02,0xff, //idProduct(ff02);
- 0x00,0x01, //bcdDevice(1.00);
- 0x01, //iManufacturer(1);
- 0x02, //iProduct(2);
- 0x00, //iSerialNumber(0);
- 0x01, //bNumConfigurations(1);
- };
-
- char code CONFIGDESC[67] =
- {
- 0x09, //bLength(9);
- 0x02, //bDescriptorType(Configuration);
- 0x43,0x00, //wTotalLength(67);
- 0x02, //bNumInterfaces(2);
- 0x01, //bConfigurationValue(1);
- 0x00, //iConfiguration(0);
- 0x80, //bmAttributes(BUSPower);
- 0x32, //MaxPower(100mA);
-
- 0x09, //bLength(9);
- 0x04, //bDescriptorType(Interface);
- 0x00, //bInterfaceNumber(0);
- 0x00, //bAlternateSetting(0);
- 0x01, //bNumEndpoints(1);
- 0x02, //bInterfaceClass(Communication Interface Class);
- 0x02, //bInterfaceSubClass(Abstract Control Model);
- 0x01, //bInterfaceProtocol(Common AT commands);
- 0x00, //iInterface(0);
-
- 0x05, //bLength(5);
- 0x24, //bDescriptorType(CS_INTERFACE);
- 0x00, //bDescriptorSubtype(Header Functional Descriptor);
- 0x10,0x01, //bcdCDC(1.10);
-
- 0x05, //bLength(5);
- 0x24, //bDescriptorType(CS_INTERFACE);
- 0x01, //bDescriptorSubtype(Call Management Functional Descriptor);
- 0x00, //bmCapabilities(Device does not handles call management itself);
- 0x01, //bDataInterface(1);
-
- 0x04, //bLength(4);
- 0x24, //bDescriptorType(CS_INTERFACE);
- 0x02, //bDescriptorSubtype(Abstract Control Management Functional Descriptor);
- 0x02, //bmCapabilities(Set/Get_Line_Coding,Serial_State,Set_Control_Line_State);
-
- 0x05, //bLength(5);
- 0x24, //bDescriptorType(CS_INTERFACE);
- 0x06, //bDescriptorSubtype(Union Functional descriptor);
- 0x00, //bMasterInterface(0);
- 0x01, //bSlaveInterface0(1);
-
- 0x07, //bLength(7);
- 0x05, //bDescriptorType(Endpoint);
- 0x82, //bEndpointAddress(EndPoint2 as IN);
- 0x03, //bmAttributes(Interrupt);
- 0x40,0x00, //wMaxPacketSize(64);
- 0xff, //bInterval(255ms);
-
- 0x09, //bLength(9);
- 0x04, //bDescriptorType(Interface);
- 0x01, //bInterfaceNumber(1);
- 0x00, //bAlternateSetting(0);
- 0x02, //bNumEndpoints(2);
- 0x0a, //bInterfaceClass(Data Interface Class);
- 0x00, //bInterfaceSubClass(AData Interface Class SubClass Codes);
- 0x00, //bInterfaceProtocol(USB SPEC);
- 0x00, //iInterface(0);
-
- 0x07, //bLength(7);
- 0x05, //bDescriptorType(Endpoint);
- 0x84, //bEndpointAddress(EndPoint4 as IN);
- 0x02, //bmAttributes(Bulk);
- 0x40,0x00, //wMaxPacketSize(64);
- 0x00, //bInterval(Ignored);
-
- 0x07, //bLength(7);
- 0x05, //bDescriptorType(Endpoint);
- 0x04, //bEndpointAddress(EndPoint4 as OUT);
- 0x02, //bmAttributes(Bulk);
- 0x40,0x00, //wMaxPacketSize(64);
- 0x00, //bInterval(Ignored);
- };
复制代码
附件使用一箭双雕USB转双串口A0例程修改USB配置,主函数里将自检部分删除避免使用不同板子测试自检通不过导致不识别。最小改动实现楼主需求。
|