|
楼主 |
发表于 2011-1-14 22:11:13
|
显示全部楼层
Descriptor是这样的:
;------------------------------------------------------------------------------------------
.equ USBversion =0x0100 ;for what version USB is that (1.00)
.equ VendorUSBID =0x0777 ;vendor identifier (Atmel=0x03EB)
.equ DeviceUSBID =0x0001 ;product identifier (USB Joystick)
.equ DeviceVersion =0x0001 ;version number of product (version=0.01)
;(0.01=First USB Joystick with internal ADC)
.equ MaxUSBCurrent =0xC8 ;current consumption from USB (50mA) - together with MAX232
;------------------------------------------------------------------------------------------
DeviceDescriptor:
.db 0x12,0x01 ;0 byte - size of descriptor in byte
;1 byte - descriptor type: Device descriptor
.dw USBversion ;2,3 byte - version USB LSB (1.00)
.db 0x00,0x00 ;4 byte - device class
;5 byte - subclass
.db 0x00,0x08 ;6 byte - protocol code
;7 byte - FIFO size in bytes
.dw VendorUSBID ;8,9 byte - vendor identifier
.dw DeviceUSBID ;10,11 byte - product identifier
.dw DeviceVersion ;12,13 byte - product version number
.db 0x01,0x02 ;14 byte - index of string "vendor"
;15 byte - index of string "product"
.db 0x00,0x01 ;16 byte - index of string "serial number" (0=none)
;17 byte - number of possible configurations
DeviceDescriptorEnd:
;------------------------------------------------------------------------------------------
ConfigDescriptor:
.db 0x9,0x02 ;length, descriptor type
ConfigDescriptorLength:
.dw 9+9+9+7 ;entire length of all descriptors + HID
ConfigAnswerMinus1: ;for sending the number - congiguration number (attention - addition of 1 required)
.db 1,1 ;numInterfaces, congiguration number
.db 2,0x80 ;string index (0=none), attributes; bus powered
;InterfaceDescriptor-1:
.db MaxUSBCurrent/2,0x09 ;current consumption, interface descriptor length
.db 0x04,0 ;interface descriptor; number of interface
InterfaceAnswer: ;for sending number of alternatively interface
.db 0,1 ;alternatively interface; number of endpoints except EP0
.db 0x03,0 ;interface class - HID; interface subclass
.db 0,3 ;protocol code; string index - Device name
HIDDescriptor:
.db 0x09,0x21 ; HID descriptor length , HID descriptor type (defined by USB)
.dw 0x101 ; HID Class Specification release number
.db 0,0x01 ;Hardware target country.; ;Number of HID class descriptors to follow.
.db 0x22,ReportDescriptorSize ;Report descriptor type.; length LSB
.db 0, 0x07 ;Total length of Report descriptor MSB, EndPointDescriptor length
;EndPointDescriptor:
.db 0x5, 0x81 ;, descriptor type - endpoint
.db 0x3, 0x08 ;endpoint address In 1; transfer type -interrupt;max packet size LSB
.db 0, 10 ;max packet size MSB,polling interval [ms];
ConfigDescriptorEnd:
;-------------------------
StatusAnswer:
.db 0,0 ;2 zero answers
;-----------------------------------
.equ ReportDescriptorSize =0x3d;61 (ReportDescriptorEnd-ReportDescriptor)*2-1;0x37;55
.equ JoystickReportSize =6
ReportDescriptor:
.db 0x05,0x01 ;Usage_Page (Generic Desktop)
.db 0x15,0x00 ;Logical_Minimum (0)
.db 0x09,0x04 ;Usage (Joystick)
.db 0xA1,0x01 ;Collection (Application)
.db 0x05,0x02 ;Usage_Page (Simulation Controls)
.db 0x09,0xC8 ;Usage (Steering) - OK
.db 0x16,0x00 ;Logical_Minimum (-1024)
.db 0xFC,0x26
.db 0xFF,0x03 ;Logical Maximum (1023)
.db 0x75,0x10 ;Report_Size (16)
.db 0x95,0x01 ;Report_Count (1)
.db 0x81,0x02 ;Input (Data, Var, Abs)
.db 0x09,0xC4 ;Usage (Accelerator) OK for 1 axle
.db 0x09,0xBB ;Usage (Throttle) - OK for 2 axle
.db 0x09,0xC5 ;Usage (Brake) - OK 2 axle
.db 0x15,0x81 ;Logical_Minimum (-128)
.db 0x25,0x7F ;Logical Maximum (127)
.db 0x75,0x08 ;Report_Size (8)
.db 0x95,0x03 ;Report_Count (3)
.db 0x81,0x02 ;Input (Data, Var, Abs)
.db 0x05,0x09 ;Usage_Page (Button)
.db 0x19,0x01 ;Usage_Minimum (Button 1)
.db 0x29,0x08 ;Usage_Maximum (Button 24)
.db 0x15,0x00 ;Logical_Minimum (0)
.db 0x25,0x01 ;Logical_Maximum (1)
.db 0x35,0x00 ;Physical_Minimum(0)
.db 0x45,0x01 ;Physical_Maximum(1)
.db 0x75,0x01 ;Report_Size (1)
.db 0x95,0x08 ;Report_Count (8)
.db 0x81,0x02 ;Input (Data, Var, Abs)
.db 0xC0,0 ;End_Collection , dummy padding
ReportDescriptorEnd:
;------------------------------------------------------------------------------------------
LangIDStringDescriptor:
.db (LangIDStringDescriptorEnd-LangIDStringDescriptor)*2,3 ;length, type: string descriptor
;.dw 0x0409 ;English
.dw 0x0009 ;English
LangIDStringDescriptorEnd:
;------------------------------------------------------------------------------------------
VendorStringDescriptor:
.db (VendorStringDescriptorEnd-VendorStringDescriptor)*4-2,3 ;length, type: string descriptor
CopyRight:
.db "hbk0401,Copyright(c)_2010"
CopyRightEnd:
VendorStringDescriptorEnd:
;------------------------------------------------------------------------------------------
DevNameStringDescriptor:
.db (DevNameStringDescriptorEnd-DevNameStringDescriptor)*4-2,3;length, type: string descriptor
.db "HBK_JoyStick_for_R220"
DevNameStringDescriptorEnd:
NameStringDescriptor:
.db (NameStringDescriptorEnd-NameStringDescriptor)*4-2,3;length, type: string descriptor
.db "ATMega8_based USB Optical Joystick"
NameStringDescriptorEnd: |
|