📄 sn8_usb_descriptor_table.lib
字号:
;***********************************************************************
; USB Descriptor Table (K + M)
;=======================================================================
; This descriptor inclues
;---------------------------
;1. Device Descriptor
;2. Configuration Descriptor
;3. Interface Descriptor
;4. HID class Descriptor
;5. Endpoint Descriptor
;6. Report Descriptor (HID)
;7. String Descriptor
;***********************************************************************
DeviceDescr:
db 12h ; size of descriptor (18 bytes)
db 01h ; descriptor type (device descriptor)
db 10h ; USB SPEC release (ver 1.1) - Lowbyte
db 01h ; USB SPEC release (ver 1.1) - Highbyte
db 00h ; class code (each interface specifies class information)
db 00h ; device sub-class (must be set to 0 because class code is 0)
db 00h ; device protocol (no class specific protocol)
db 08h ; maximum packet size (8 bytes)
db 45h ; vendor ID - Lowbyte
db 0ch ; vendor ID - Highbyte
db 03h ; product ID - Lowbyte
db 73h ; product ID - Highbyte
db 01h ; device release number - Low byte
db 00h ; device release number - High byte
db 01h ; index of manufacturer string
db 02h ; index of product string
db 00h ; index of serial number string (0=none)
db 01h ; number of configurations
end_DeviceDescr:
DeviceDescr_length EQU (end_DeviceDescr - DeviceDescr)
DeviceDescr_length_H EQU 0
ConfigDescr:
db 09h ; length of descriptor
db 02h ; descriptor type (CONFIGURATION)
db config_all_descr_length ; total length of descriptor
db 00h
db 02h ; number of interfaces to configure
db 01h ; configuration value
db 00h ; configuration string index
db 0A0h ; configuration attributes
db 32h ; maximum power
end_ConfigDescr:
ConfigDescr_length EQU (end_ConfigDescr - ConfigDescr)
end_ConfigDescr_length_H EQU 0
InterfaceDescr: ; descriptor for interface 0
db 09h ; length of descriptor (9 bytes)
db 04h ; descriptor type (INTERFACE)
db 00h ; interface number
db 00h ; alternate setting
db 01h ; number of endpoints
db 03h ; interface class (3..defined by HID spec for HID)
db 01h ; interface sub-class (1..defined by HID spec for Boot subclass)
db 01h ; interface protocol (1..defined by HID spec for keyboard)
db 00h ; interface string index 00
end_InterfaceDescr:
InterfaceDescr_length EQU (end_InterfaceDescr - InterfaceDescr)
InterfaceDescr_length_H EQU 0
HID_Descr:
db 09h ; descriptor size (9 bytes)
db 21h ; descriptor type (HID)
db 00h ; class specification(1.00)
db 01h
db 00h ; hardware target country
db 01h ; number of hid class desriptors to follow
db 22h ; report descriptor type
db ReportDesc_length;ReportDesc total length
db ReportDesc_length_H
end_HID_Descr:
HID_Descr_length EQU (end_HID_Descr - HID_Descr)
HID_Descr_length_H EQU 0
Endpoint1_Descr:
db 07h ; descriptor length (7 bytes)
db 05h ; descriptor type (ENDPOINT)
db 81h ; endpoint address (IN endpoint, endpoint 1)
db 03h ; endpoint attributes (interrupt)
db 08h ; maximum packet size (8 bytes)
db 00h
db 01h ; polling interval (1ms)
end_Endpoint1_Descr:
Endpoint1_Descr_length EQU (end_Endpoint1_Descr - Endpoint1_Descr)
Endpoint1_Descr_length_H EQU 0
Interface2_Descr: ; descriptor for interface 1 (HID mouse)
db 09h ; length of descriptor (9 bytes)
db 04h ; descriptor type (INTERFACE)
db 01h ; interface number (0)
db 00h ; alternate setting (0)
db 01h ; number of endpoints (1)
db 03h ; interface class (3..defined by HID spec for HID)
db 01h ; interface sub-class (1..defined by HID spec for Boot subclass)
db 02h ; interface protocol (2..defined by HID spec for mouse)
db 00h ; interface string index 00
end_Interface2_Descr:
Interface2Descr_length EQU (end_Interface2_Descr - Interface2_Descr)
Interface2Descr_length_H EQU 0
HID2_Descr:
db 09h ; descriptor size (9 bytes)
db 21h ; descriptor type (HID)
db 00h ; class specification (1.00) - lowbyte
db 01h ; class specification (1.00) - Highbyte
db 00h ; hardware target country
db 01h ; number of hid class desriptors to follow (1)
db 22h ; report descriptor type (2)
db Report2Desc_length
db Report2Desc_length_H
end_HID2_Descr:
HID2_Descr_length EQU (end_HID2_Descr - HID2_Descr)
HID2_Descr_length_H EQU 0
Endpoint2_Descr:
db 07h ; descriptor length (7 bytes)
db 05h ; descriptor type (ENDPOINT)
db 82h ; endpoint address (IN endpoint, endpoint 2)
db 03h ; endpoint attributes (interrupt)
db 05h ; maximum packet size (5 bytes)
db 00h
db 01h ; polling interval (1ms)
end_Endpoint2_Descr:
Endpoint2_Descr_length EQU (end_Endpoint2_Descr - Endpoint2_Descr)
Endpoint2_Descr_length_H EQU 0
end_all_config_descr:
config_all_descr_length EQU ((end_all_config_descr - ConfigDescr) & 0xff)
config_all_descr_length_H EQU (((end_all_config_descr - ConfigDescr) >>8) & 0xff)
;**************************************************************************
;Note!! The report descriptor is for HID class request.
;**************************************************************************
ReportDesc:
db 05h, 01h ; usage page (generic desktop)
db 09h, 06h ; usage (keyboard)
db 0A1h,01h ; collection (application)
db 05h, 07h ; usage page( key codes)
db 19h, 0E0h ; usage minimum (234)
db 29h, 0E7h ; usage maximum (231)
db 15h, 00h ; logical minimum (0)
db 25h, 01h ; logical maximum (1)
db 75h, 01h ; report size (1 bit)
db 95h, 08h ; report count (8 bytes)
db 81h, 02h ; input (data, variable, absolute)
db 95h, 01h ; report count (1 byte)
db 75h, 08h ; report size (8 bits)
db 81h, 01h ; input (constant)
db 95h, 05h ; report count (5)
db 75h, 01h ; report size (1)
db 05h, 08h ; usage page (LEDs)
db 19h, 01h ; usage minimum (1)
db 29h, 05h ; usage maximum (5)
db 91h, 02h ; output (data, variable, absolute)
db 95h, 01h ; report count (1)
db 75h, 03h ; report size (3)
db 91h, 01h ; output (constant)
db 95h, 06h ; report count (6)
db 75h, 08h ; report size (8)
db 15h, 00h ; logical minimum (0)
db 25h, 68h ; logical maximum (101)
db 05h, 07h ; usage page (key codes)
db 19h, 00h ; usage minimum (0)
db 29h, 68h ; usage maximum (101)
db 81h, 00h ; input (data, array)
db 05h,0ch ;Usage Page(Consumer Page)
db 09h,00h ;Usage(unassigned)
db 15h,80h ;logical minimum(-128)
db 25h,7fh ;logical maxinum(+127)
db 75h,08h ;report size(8)
db 95h,08h ;report count(8)
db 0B1h,02h ;feature(data,var,abs)
db 0C0h ; end collection
end_ReportDesc:
ReportDesc_length EQU (((end_ReportDesc - ReportDesc) <<1) & 0xff) -1
ReportDesc_length_H EQU (((((end_ReportDesc - ReportDesc) <<1) -1) >>8) & 0xff)
Report2Desc:
db 05h, 01h ; usage page (generic desktop)
db 09h, 02h ; usage (mouse)
db 0A1h, 01h ; collection (application)
db 09h, 01h ; usage (pointer)
db 0A1h, 00h ; collection (linked)
db 05h, 09h ; usage page (buttons)
db 19h, 01h ; usage minimum (1)
db 29h, 05h ; usage maximum (3)
db 15h, 00h ; logical minimum (0)
db 25h, 01h ; logical maximum (1)
db 95h, 05h ; report count (5)
db 75h, 01h ; report size (1)
db 81h, 02h ; input (3 button bits)
db 95h, 01h ; report count (1)
db 75h, 03h ; report size (3)
db 81h, 01h ; input (constant 5 bit padding)
db 05h, 01h ; usage page (generic desktop)
db 09h, 30h ; usage (X)
db 09h, 31h ; usage (Y)
db 09h, 38h ; usage (wheel)
db 15h, 81h ; logical minimum (-127)
db 25h, 7Fh ; logical maximum (127)
db 75h, 08h ; report size (8)
db 95h, 03h ; report count (3)
db 81h, 06h ; input (3 position bytes X & Y & wheel)
db 0C0h,0C0h ; End Collection
end_Report2Desc:
Report2Desc_length EQU (((end_Report2Desc - Report2Desc) <<1) & 0xff)
Report2Desc_length_H EQU (((((end_Report2Desc - Report2Desc) <<1) -1) >>8) & 0xff)
; NOTE !!!!!!!!!!!!!!!!!!!!!!!
;*****************************************************************************************
; If the report descriptor end in low byte of ROM. Please modify the ReportDesc_length
; Example (1)
;
; db 0C0h ;end collection
; Report2Desc_length EQU (((end_Report2Desc - Report2Desc) <<1) & 0xff) -1
; Report2Desc_length_H EQU (((((end_Report2Desc - Report2Desc) <<1) -1) >>8) & 0xff)
;
; Example (2)
;
; db 00h, 0C0h ;end collection
; Report2Desc_length EQU (((end_Report2Desc - Report2Desc) <<1) & 0xff)
; Report2Desc_length_H EQU (((((end_Report2Desc - Report2Desc) <<1)) >>8) & 0xff)
;*****************************************************************************************
;*********************************************************
; String descriptor
;*********************************************************
ilanguageString: ; Language: English
; Sub-language: Default
dw 0x0304
dw 0x0409
end_ilanguageString:
ilanguageString_len EQU (end_ilanguageString - ilanguageString) <<1
ilanguageString_len_H EQU (((end_ilanguageString - ilanguageString) >>7) & 0xff)
imanufacturerString:
dw 0x030C
db "S"
db "O"
db "N"
db "i"
db "X"
end_imanufacturerString:
imanufacturerString_len EQU (end_imanufacturerString - imanufacturerString) <<1
imanufacturerString_len_H EQU (((end_imanufacturerString - imanufacturerString) >>7) & 0xff)
iproductString:
dw 0x0316
db "U"
db "S"
db "B"
db " "
db "D"
db "e"
db "v"
db "i"
db "c"
db "e"
end_iproductString:
iproductString_len EQU (end_iproductString - iproductString) <<1
iproductString_len_H EQU (((end_iproductString - iproductString) >>7) & 0xff)
iserialNumberString:
dw 0x0312
db "0"
db "0"
db "0"
db "0"
db "0"
db "0"
db "0"
db "0"
end_iserialNumberString:
iserialNumberString_len EQU (end_iserialNumberString - iserialNumberString) <<1
iserialNumberString_len_H EQU (((end_iserialNumberString - iserialNumberString) >> 7) & 0xff)
iconfigurationString:
dw 0x0328
db "H"
db "I"
db "D"
db "-"
db "C"
db "o"
db "m"
db "p"
db "l"
db "i"
db "a"
db "n"
db "t"
db "D "
db "e"
db "v"
db "i"
db "c"
db "e"
end_iconfigurationString:
iconfigurationString_len EQU (end_iconfigurationString - iconfigurationString) <<1
iconfigurationString_len_H EQU (((end_iconfigurationString - iconfigurationString) >>7) & 0xff)
;***********************************************************************
; END of Descriptor table
;***********************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -