打印
[ZLG-ARM]

请教2148USB设备描述接口的写法!!!!

[复制链接]
1180|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
justcool|  楼主 | 2007-12-20 21:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
自己想做个基于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 */
};

相关帖子

沙发
computer00| | 2007-12-20 21:50 | 只看该作者

可能是因为端点数不一样,加载驱动程序失败吧。

使用特权

评论回复
板凳
justcool|  楼主 | 2007-12-20 21:57 | 只看该作者

谢谢

请问圈圈大侠,端点数的配置具体还有哪些地方需要改过来呢,能否详细说说,在此先谢过了

使用特权

评论回复
地板
computer00| | 2007-12-22 13:06 | 只看该作者

你这个不是标准的USB设备,需要自己提供驱动程序。

你不如改成HID设备算了,然后换个VID和PID。

使用特权

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

本版积分规则

7

主题

12

帖子

1

粉丝