使用 CH567 制作一个USB 键盘-Arduino中文社区 - Powered by Discuz! Archiver

Zoologist 发表于 2022-2-2 19:43

使用 CH567 制作一个USB 键盘

这一次使用 CH567 制作一个USB键盘,参考的对象是Dostyle的MK60 机械键盘。
同样的,使用 USBlyzer 抓取描述符信息:USB Composite Device
Connection StatusDevice connected
Current Configuration1
SpeedFull (12 Mbit/s)
Device Address8
Number Of Open Pipes2
Device Descriptor GamingKB
OffsetFieldSizeValueDescription
0bLength112h
1bDescriptorType101hDevice
2bcdUSB20110hUSB Spec 1.1
4bDeviceClass100hClass info in IfcDescriptors
5bDeviceSubClass100h
6bDeviceProtocol100h
7bMaxPacketSize0108h8 bytes
8idVendor2258Ah
10idProduct2002Ah
12bcdDevice21201h12.01
14iManufacturer101h"SINOWEALTH"
15iProduct102h"Gaming KB"
16iSerialNumber100h
17bNumConfigurations101h
Configuration Descriptor1 Bus Powered, 500 mA
OffsetFieldSizeValueDescription
0bLength109h
1bDescriptorType102hConfiguration
2wTotalLength2003Bh
4bNumInterfaces102h
5bConfigurationValue101h
6iConfiguration100h
7bmAttributes1A0hBus Powered, RemoteWakeup
4..0: Reserved...00000
5: Remote Wakeup..1..... Yes
6: Self Powered.0...... No, Bus Powered
7: Reserved (set toone)
(bus-powered for 1.0)1.......
8bMaxPower1FAh500 mA
Interface Descriptor 0/0 HID,1 Endpoint
OffsetFieldSizeValueDescription
0bLength109h
1bDescriptorType104hInterface
2bInterfaceNumber100h
3bAlternateSetting100h
4bNumEndpoints101h
5bInterfaceClass103hHID
6bInterfaceSubClass101hBoot Interface
7bInterfaceProtocol101hKeyboard
8iInterface100h
HID Descriptor
OffsetFieldSizeValueDescription
0bLength109h
1bDescriptorType121hHID
2bcdHID20111h1.11
4bCountryCode100h
5bNumDescriptors101h
6bDescriptorType122hReport
7wDescriptorLength20043h67 bytes
Endpoint Descriptor 81 1In, Interrupt, 1 ms
OffsetFieldSizeValueDescription
0bLength107h
1bDescriptorType105hEndpoint
2bEndpointAddress181h1 In
3bmAttributes103hInterrupt
1..0: Transfer Type......11 Interrupt
7..2: Reserved000000..
4wMaxPacketSize20008h8 bytes
6bInterval101h1 ms
Interface Descriptor 1/0 HID,1 Endpoint
OffsetFieldSizeValueDescription
0bLength109h
1bDescriptorType104hInterface
2bInterfaceNumber101h
3bAlternateSetting100h
4bNumEndpoints101h
5bInterfaceClass103hHID
6bInterfaceSubClass100h
7bInterfaceProtocol100h
8iInterface100h
HID Descriptor
OffsetFieldSizeValueDescription
0bLength109h
1bDescriptorType121hHID
2bcdHID20111h1.11
4bCountryCode100h
5bNumDescriptors101h
6bDescriptorType122hReport
7wDescriptorLength200CCh204 bytes
Endpoint Descriptor 82 2In, Interrupt, 1 ms
OffsetFieldSizeValueDescription
0bLength107h
1bDescriptorType105hEndpoint
2bEndpointAddress182h2 In
3bmAttributes103hInterrupt
1..0: Transfer Type......11 Interrupt
7..2: Reserved000000..
4wMaxPacketSize20010h16 bytes
6bInterval101h1 ms
Interface 0 HID ReportDescriptor Keyboard
Item Tag (Value)Raw Data
Usage Page (GenericDesktop)05 01
Usage (Keyboard)09 06
Collection(Application)A1 01
    UsagePage (Keyboard/Keypad)05 07
    UsageMinimum (Keyboard Left Control)19 E0
    UsageMaximum (Keyboard Right GUI)29 E7
    LogicalMinimum (0)15 00
    LogicalMaximum (1)25 01
    ReportCount (8)95 08
    ReportSize (1)75 01
    Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02
    ReportCount (1)95 01
    ReportSize (8)75 08
    Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 03
    ReportCount (6)95 06
    ReportSize (8)75 08
    LogicalMinimum (0)15 00
    LogicalMaximum (255)26 FF 00
    UsagePage (Keyboard/Keypad)05 07
    UsageMinimum (Undefined)19 00
    UsageMaximum2A FF 00
    Input (Data,Ary,Abs)81 00
    LogicalMaximum (1)25 01
    ReportCount (5)95 05
    ReportSize (1)75 01
    UsagePage (LEDs)05 08
    UsageMinimum (Num Lock)19 01
    UsageMaximum (Kana)29 05
    Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)91 02
    ReportCount (1)95 01
    ReportSize (3)75 03
    Output (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)91 03
End CollectionC0
Interface 1 HID ReportDescriptor System Control
Item Tag (Value)Raw Data
Usage Page (GenericDesktop)05 01
Usage (SystemControl)09 80
Collection (Application)A1 01
    ReportID (1)85 01
    UsageMinimum (System Power Down)19 81
    UsageMaximum (System Wake Up)29 83
    LogicalMinimum (0)15 00
    LogicalMaximum (1)25 01
    ReportSize (1)75 01
    ReportCount (3)95 03
    Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02
    ReportCount (5)95 05
    Input (Cnst,Ary,Abs)81 01
End CollectionC0
Usage Page (ConsumerDevices)05 0C
Usage (ConsumerControl)09 01
Collection(Application)A1 01
    ReportID (2)85 02
    UsageMinimum (Undefined)19 00
    UsageMaximum (AC Format)2A 3C 02
    LogicalMinimum (0)15 00
    LogicalMaximum (572)26 3C 02
    ReportCount (1)95 01
    ReportSize (16)75 10
    Input (Data,Ary,Abs)81 00
End CollectionC0
Usage Page(Vendor-Defined 1)06 00 FF
Usage (Vendor-Defined1)09 01
Collection(Application)A1 01
    ReportID (5)85 05
    LogicalMinimum (0)15 00
    LogicalMaximum (255)26 FF 00
    UsageMinimum (Vendor-Defined 1)19 01
    UsageMaximum (Vendor-Defined 2)29 02
    ReportSize (8)75 08
    ReportCount (5)95 05
    Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)B1 02
End CollectionC0
Usage Page (GenericDesktop)05 01
Usage (Keyboard)09 06
Collection(Application)A1 01
    ReportID (6)85 06
    LogicalMinimum (0)15 00
    LogicalMaximum (1)25 01
    ReportSize (1)75 01
    ReportCount (112)95 70
    UsagePage (Keyboard/Keypad)05 07
    UsageMinimum (Keyboard Left Control)19 E0
    UsageMaximum (Keyboard Right GUI)29 E7
    UsageMinimum (Undefined)19 00
    UsageMaximum (Keypad =)29 67
    Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02
    ReportCount (8)95 08
    Input (Cnst,Ary,Abs)81 01
End CollectionC0
Usage Page(Vendor-Defined 1)06 00 FF
Usage (Vendor-Defined1)09 01
Collection(Application)A1 01
    ReportID (9)85 09
    LogicalMinimum (0)15 00
    LogicalMaximum (255)26 FF 00
    Usage(Undefined)09 00
    ReportSize (8)75 08
    ReportCount (504)96 F8 01
    Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)B1 02
End CollectionC0
Usage Page(Vendor-Defined 1)06 00 FF
Usage (Vendor-Defined1)09 01
Collection(Application)A1 01
    ReportID (10)85 0A
    LogicalMinimum (0)15 00
    LogicalMaximum (255)26 FF 00
    Usage(Undefined)09 00
    ReportSize (8)75 08
    ReportCount (41)95 29
    Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)B1 02
End CollectionC0
Usage Page(Vendor-Defined 1)06 00 FF
Usage (Vendor-Defined1)09 01
Collection(Application)A1 01
    ReportID (11)85 0B
    LogicalMinimum (0)15 00
    LogicalMaximum (255)26 FF 00
    Usage(Undefined)09 00
    ReportSize (8)75 08
    ReportCount (126)95 7E
    Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)B1 02
End CollectionC0
Usage Page (Vendor-Defined1)06 00 FF
Usage (Vendor-Defined1)09 01
Collection(Application)A1 01
    ReportID (12)85 0C
    LogicalMinimum (0)15 00
    LogicalMaximum (255)26 FF 00
    Usage(Undefined)09 00
    ReportSize (8)75 08
    ReportCount (1920)96 80 07
    Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)B1 02
End CollectionC0
This report was generated by USBlyzer需要特别注意的是:这个设备是 USB Full Speed(12Mbits/s)的,必须在文件头部设置为 Full Speed,如果继续使用 Low Speed,插入之后读取描述符后 Host就会停止继续发送数据(Windows行为,我不知道原因)。除此之外,和之前的鼠标代码相比还增加了一个HID描述符,另外,在 Main 中定时发送打开Windows菜单(Win按键)。


页: [1]
查看完整版本: 使用 CH567 制作一个USB 键盘