USB HID重要知识点

1 报告描述符

1.1 自定义一个输入和输出64字节数据的报告描述符(无Report ID)

读写数据格式:1字节ReportID + payload

STM32高级教程之USB HID双向数据传输

http://www.embed-net.com/thread-5-1-1.html

-STM32这个例子有bushound抓图。注意,第一个字节0x00为ReportID,后面的为64字节payload。

1.2 例子1

当前例子数据长度是64字节,没有ReportID,所以ReportID取0,数据格式是:0x00 + 64 bytes payload(负载如果不足64字节,一定要补齐64字节,否则Windows ReadFile()和WriteFile()会失败。)

static const unsigned char report_descriptor[] = {

0x06, 0xA0, 0xFF, //用法页(FFA0h, vendor defined)

0x09, 0x01, //用法(vendor defined)

0xA1, 0x01, //集合(Application)

0x09, 0x02, //用法(vendor defined)

0xA1, 0x00, //集合(Physical)

0x06, 0xA1, 0xFF, //用法页(vendor defined)

//输入报告

0x09, 0x03, //用法(vendor defined)

0x09, 0x04, //用法(vendor defined)

0x15, 0x80, //逻辑最小值(0x80 or -128)

0x25, 0x7F, //逻辑最大值(0x7F or 127)

0x35, 0x00, //物理最小值(0)

0x45, 0xFF, //物理最大值(255)

0x75, 0x08, //报告长度Report size (每个字段8位)

0x95, 0x40, //报告数值(64 字节)

0x81, 0x02, //输入(data, variable, absolute)

//输出报告

0x09, 0x05, //用法(vendor defined)

0x09, 0x06, //用法(vendor defined)

0x15, 0x80, //逻辑最小值(0x80 or -128)

0x25, 0x7F, //逻辑最大值(0x7F or 127)

0x35, 0x00, //物理最小值(0)

0x45, 0xFF, //物理最大值(255)

0x75, 0x08, //报告长度(每个字段8位)

0x95, 0x40, //报告数值(64 字节)

0x91, 0x02, //输出(data, variable, absolute)

0xC0, //集合结束(Physical)

0xC0 //集合结束(Application)

};

1.3 例子2

static const unsigned char CustomHID_ReportDescriptor[] =

{

0x05, 0x8c, /* USAGE_PAGE (ST Page) */

0x09, 0x01, /* USAGE (Demo Kit) */

0xa1, 0x01, /* COLLECTION (Application) */

// The Input report

0x09,0x03, // USAGE ID - Vendor defined

0x15,0x00, // LOGICAL_MINIMUM (0)

0x26,0x00, 0xFF, // LOGICAL_MAXIMUM (255)

0x75,0x08, // REPORT_SIZE (8bit)

0x95,0x40, // REPORT_COUNT (64Byte)

0x81,0x02, // INPUT (Data,Var,Abs)

// The Output report

0x09,0x04, // USAGE ID - Vendor defined

0x15,0x00, // LOGICAL_MINIMUM (0)

0x26,0x00,0xFF, // LOGICAL_MAXIMUM (255)

0x75,0x08, // REPORT_SIZE (8bit)

0x95,0x40, // REPORT_COUNT (64Byte)

0x91,0x02, // OUTPUT (Data,Var,Abs)

0xc0 /* END_COLLECTION */

}; /* CustomHID_ReportDescriptor */

2 Linux HID调试

/sys/kernel/debug/hid

usbhid-dump

3 PS/2和USB双协议键鼠控制器

3.1 Cypress

CY7C63722C

CY7C63723C

CY7C63743C

3.2 Holtek

HT82K95A

HT82K95E

4 Legacy USB

键盘的工业标准是8042,访问8042的编程标准则是两个IO端口,60H和64H。Legacy USB就是模拟8042控制器的2个IO口。

An 8051-based ITE IT8586E EC built into a Lenovo Ideapad 310-15IKB laptop. The EC (Embedded Controller) evolved from the original Intel 8042 keyboard controller.

5 Cypress WirelessUSB

2.4 GHz无线键鼠使用的芯片,譬如CYRF9935。

6 USBKey

1)client发送报文给server,请求登录验证

2)challenge:server发随机数给client

3)response:client使用server发送的随机数和本地保存的密匙计算MD5,并发送给server

4)与此同时,server也用这个随机数和客户保存在服务器端的密匙进行MD5计算,与从client发送过来的MD5值比较,一致就允许登录

7 Abbreviations

ARC:Argonant RISC Core

AT91SAM9260:SAM means Smart ARM-based Microcontroller

BFM模式:Betop Full Match,北通安卓全匹配模式

DWC2:Design Ware Controller 2,Apple的嵌入式设备,包括iPad和iPhone都是使用的DWC2

ISP1161:Philips' Integrated host Solution Pairs 1161,"Firms introduce USB host controllers",https://www.eetimes.com/document.asp?doc_id=1290054

Quirks:the attributes of a device that are considered to be noncompliant with expected operation

SL811HS:Cypress/ScanLogic 811 Host/Slave,性能上与ISP1161(Integrated host Solution Pairs 1161)相当

TDI:TransDimension Inc.,该公司首先发明了将TT集成到EHCI RootHub中的方法,这样对于嵌入式系统来说,就省去了OHCI/UHCI的硬件,同时降低了成本,作为对该公司的纪念,Linux内核定义了宏ehci_is_TDI(ehci);产品UHC124表示USB Host Controller;收购了ARC USB技术;现已被chipidea收购,chipidea又被mips收购

TT:Transaction Translator(事务转换器,将USB2.0的包转换成USB1.1的包)