找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6628|回复: 1
打印 上一主题 下一主题
收起左侧

经测试利用STM32实现的USB Dual RS485设备可直接使用在64位的win10预览版中,自动...

[复制链接]
跳转到指定楼层
楼主
ID:75926 发表于 2015-4-4 01:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式











设备驱动经过两次自动搜索和安装,廉价的STM32F1芯片实现了双路的USB转RS485通信硬件桥,驱动是微软自家的,
其中一路信号在大虾开发板上通信测试通过,大虾开发板带有CH341电路,这个芯片的驱动也是自动安装的。



作为一个符合微软标准的USB复合设备(USB composite device),本人设计的这款USB智能通讯产品,能被xpsp3, win7, win10所支持。
建议使用比较新的系统,在linux系统下,测试只能支持一个。

USB串行设备的配置描述常量数组如下所示,该描述不涉及代码部分,需要了解USB通讯协议。虽说是落后的USB1.1,可以满足常规
工作的需求。国内的专用芯片只有USB1.1全速的,USB2.0高速或USB3.0国内没有芯片可用,意法半导体的STM32F1或STM32L1可
替代国内专用芯片的大部分功能,关键是还能实现智能通讯,专用芯片不能编程,功能太单一。
  
const uint8_t Virtual_Com_Port_ConfigDescriptor[] =
{
/*Configuation Descriptor*/
0x09,   /* bLength: Configuation Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE,      /* bDescriptorType: Configuration */
VIRTUAL_COM_PORT_SIZ_CONFIG_DESC,       /* wTotalLength:no of returned bytes */
0x00,
0x04,   /* bNumInterfaces: 4 interface */
0x01,   /* bConfigurationValue: Configuration value */
0x00,   /* iConfiguration: Index of string descriptor describing the configuration */
0xC0,   /* bmAttributes: self powered */
0x32,   /* MaxPower 100 mA */

/*IAD Configuation Descriptor*/
0x08,  /* bLength: Interface Descriptor size */
0x0B,  /* bDescriptorType: IAD */
0x00,  /* bFirstInterface */
0x02,   /* bInterfaceCount */
0x02,  /* bFunctionClass: CDC */
0x02,   /* bFunctionSubClass */
0x01,   /* bFunctionProtocol */
0x02,   /* iFunction */
/*Interface Descriptor*/
0x09,   /* bLength: Interface Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: Interface */
/* Interface descriptor type */
0x00,   /* bInterfaceNumber: Number of Interface */
0x00,   /* bAlternateSetting: Alternate setting */
0x01,   /* bNumEndpoints: One endpoints used */
0x02,   /* bInterfaceClass: Communication Interface Class */
0x02,   /* bInterfaceSubClass: Abstract Control Model */
0x01,   /* bInterfaceProtocol: Common AT commands */
0x00,   /* iInterface: */
/*Header Functional Descriptor*/
0x05,   /* bLength: Endpoint Descriptor size */
0x24,   /* bDescriptorType: CS_INTERFACE */
0x00,   /* bDescriptorSubtype: Header Func Desc */
0x10,   /* bcdCDC: spec release number */
0x01,
/*Call Managment Functional Descriptor*/
0x05,   /* bFunctionLength */
0x24,   /* bDescriptorType: CS_INTERFACE */
0x01,   /* bDescriptorSubtype: Call Management Func Desc */
0x00,   /* bmCapabilities: D0+D1 */
0x01,   /* bDataInterface: 1 */
/*ACM Functional Descriptor*/
0x04,   /* bFunctionLength */
0x24,   /* bDescriptorType: CS_INTERFACE */
0x02,   /* bDescriptorSubtype: Abstract Control Management desc */
0x02,   /* bmCapabilities */
/*Union Functional Descriptor*/
0x05,   /* bFunctionLength */
0x24,   /* bDescriptorType: CS_INTERFACE */
0x06,   /* bDescriptorSubtype: Union func desc */
0x00,   /* bMasterInterface: Communication class interface */
0x01,   /* bSlaveInterface0: Data Class Interface */
/*Endpoint 2 Descriptor*/
0x07,   /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
0x82,   /* bEndpointAddress: (IN2) */
0x03,   /* bmAttributes: Interrupt */
VIRTUAL_COM_PORT_INT_SIZE,      /* wMaxPacketSize: */
0x00,
0xFF,   /* bInterval: */
/*Data class interface descriptor*/
0x09,   /* bLength: Endpoint Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: */
0x01,   /* bInterfaceNumber: Number of Interface */
0x00,   /* bAlternateSetting: Alternate setting */
0x02,   /* bNumEndpoints: Two endpoints used */
0x0A,   /* bInterfaceClass: CDC */
0x00,   /* bInterfaceSubClass: */
0x00,   /* bInterfaceProtocol: */
0x00,   /* iInterface: */
/*Endpoint 3 Descriptor*/
0x07,   /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
0x03,   /* bEndpointAddress: (OUT3) */
0x02,   /* bmAttributes: Bulk */
VIRTUAL_COM_PORT_DATA_SIZE,             /* wMaxPacketSize: */
0x00,
0x00,   /* bInterval: ignore for Bulk transfer */
/*Endpoint 1 Descriptor*/
0x07,   /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
0x81,   /* bEndpointAddress: (IN1) */
0x02,   /* bmAttributes: Bulk */
VIRTUAL_COM_PORT_DATA_SIZE,             /* wMaxPacketSize: */
0x00,
0x00,    /* bInterval */

/*IAD Configuation Descriptor*/
0x08,   /* bLength: Interface Descriptor size */
0x0B,   /* bDescriptorType: IAD */
0x02,   /* bFirstInterface */
0x02,   /* bInterfaceCount */
0x02,   /* bFunctionClass: CDC */
0x02,   /* bFunctionSubClass */
0x01,   /* bFunctionProtocol */
0x02,   /* iFunction */
/*Interface Descriptor*/
0x09,   /* bLength: Interface Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: Interface */
/* Interface descriptor type */
0x02,   /* bInterfaceNumber: Number of Interface */
0x00,   /* bAlternateSetting: Alternate setting */
0x01,   /* bNumEndpoints: One endpoints used */
0x02,   /* bInterfaceClass: Communication Interface Class */
0x02,   /* bInterfaceSubClass: Abstract Control Model */
0x01,   /* bInterfaceProtocol: Common AT commands */
0x00,   /* iInterface: */
/*Header Functional Descriptor*/
0x05,   /* bLength: Endpoint Descriptor size */
0x24,   /* bDescriptorType: CS_INTERFACE */
0x00,   /* bDescriptorSubtype: Header Func Desc */
0x10,   /* bcdCDC: spec release number */
0x01,
/*Call Managment Functional Descriptor*/
0x05,   /* bFunctionLength */
0x24,   /* bDescriptorType: CS_INTERFACE */
0x01,   /* bDescriptorSubtype: Call Management Func Desc */
0x00,   /* bmCapabilities: D0+D1 */
0x03,   /* !! bDataInterface: */
/*ACM Functional Descriptor*/
0x04,   /* bFunctionLength */
0x24,   /* bDescriptorType: CS_INTERFACE */
0x02,   /* bDescriptorSubtype: Abstract Control Management desc */
0x02,   /* bmCapabilities */
/*Union Functional Descriptor*/
0x05,   /* bFunctionLength */
0x24,   /* bDescriptorType: CS_INTERFACE */
0x06,   /* bDescriptorSubtype: Union func desc */
0x02,   /* !! bMasterInterface: Communication class interface */
0x03,   /* !! bSlaveInterface0: Data Class Interface */
/*Endpoint 2 Descriptor*/
0x07,   /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
0x85,   /* bEndpointAddress: (IN2) */
0x03,   /* bmAttributes: Interrupt */
VIRTUAL_COM_PORT_INT_SIZE,      /* wMaxPacketSize: */
0x00,
0xFF,   /* bInterval: */

/*Data class interface descriptor*/
0x09,   /* bLength: Endpoint Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: */
0x03,   /* bInterfaceNumber: Number of Interface */
0x00,   /* bAlternateSetting: Alternate setting */
0x02,   /* bNumEndpoints: Two endpoints used */
0x0A,   /* bInterfaceClass: CDC */
0x00,   /* bInterfaceSubClass: */
0x00,   /* bInterfaceProtocol: */
0x00,   /* iInterface: */
/*Endpoint 3 Descriptor*/
0x07,   /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
0x06,   /* bEndpointAddress: (OUT3) */
0x02,   /* bmAttributes: Bulk */
VIRTUAL_COM_PORT_DATA_SIZE,             /* wMaxPacketSize: */
0x00,
0x00,   /* bInterval: ignore for Bulk transfer */
/*Endpoint 1 Descriptor*/
0x07,   /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
0x84,   /* bEndpointAddress: (IN1) */
0x02,   /* bmAttributes: Bulk */
VIRTUAL_COM_PORT_DATA_SIZE,             /* wMaxPacketSize: */
0x00,
0x00    /* bInterval */
};





分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:76352 发表于 2015-4-7 18:05 | 只看该作者
有其他的資料嗎〉
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表