STM32 USB 复合设备开发的技巧
来源:互联网 发布:数据展现工具 编辑:程序博客网 时间:2024/06/11 23:43
利用 IDA 描述符 将两个USB设备 做成复合设备
usb_desc.c 文件
/* USB Standard Device Descriptor */const uint8_t Composite_DeviceDescriptor[Composite_SIZ_DEVICE_DESC] = {0x12, //bLengthUSB_DEVICE_DESCRIPTOR_TYPE, //bDescriptorType0x00, //bcdUSB 0x02,0x00, //bDeviceClass0x00, //bDeviceSubClass0x00, //bDeviceProtocol0x40, //bMaxPacketSize400x83, //idVendor (0x0483)0x04,0x40, //idProduct = 0x57500x57,0x00, //bcdDevice rel. 2.000x02,1, //Index of string descriptor describing manufacturer 2, //Index of string descriptor describing product 3, //Index of string descriptor describing the device serial number 0x01 //bNumConfigurations}; const uint8_t Composite_ConfigDescriptor[Composite_SIZ_CONFIG_DESC] = {0x09, /* bLength: Configuration Descriptor size */USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */Composite_SIZ_CONFIG_DESC,0x00,0x03, /* bNumInterfaces: 2 interfaces, 1 for keyboard, 2 for virtual COM port */0x01, /* bConfigurationValue: Configuration value */0x00, /* iConfiguration: Index of string descriptor describing the configuration*/ 0xC0, /* bmAttributes: Self powered */0x32, /* MaxPower 100 mA: this current is used for detecting Vbus *//*********************************IAD Descriptor*********************************/0x08,//描述符大小0x0B, //IAD描述符类型0x00,//bFirstInterface0x01,//bInferfaceCount0x03,//bFunctionClass:HID0x00,//bFunctionSubClass0x00,//bFunctionProtocol/*16*/0x05,//iFunction/************** Descriptor of Keyboard HID interface ****************//* 09 */0x09, /* bLength: Interface Descriptor size */USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */0x00, /* bInterfaceNumber: Number of Interface */0x00, /* bAlternateSetting: Alternate setting */0x02, /* bNumEndpoints */0x03, /* bInterfaceClass: HID */0x01, /* bInterfaceSubClass : 1=BOOT, 0=no boot */0x01, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */0, /* iInterface: Index of string descriptor *//******************** Descriptor of Keyboard HID HID ********************//* 18 */0x09, /* bLength: HID Descriptor size */HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */0x00, /* bcdHID: HID Class Spec release number */0x01,0x00, /* bCountryCode: Hardware target country */0x01, /* bNumDescriptors: Number of HID class descriptors to follow */0x22, /* bDescriptorType */KEYBOARD_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */0x00,/******************** Descriptor of Keyboard HID endpoints ******************//* 27 */0x07, /* bLength: Endpoint Descriptor size */USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */0x81, /* bEndpointAddress: Endpoint Address (IN) */0x03, /* bmAttributes: Interrupt endpoint */0x08, /* wMaxPacketSize: 8 Bytes max */0x00,0x20, /* bInterval: Polling Interval (32 ms) *//* 34 */0x07,/* bLength: Endpoint Descriptor size */USB_ENDPOINT_DESCRIPTOR_TYPE,/* bDescriptorType: *//*Endpoint descriptor type */0x01,/* bEndpointAddress: *//*Endpoint Address (OUT) */0x03,/* bmAttributes: Interrupt endpoint */0x08,/* wMaxPacketSize: 8 Bytes max */0x00,0x20,/* bInterval: Polling Interval (20 ms) *//* 41 *//*********************************IAD Descriptor*********************************/0x08,/*描述符大小*/0x0B,/*IAD描述符类型*/0x01,/*bFirstInterface*/0x02,/*bInterfaceCOunt*/0x02,/*bFunctionClass:CDC Class*/0x02,/*bFunctionSubClass*/0x01,/*bFunctionProtocol*//*56*/0x04,/*iFunction*//******************** Descriptor of virtual COM interface ********************//* 41 */0x09, /* bLength: Interface Descriptor size */USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: *//* Interface descriptor type */0x01, /* bInterfaceNumber: Number of Interface */0x00, /* bAlternateSetting: Alternate setting */0x01, /* bNumEndpoints*/0x02, /* bInterfaceClass: Communication Interface Class */0x02, /* bInterfaceSubClass : Abstract Control Model*/0x01, /* nInterfaceProtocol : Common AT commands*/0x00, /* iInterface: Index of string descripto*//*Header Functional Descriptor*//* 50 */0x05, /* bLength: Endpoint Descriptor size */0x24, /* bDescriptorType: CS_INTERFACE */0x00, /* bDescriptorSubtype: Header Func Desc */0x10, /* bcdCDC: spec release number */0x01,/*Call Management Functional Descriptor*//* 55 */0x05, /* bFunctionLength */0x24, /* bDescriptorType: CS_INTERFACE */0x01, /* bDescriptorSubtype: Call Management Func Desc */0x00, /* bmCapabilities: D0+D1 */0x02, /* bDataInterface: 2 *//*ACM Functional Descriptor*//* 60 */0x04, /* bFunctionLength */0x24, /* bDescriptorType: CS_INTERFACE */0x02, /* bDescriptorSubtype: Abstract Control Management desc */0x02, /* bmCapabilities *//*Union Functional Descriptor*//* 64 */0x05, /* bFunctionLength */0x24, /* bDescriptorType: CS_INTERFACE */0x06, /* bDescriptorSubtype: Union func desc */0x01, /* bMasterInterface: Communication class interface */0x02, /* bSlaveInterface0: Data Class Interface *//*Endpoint 2 Descriptor*//* 69 */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*//* 76 */0x09, /* bLength: Endpoint Descriptor size */USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */0x02, /* 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*//* 85 */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 4 Descriptor*//* 92 */0x07, /* bLength: Endpoint Descriptor size */USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */0x84, /* bEndpointAddress: (IN4) */0x02, /* bmAttributes: Bulk */VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */0x00,0x00 /* bInterval *//* 99 */}; /* Composite_ConfigDescriptor *//* 66 */const uint8_t KeyBoard_ReportDescriptor[KEYBOARD_SIZ_REPORT_DESC] = {0x05, 0x01, // USAGE_PAGE (Generic Desktop)0x09, 0x06, // USAGE (Keyboard)0xa1, 0x01, // COLLECTION (Application)0x05, 0x07, // USAGE_PAGE (Keyboard)0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)0x15, 0x00, // LOGICAL_MINIMUM (0)0x25, 0x01, // LOGICAL_MAXIMUM (1)0x75, 0x01, // REPORT_SIZE (1)0x95, 0x08, // REPORT_COUNT (8)0x81, 0x02, // INPUT (Data,Var,Abs)0x95, 0x01, // REPORT_COUNT (1)0x75, 0x08, // REPORT_SIZE (8)0x81, 0x03, // INPUT (Cnst,Var,Abs)0x95, 0x05, // REPORT_COUNT (5)0x75, 0x01, // REPORT_SIZE (1)0x05, 0x08, // USAGE_PAGE (LEDs)0x19, 0x01, // USAGE_MINIMUM (Num Lock)0x29, 0x05, // USAGE_MAXIMUM (Kana)0x91, 0x02, // OUTPUT (Data,Var,Abs)0x95, 0x01, // REPORT_COUNT (1)0x75, 0x03, // REPORT_SIZE (3)0x91, 0x03, // OUTPUT (Cnst,Var,Abs)0x95, 0x06, // REPORT_COUNT (6)0x75, 0x08, // REPORT_SIZE (8)0x15, 0x00, // LOGICAL_MINIMUM (0)0x25, 0xFF, // LOGICAL_MAXIMUM (255)0x05, 0x07, // USAGE_PAGE (Keyboard)0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)0x81, 0x00, // INPUT (Data,Ary,Abs)0xc0 // END_COLLECTION}; /* KeyBoard_ReportDescriptor *//* USB String Descriptors (optional) */const uint8_t Composite_StringLangID[Composite_SIZ_STRING_LANGID] = {Composite_SIZ_STRING_LANGID,USB_STRING_DESCRIPTOR_TYPE,0x09,0x04}; /* LangID = 0x0409: U.S. English */const uint8_t Composite_StringVendor[Composite_SIZ_STRING_VENDOR] = {Composite_SIZ_STRING_VENDOR, /* Size of Vendor string */USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType*//* Manufacturer: "STMicroelectronics" */'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,'c', 0, 's', 0};const uint8_t Composite_StringProduct[Composite_SIZ_STRING_PRODUCT] = {Composite_SIZ_STRING_PRODUCT, /* bLength */USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'C', 0,'o', 0, 'm', 0, 'p', 0, 'o', 0, 's', 0, 'i', 0, 't', 0,'e', 0, ' ', 0, 'M', 0, 'S', 0, 'C', 0, '+', 0, 'H', 0, 'I', 0, 'D', 0};uint8_t Composite_StringSerial[Composite_SIZ_STRING_SERIAL] = {Composite_SIZ_STRING_SERIAL, /* bLength */USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0};/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
QQ 727341554 TEL 13810175694
0 0
- STM32 USB 复合设备开发的技巧
- USB设备开发之STM32
- USB复合设备
- STM32F207 USB复合设备
- 枚举 USB 复合设备
- 基于STM32的USB程序开发笔记(四)——USB设备的枚举(上)
- USB复合设备与组合设备的区别
- STM32 自定义HID USB设备的实现
- 初学 stm32 的USB 开发
- 基于STM32的USB开发
- USB复合设备(mass storage&hid)
- USB复合设备(mass storage&hid)
- GD32 USB 复合设备文件描述符
- USB复合设备(mass storage&hid)
- USB开发基础:USB设备的开发流程
- USB Compound Device,USB复合设备 ; USB Composite Device,USB组合设备
- USB 大容量存储设备的开发
- “复合设备(Compound Device)”可以占用多个地址。所谓复合设备其实就是把多个功能设备 通过内置的USB HUB 组合而成的设备,比如带录音话筒的USB 摄像头
- 原码反码补码
- 银行软件测试面试问题
- CountDownTimer倒计时器,获取验证码,的使用
- 编译Android内核
- 面试感悟:3年工作经验程序员应有的技能
- STM32 USB 复合设备开发的技巧
- JVM运行时数据区域解析
- 进程与线程的区别
- JDK、tomcat环境变量的配置
- Android中Dialog(对话框)的用法
- Java:Annotation(注解)--原理到案例
- list ,set,map的特点与区别
- Struts2使用jquery ajax返回json数据
- 为什么企业宁愿开高工资给新员工,都不愿意给老员工加工资?