各位大侠: 小弟在ZLG SMART D12开发板上使用CDC类开发USB转RS232,不需要写驱动(windows自带的usbser.sys),只需要提供一个INF文件,网上有很多的用AVR单片机做的例子,小弟想移植到51单片机上来,但是现在枚举不成功,获取配置描述符集合以后,就出现“由于向导无法找到需要的软件因此无法安装该硬件”的窗口,配置描述符如下(配置描述符也是仿照网上AVR单片机的):
//ÅäÖÃÃèÊö·û code USB_CONFIGURATION_DESCRIPTOR ConfigDescr = { 9, /* bLength */ 2, /* descriptor type */ SWAP( CONFIG_DESCRIPTOR_LENGTH ), /* length of packed config descr. (16b) */ 0x02, /* number of interfaces */ 0x01, /* configuration value */ 0x00, /* configuration string index (none) */ 0x80, /* attributes (self-powered, no remote wakeup) */ 0xff, /* max power (0x0A * 2mA = 20mA) */ // ͨÐÅ½Ó¿Ú /* Interface descriptor */ 9, /* bLength */ 4, /* descriptor type */ 0x00, /* interface number */ 0x00, /* alternate setting */ 0x01, /* number of endpoints (excl. EP0) */ 0x02, /* CDC class */ /* interface class (USBTMC=0xFE) */ 0x02, /* Abstract (Modem) */ /* interface subclass (USB488=0x03) */ 0x01, /* AT-Commands */ /* interface protocol (0x01)*/ 0x00, /* interface string index (none) */
/* CDC Class-Specific descriptor */ 5, /* sizeof(usbDescrCDC_HeaderFn): length of descriptor in bytes */ 0x24, /* descriptor type */ 0, /* header functional descriptor */ 0x10, 0x01,
4, /* sizeof(usbDescrCDC_AcmFn): length of descriptor in bytes */ 0x24, /* descriptor type */ 2, /* abstract control management functional descriptor */ 0x02, /* SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE */
5, /* sizeof(usbDescrCDC_UnionFn): length of descriptor in bytes */ 0x24, /* descriptor type */ 6, /* union functional descriptor */ 0, /* CDC_COMM_INTF_ID */ 1, /* CDC_DATA_INTF_ID */
5, /* sizeof(usbDescrCDC_CallMgtFn): length of descriptor in bytes */ 0x24, /* descriptor type */ 1, /* call management functional descriptor */ 0, /* allow management on data interface, handles call management by itself */ 1, /* CDC_DATA_INTF_ID */
7, /* bLength */ 5, /* descriptor type */ 0x81, /* Endpoint dir'n (IN) & addr */ 0x03, /* Endpoint type */ SWAP(EP1_PACKET_SIZE), 10, /* Polling interval (unit=frame=1mS) */
// Êý¾Ý½Ó¿Ú /* Interface Descriptor */ 9, /* sizeof(usbDescrInterface): length of descriptor in bytes */ 4, /* descriptor type */ 1, /* index of this interface */ 0, /* alternate setting for this interface */ 2, /* endpoints excl 0: number of endpoint descriptors to follow */ 0x0A, /* Data Interface Class Codes */ 0, 0, /* Data Interface Class Protocol Codes */ 0, /* string index for interface */
7, /* bLength */ 5, /* descriptor type */ 0x82, /* Endpoint dir'n (IN) & addr */ 0x02, /* Endpoint type */ SWAP(EP2_PACKET_SIZE), 10, /* Interval - usually ignored for bulk */ 7, /* bLength */ 5, /* descriptor type */ 0x02, /* Endpoint dir'n (OUT) & addr */ 0x02, /* Endpoint type */ SWAP(EP2_PACKET_SIZE), 10, /* Interval - usually ignored for bulk */ }; 经过调试发现,配置描述符集合是正确发送给主机的,但主机没有找到驱动usbser.sys,提供的INF文件如下:
; Windows USB CDC Setup File ; Copyright (c) 2000 Microsoft Corporation ; Copyright (c) 2007 ship_@163.com.
[Version] Signature="$Windows NT$" Class=Ports ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} Provider=%COMPANY% LayoutFile=layout.inf DriverVer=03/01/2007,1.0.0.0
[Manufacturer] %MFGNAME% = ManufName
[DestinationDirs] DefaultDestDir=12
[ManufName] %Modem3% = Modem3, USB\VID_0471&PID_0777
;------------------------------------------------------------------------------ ; Windows 2000/XP Sections ;------------------------------------------------------------------------------
[Modem3.nt] CopyFiles=USBModemCopyFileSection AddReg=Modem3.nt.AddReg
[USBModemCopyFileSection] usbser.sys,,,0x20
[Modem3.nt.AddReg] HKR,,DevLoader,,*ntkern HKR,,NTMPDriver,,usbser.sys HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
[Modem3.nt.Services] AddService=usbser, 0x00000002, DriverService
[DriverService] DisplayName=%SERVICE% ServiceType=1 StartType=3 ErrorControl=1 ServiceBinary=%12%\usbser.sys
;------------------------------------------------------------------------------ ; String Definitions ;------------------------------------------------------------------------------
[Strings] COMPANY="ship_@163.com" MFGNAME="mengrz" Modem3="DpView" SERVICE="USB-232 Emulation Driver"
现在不知道问题出在哪里,希望大侠赐教
|