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

📄 descriptors.asm

📁 usb serial converter
💻 ASM
字号:
;****************************************************************
; DESCRIPTORS
;****************************************************************

    XPAGEOFF

IFDEF 64013

POLLING_INTERVAL:       equ    01h             ; Full Speed is 1ms

ENDIF

IFDEF 63743

POLLING_INTERVAL:       equ    0Ah             ; Low Speed is 10ms

ENDIF     
        
;****************************************************************
; control_read_table
;****************************************************************

control_read_table:

;****************************************************************
; DEVICE DESCRIPTOR
;****************************************************************

device_descriptor:
    db      SIZEOF_DEVICE_DESCRIPTOR        ; size of descriptor (18 bytes)
    db      DEVICE                          ; descriptor type (device descriptor)
    dwl     0100h                           ; USB spec release (ver 1.0)
    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)
    dwl     04B4h                           ; Vendor ID (Cypress Semiconductor, 04B4)
    dwl     5500h                           ; Product ID (5500)
    dwl     0000h                           ; device release number
    db      01h                             ; index of manufacturer string 
    db      02h                             ; index of product string 
    db      00h                             ; index of serial number (0 = none)
    db      01h                             ; number of configurations (1)
device_descriptor_end:

SIZEOF_DEVICE_DESCRIPTOR:    equ (device_descriptor_end - device_descriptor)

;****************************************************************
; CONFIGURATION DESCRIPTOR
;****************************************************************

configuration_descriptor:
    db      SIZEOF_CONFIGURATION_DESCRIPTOR ; length of descriptor (9 bytes)
    db      CONFIGURATION                   ; descriptor type (CONFIGURATION)
    dwl     SIZEOF_ALL_CONFIGURATION_DESCRIPTORS ; total length of descriptor (34 bytes)
    db      01h                             ; number of interfaces to configure (1)
    db      01h                             ; configuration value (1)
    db      04h                             ; configuration string index 
    db      80h                             ; configuration attributes (bus powered)
    db      32h                             ; maximum power (100mA)
configuration_descriptor_end:

SIZEOF_CONFIGURATION_DESCRIPTOR:    equ (configuration_descriptor_end - configuration_descriptor)

;****************************************************************
; INTERFACE DESCRIPTOR TABLE
;****************************************************************

interface_descriptor:
    db      SIZEOF_INTERFACE_DESCRIPTOR     ; length of descriptor (9 bytes)
    db      INTERFACE                       ; descriptor type (INTERFACE)
    db      00h                             ; interface number (1)
    db      00h                             ; alternate setting (0)
    db      02h                             ; number of endpoints (2)
    db      03h                             ; interface class (3..defined by USB spec)
    db      00h                             ; interface sub-class (1..defined by USB spec)
    db      00h                             ; interface protocol (2..defined by USB spec)
    db      00h                             ; interface string index 
interface_descriptor_end:

SIZEOF_INTERFACE_DESCRIPTOR:    equ (interface_descriptor_end - interface_descriptor)

;****************************************************************
; HID DESCRIPTOR
;****************************************************************

hid_descriptor:
    db      SIZEOF_HID_DESCRIPTOR           ; descriptor size (9 bytes)
    db      HID                             ; descriptor type (HID)
    dwl     0100h                           ; HID class release number (1.00)
    db      00h                             ; Localized country code (none)
    db      01h                             ; # of HID class descriptor to follow (1)
    db      22h                             ; Report descriptor type (HID)
    dwl     SIZEOF_HID_REPORT_DESCRIPTOR    ;
hid_descriptor_end:

SIZEOF_HID_DESCRIPTOR:    equ (hid_descriptor_end - hid_descriptor)

;****************************************************************
; EP1 DESCRIPTOR
;****************************************************************

ep1_descriptor:
    db      SIZEOF_EP1_DESCRIPTOR           ; descriptor length (7 bytes)
    db      ENDPOINT                        ; descriptor type (ENDPOINT)
    db      81h                             ; endpoint address (IN endpoint, endpoint 1)
    db      03h                             ; endpoint attributes (interrupt)
    dwl     SIZEOF_EP2_FIFO                 ; maximum packet size (32 bytes)    
    db      POLLING_INTERVAL                ; polling interval (4ms)
ep1_descriptor_end:

SIZEOF_EP1_DESCRIPTOR:  equ (ep1_descriptor_end - ep1_descriptor)

;****************************************************************
; EP2 DESCRIPTOR
;****************************************************************

ep2_descriptor:
    db      SIZEOF_EP2_DESCRIPTOR           ; descriptor length (7 bytes)
    db      ENDPOINT                        ; descriptor type (ENDPOINT)
    db      02h                             ; endpoint address (OUT endpoint, endpoint 2)
    db      03h                             ; endpoint attributes (interrupt)
    dwl     SIZEOF_EP2_FIFO                 ; maximum packet size (32 bytes)
    db      POLLING_INTERVAL                ; polling interval (4ms)
ep2_descriptor_end:

SIZEOF_EP2_DESCRIPTOR:  equ (ep2_descriptor_end - ep2_descriptor)


;****************************************************************
;
;****************************************************************

all_configuration_descriptors_end:

SIZEOF_ALL_CONFIGURATION_DESCRIPTORS:  equ (all_configuration_descriptors_end - configuration_descriptor)

;****************************************************************
; HID REPORT DESCRIPTOR
;****************************************************************

hid_report_descriptor:
 
    db      06h, A0h, FFh                   ; Usage Page (FFA0H = vendor defined)
    db      09h, 01h                        ; Usage (Vendor defined)
    db      A1h, 01h                        ; Collection (Application)
    
    ; The input report
    db      09h, 01h                        ; Usage (vendor defined)
    db      15h, 00h                        ; Logical minimum (0)
    db      26h, FFh, 00h                   ; Logical maximum (255)
    db      75h, 08h                        ; Report size (8 bits)
    db      95h, SIZEOF_INPUT_REPORT        ; Report count (8 fields)
    db      81h, 02h                        ; Input (Data, Variable, Absolute)
    
    ; The output report
    db      09h, 02h                        ; Usage (vendor defined)
    db      75h, 08h                        ; Report size (8 bits)
    db      95h, SIZEOF_OUTPUT_REPORT       ; Report count (8 fields)
    db      91h, 02h                        ; Output (Data, Variable, Absolute)
    
    ; The Feature report
    db      09h, 03h                        ; Usage (vendor defined)
    db      75h, 08h                        ; Report size (8 bits)
    db      95h, SIZEOF_CONTROL_REPORT      ; Report count (5 fields)
    db      B1h, 02h                        ; Feature (Data, Variable, Absolute)
    
    db      C0h                             ; End Collection (Application)

hid_report_descriptor_end:

SIZEOF_HID_REPORT_DESCRIPTOR:   equ   (hid_report_descriptor_end - hid_report_descriptor)

;****************************************************************
; STRING DESCRIPTORS
;****************************************************************

string:

;****************************************************************
; LANGUAGE STRING
;****************************************************************

language_string:
    db      SIZEOF_LANGUAGE_STRING          ; Length
    db      STRING                          ; Type (3=string)
    db      09h                             ; Language:  English
    db      04h                             ; Sub-language: US
language_string_end:

SIZEOF_LANGUAGE_STRING:  equ (language_string_end - language_string)

;****************************************************************
; MANUFACTURER STRING    
;****************************************************************

manufacturer_string:
    db      SIZEOF_MANUFACTURER_STRING      ; Length
    db      STRING                          ; Type (3=string)
    dsu     "Cypress Semiconductor"         ;
manufacturer_string_end:

SIZEOF_MANUFACTURER_STRING:  equ (manufacturer_string_end - manufacturer_string)

;****************************************************************
; PRODUCT STRING   
;****************************************************************

product_string:
    db      SIZEOF_PRODUCT_STRING           ; Length
    db      STRING                          ; Type (3=string)
    dsu     "USB to Serial"                 ;
product_string_end:

SIZEOF_PRODUCT_STRING:  equ (product_string_end - product_string)

;****************************************************************
; SERIAL NUMBER STRING  
;****************************************************************
; If the firmware contains a serial number, it must be unique
; for each device or the devices may not enumerate properly.
;****************************************************************

serial_string:
serial_string_end:

SIZEOF_SERIAL_STRING:  equ (serial_string_end - serial_string)

;****************************************************************
; CONFIGURATION STRING  
;****************************************************************

configuration_string:
    db      SIZEOF_CONFIGURATION_STRING     ; Length
    db      STRING                          ; Type (3=string)
    dsu     "Sample HID"                    ;
configuration_string_end:

SIZEOF_CONFIGURATION_STRING:  equ (configuration_string_end - configuration_string)

;****************************************************************
; INTERFACE STRING  
;****************************************************************

interface_string:
    db      SIZEOF_INTERFACE_STRING         ; Length
    db      STRING                          ; Type (3=string)
    dsu     "EndPoint1 Interrupt Pipe"      ;
interface_string_end:

SIZEOF_INTERFACE_STRING:  equ (interface_string_end - interface_string)

string_end:

SIZEOF_STRING:  equ (string_end - string)

⌨️ 快捷键说明

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