USB设备类型定义
USB设备类型定义
2021-05-08
本文链接为:http://www.usbzh.com/article/detail-221.html ,欢迎转载,转载请附上本文链接。
依附在总线上的设备可以是需要特定的驱动程序的完全定制的设备,也可能属于某个设备类别。这些类别定义设备的行为和接口描述符,这样一个驱动程序可能用于所有此种类别的设备。一般操作系统都为支持这些设备类别,为其提供通用驱动程序。
设备分类由USB设计论坛设备工作组决定,并分配ID。
一些已定义的类代码只允许在设备描述符中使用,其他类代码可以在设备和接口描述符中使用,而另外一些类代码只能在接口描述符中使用。
在一个设备上有两个地方可以显示类代码信息放置。
一个位置在设备描述符中.另一个在接口描述符中。
USB设备类型信息包含在三个字节中,分别是基类、子类和协议。如果一个设备类型属于整个设备,该设备的描述符的bDeviceClass域保存类别ID;如果它这是设备的一个接口,其ID保存在接口描述符的bInterfaceClass域。他们都占用一个字节,所以最多有253种设备类别。(0x00和0xFF保留)。当bDeviceClass设为0x00,操作系统会检查每个接口的bInterfaceClass以确定其类别。
在设备描述符中使用bDeviceClass,bDeviceSubClass,bDeviceProtocol字段来标识。在接口描述符中使用 bInterfaceClass, bInterfaceSubClass,bInterfaceProtocol字段来标识。
每种类别可选支持子类别(SubClass)和协议子定义(Protocol subdefinition)。这样可以用于主设备类型的不断修订。使用这定义USB定义了类代码信息,可以识别设备的功能并基于该功能加载设备驱动程序。
下表显示了当前定义的基类值集、泛型用法以及基类的使用位置(设备或接口描述符或两者)。
Base Class
Descriptor Usage
Description
00h
Device
Use class information in the Interface Descriptors
01h
Interface
Audio USB音频,参见UAC规范
02h
Both
Communications and CDC Control 网卡、调制解调器、串列端口
03h
Interface
HID (Human Interface Device),键盘、鼠标 参见HID规范
05h
Interface
Physical 控制杆
06h
Interface
Image 影像扫描仪、Picture Transfer Protocol
07h
Interface
Printer 打印机
08h
Interface
Mass Storage U盘、移动硬盘、存储卡读卡器、数字相机
09h
Device
Hub 集线器
0Ah
Interface
CDC-Data 调制解调器、网络卡、ISDN、传真
0Bh
Interface
Smart Card 读卡器
0Dh
Interface
Content Security
0Eh
Interface
Video USB视频,UVC摄像头,参见UVC规范
0Fh
Interface
Personal Healthcare
10h
Interface
Audio/Video Devices
11h
Device
Billboard Device Class
12h
Interface
USB Type-C Bridge Class
DCh
Both
Diagnostic Device
E0h
Interface
Wireless Controller 蓝牙
EFh
Both
Miscellaneous
FEh
Interface
Application Specific 红外线资料桥接器
FFh
Both
Vendor Specific 自定义USB设备
关于USB类定义,更加详尽的描述见:https://www.usb.org/defined-class-codes
//
// With the exception of the HUB device class, USB class codes are not
// defined in the core USB 1.1, 2.0, 3.0 specifications.
//
#define USB_DEVICE_CLASS_RESERVED 0x00
#define USB_DEVICE_CLASS_AUDIO 0x01
#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
#define USB_DEVICE_CLASS_MONITOR 0x04
#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
#define USB_DEVICE_CLASS_POWER 0x06
#define USB_DEVICE_CLASS_IMAGE 0x06
#define USB_DEVICE_CLASS_PRINTER 0x07
#define USB_DEVICE_CLASS_STORAGE 0x08
#define USB_DEVICE_CLASS_HUB 0x09
#define USB_DEVICE_CLASS_CDC_DATA 0x0A
#define USB_DEVICE_CLASS_SMART_CARD 0x0B
#define USB_DEVICE_CLASS_CONTENT_SECURITY 0x0D
#define USB_DEVICE_CLASS_VIDEO 0x0E
#define USB_DEVICE_CLASS_PERSONAL_HEALTHCARE 0x0F
#define USB_DEVICE_CLASS_AUDIO_VIDEO 0x10
#define USB_DEVICE_CLASS_BILLBOARD 0x11
#define USB_DEVICE_CLASS_DIAGNOSTIC_DEVICE 0xDC
#define USB_DEVICE_CLASS_WIRELESS_CONTROLLER 0xE0
#define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF
#define USB_DEVICE_CLASS_APPLICATION_SPECIFIC 0xFE
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
本文链接为:http://www.usbzh.com/article/detail-221.html ,欢迎转载,转载请附上本文链接。
¥打赏
随手分享,手有余香
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936 USB技术交流3:1031974172
