⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb_descriptor.s51

📁 reference about wireless design which is helpful to everyone
💻 S51
字号:

#define ASM_FILE
#include "usb_descriptor.h"

   MODULE  usb_descriptor

   RSEG    RCODE

   PUBLIC pUsbDescStart;
   PUBLIC pUsbDescEnd;
   PUBLIC deviceDesc;
   PUBLIC configDesc;
   PUBLIC interface0Desc;
   PUBLIC interface1Desc;
   PUBLIC endpoint0Desc;
   PUBLIC endpoint1Desc;
   PUBLIC hid0Desc;
   PUBLIC hid1Desc;
   PUBLIC entity0Desc;
   PUBLIC entity1Desc;
   PUBLIC entity0DescEnd;
   PUBLIC entity1DescEnd;
   PUBLIC string0Desc;
   PUBLIC string1Desc;
   PUBLIC string2Desc;
   PUBLIC pUsbDescLut;
   PUBLIC pUsbDescLutEnd;
   PUBLIC pUsbDblbufLut;

;;-------------------------------------------------------------------------------------------------------
;; USB descriptors


pUsbDescStart:
deviceDesc:     ; Device descriptor
               DB deviceDescEnd - deviceDesc
               DB DESC_TYPE_DEVICE      ; bDescriptorType
               DB 10H, 01H              ; bcdUSB
               DB 00H                   ; bDeviceClass
               DB 00H                   ; bDeviceSubClass
               DB 00H                   ; bDeviceProtocol
               DB EP0_PACKET_SIZE
               DB 0A0H, 11H             ; idVendor
               DB 10H, 01H              ; idProduct
               DB 00H, 01H              ; bcdDevice
               DB 01H                   ; iManufacturer
               DB 02H                   ; iProduct
               DB 00H                   ; iSerialNumber
               DB 01H                   ; bNumConfigurations
deviceDescEnd:

config1LengthStart:
configDesc:     ; Configuration descriptor
                DB configDescEnd - configDesc
                DB DESC_TYPE_CONFIG     ; bDescriptorType
                DB config1LengthEnd - config1LengthStart, 00H
                DB 02H                  ; NumInterfaces
                DB 01H                  ; bConfigurationValue
                DB 00H                  ; iConfiguration
                DB 80H                  ; bmAttributes
                DB 25                   ; MaxPower
configDescEnd:

interface0Desc: ; Keyboard interface descriptor
                DB interface0DescEnd - interface0Desc
                DB DESC_TYPE_INTERFACE  ; bDescriptorType
                DB 00H                  ; bInterfaceNumber
                DB 00H                  ; bAlternateSetting
                DB 01H                  ; bNumEndpoints
                DB 03H                  ; bInterfaceClass (HID)
                DB 01H                  ; bInterfaceSubClass (Boot)
                DB 01H                  ; bInterfaceProcotol (Keyboard)
                DB 00H                  ; iInterface
interface0DescEnd:

hid0Desc:	; Keyboard HID descriptor
		DB hid0DescEnd - hid0Desc
		DB DESC_TYPE_HID            ; bDescriptor (MemPhis)
		DB 10H, 01H                 ; bcdHID
		DB 00H                      ; bCountryCode
		DB 01H                      ; bNumDescriptors
		DB DESC_TYPE_HIDREPORT      ; bDescriptorType
		DB entity0DescEnd - entity0Desc, 00H
hid0DescEnd:

endpoint0Desc:  ; Keyboard endpoint descriptor (EP1 IN)
                DB endpoint0DescEnd - endpoint0Desc
                DB DESC_TYPE_ENDPOINT    ; bDescriptorType
                DB 81H                   ; bEndpointAddress
                DB EP_ATTR_INT           ; bmAttributes (INT)
                DB 08H, 00H              ; wMaxPacketSize
                DB 0AH                   ; bInterval
endpoint0DescEnd:

interface1Desc: ; Mouse interface descriptor
                DB interface1DescEnd - interface1Desc
                DB DESC_TYPE_INTERFACE   ; bDescriptorType
                DB 01H                   ; bInterfaceNumber
                DB 00H                   ; bAlternateSetting
                DB 01H                   ; bNumEndpoints
                DB 03H                   ; bInterfaceClass (HID)
                DB 01H                   ; bInterfaceSubClass (Boot)
                DB 02H                   ; bInterfaceProcotol (Keyboard)
                DB 00H                   ; iInterface
interface1DescEnd:

hid1Desc:	; Mouse HID descriptor
		DB hid1DescEnd - hid1Desc
		DB DESC_TYPE_HID         ; bDescriptor (MemPhis)
		DB 10H, 01H              ; bcdHID
		DB 00H                   ; bCountryCode
		DB 01H                   ; bNumDescriptors
		DB DESC_TYPE_HIDREPORT   ; bDescriptorType
		DB entity1DescEnd - entity1Desc, 00H
hid1DescEnd:

endpoint1Desc:  ; Mouse endpoint descriptor (EP2 IN)
                DB endpoint1DescEnd - endpoint1Desc
                DB DESC_TYPE_ENDPOINT    ; bDescriptorType
                DB 82H                   ; bEndpointAddress
                DB EP_ATTR_INT           ; bmAttributes (INT)
                DB 08, 00H               ; wMaxPacketSize
                DB 0AH                   ; bInterval
endpoint1DescEnd:
config1LengthEnd:
;;-------------------------------------------------------------------------------------------------------


;;-------------------------------------------------------------------------------------------------------
;; String descriptors
string0Desc:    ; Serial number
                DB string0DescEnd - string0Desc
                DB 03H             ; bDescriptorType
                DB 09H
                DB 04H
string0DescEnd:

string1Desc:    ; Manufacturer
                DB string1DescEnd - string1Desc
                DB 03H             ; bDescriptorType
                DB 'C', 0
                DB 'h', 0
                DB 'i', 0
                DB 'p', 0
                DB 'c', 0
                DB 'o', 0
                DB 'n', 0
string1DescEnd:

string2Desc:    ; Product
                DB string2DescEnd - string2Desc
                DB 03H             ; bDescriptorType
                DB 'U', 0
                DB 'S', 0
                DB 'B', 0
                DB ' ', 0
                DB 'K', 0
                DB 'e', 0
                DB 'y', 0
                DB 'b', 0
                DB 'o', 0
                DB 'a', 0
                DB 'r', 0
                DB 'd', 0
                DB ' ', 0
                DB '&', 0
                DB ' ', 0
                DB 'M', 0
                DB 'o', 0
                DB 'u', 0
                DB 's', 0
                DB 'e', 0
string2DescEnd:
pUsbDescEnd:
;;-------------------------------------------------------------------------------------------------------


;;-------------------------------------------------------------------------------------------------------
;; HID report descriptors

entity0Desc:    ; Keyboard report descriptor
                DB 0005H, 0001H    ; Usage Pg (Generic Desktop)
                DB 0009H, 0006H    ; Usage (Keybaord)
                DB 00A1H, 0001H    ; Collection: (Application)

                DB 0075H, 0001H    ; Report Size (1)
                DB 0095H, 0008H    ; Report count (8)
                DB 0005H, 0007H    ; Usage Pg (Key Codes)
                DB 0019H, 00E0H    ; Usage Min (#)
                DB 0029H, 00E7H    ; Usage Max (#)
                DB 0015H, 0000H    ; Log Min (0)
                DB 0025H, 0001H    ; Log Max (1)
                DB 0081H, 0002H    ; Input: (Data, Variable, Absolute)

                DB 0095H, 0001H    ; Report Count (1)
                DB 0075H, 0008H    ; Report Size (8)
                DB 0081H, 0001H    ; Input: (Constant)

                DB 0095H, 0005H    ; Report Count (5)
                DB 0075H, 0001H    ; Report Size (1)
                DB 0005H, 0008H    ; Usage Pg (Pg# for LEDs)
                DB 0019H, 0001H    ; Usage Min (#)
                DB 0029H, 0005H    ; Usage Max (#)
                DB 0091H, 0002H    ; Output: (Data, Variable, Absolute)
                DB 0095H, 0001H    ; Report Count (1)
                DB 0075H, 0003H    ; Report Size (3)
                DB 0091H, 0001H    ; Output: (Constant)

                DB 0095H, 0006H    ; Report Count (6)
                DB 0075H, 0008H    ; Report Size (8)
                DB 0015H, 0000H    ; Log Min (0)
                DB 0025H, 0065H    ; Log Max (101)
                DB 0005H, 0007H    ; Usage Pg (Key Codes)
                DB 0019H, 0000H    ; Usage Min (#)
                DB 0029H, 0065H    ; Usage Max (#)
                DB 0081H, 0000H    ; Input: (Data, Array)

                DB 00C0H           ; End Collection
entity0DescEnd:

entity1Desc:    ; Mouse report descriptor
                DB 0005H, 0001H    ; Usage Pg (Generic Desktop)
                DB 0009H, 0002H    ; Usage (Mouse)
                DB 00A1H, 0001H    ; Collection: (Application)

                DB 0009H, 0001H    ; Usage (Pointer)
                DB 00A1H, 0000H    ; Collection (Linked)

                DB 0005H, 0009H    ; Usage (Button)
                DB 0019H, 0001H    ; Usage Min (#)
                DB 0029H, 0005H    ; Usage Max (#)
                DB 0015H, 0000H    ; Log Min (0)
                DB 0025H, 0001H    ; Log Max (1)
                DB 0095H, 0005H    ; Report count (5)
                DB 0075H, 0001H    ; Report Size (1)
                DB 0081H, 0002H    ; Input: (Data, Variable, Absolute)
                DB 0095H, 0001H    ; Report Count (1)
                DB 0075H, 0003H    ; Report Size (3)
                DB 0081H, 0001H    ; Input: (Constant)

                DB 0005H, 0001H    ; Usage Pg (Generic Desktop)
                DB 0009H, 0030H    ; Usage (X)
                DB 0009H, 0031H    ; Usage (Y)
                DB 0009H, 0038H    ; Usage (Wheel)
                DB 0015H, 0081H    ; Log Min (-127)
                DB 0025H, 007FH    ; Log Max (127)
                DB 0075H, 0008H    ; Report Size (8)
                DB 0095H, 0003H    ; Report Count (3)
                DB 0081H, 0006H    ; Input: (Data, Variable, Relative)

                DB 00C0H           ; End Collection
                DB 00C0H           ; End Collection
entity1DescEnd:
;;-------------------------------------------------------------------------------------------------------


;;-------------------------------------------------------------------------------------------------------
;; Look-up table for descriptors that are not returned through requests for DSC_DEVICE, DSC_CONFIG or
;; DSC_STRING (e.g. HID report descriptors)
pUsbDescLut:    DB DESC_TYPE_HIDREPORT, 00H         ; value (MSB:LSB)
                DB 00H,        00H                  ; index (MSB:LSB)
                DW entity0Desc                      ; pDesc
                DW entity0DescEnd - entity0Desc     ; length

                DB DESC_TYPE_HIDREPORT, 00H         ; value (MSB:LSB)
                DB 00H,        01H                  ; index (MSB:LSB)
                DW entity1Desc                      ; pDesc
                DW entity1DescEnd - entity1Desc     ; length
pUsbDescLutEnd:
;;-------------------------------------------------------------------------------------------------------


;;-------------------------------------------------------------------------------------------------------
;; Look-up table for double buffer settings (one set of bit masks for each defined interface)
pUsbDblbufLut:  DW interface0Desc  ; pInterface
                DB 00H             ; inMask
                DB 00H             ; outMask

                DW interface1Desc  ; pInterface
                DB 00H             ; inMask
                DB 00H             ; outMask
;;-------------------------------------------------------------------------------------------------------


                END;


/*******************************************************************************************************
 * Revision history:
 *
 * $Log: usb_descriptor.a51,v $
 *
 *******************************************************************************************************/


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -