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

📄 usbfs_1_cls_hid.asm

📁 cypresscy74294ic键盘和鼠标原码
💻 ASM
📖 第 1 页 / 共 3 页
字号:
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
Find_Report:
    call  USBFS_1_GetInterfaceLookupTable  ; Point the the interface lookup table
    ; The first entry of the table point to the report table.
    mov   [USBFS_1_t2],USBFS_1_t1      ; Set the GETWORD destination 
    call  USBFS_1_GETWORD              ; Get the pointer to the transfer descriptor table
                                       ; ITempW has the address
    mov   A, REG[USBFS_1_EP0DATA+wIndexLo]  ; Get the interface number
    mov   [USBFS_1_t2], A              ; Use the UM temp var--Selector
    mov   A, [USBFS_1_t1]              ; Get the Table Address MSB
    mov   X, [USBFS_1_t1+1]            ; Get the Table Address LSB

    asl   [USBFS_1_t2] ; Convert the index to offset

    swap  A, X
    add   A, [USBFS_1_t2]
    swap  A, X
    adc   A, 0                         ; A:X now points to the table entry we want

; Get the pointer to the Report Type Table
    GET_WORD

; Dereference to the requested Report Type
    push  A                            ; Don't loose the pointer MSB
    mov   A, REG[USBFS_1_EP0DATA+wValueHi]  ; Get the Report Type
    dec   A                            ; Make it 0 based
    mov   [USBFS_1_t2], A              ; Use the UM temp var--Selector
    pop   A                            ; Get the MSB back
    push  A                            ; Don't loose the pointer MSB
    romx                               ; Get the table size
    cmp   A, [USBFS_1_t2]              ; Range check
    jc    .not_supported_pop_1
        
    pop   A                            ; Get the MSB back
    inc   X                            ; Point to the next  entry
    adc   A, 0                         ;

    LT_INDEX_TO_OFFSET USBFS_1_t2      ; Convert the index to offset

    swap  A, X
    add   A, [USBFS_1_t2]
    swap  A, X
    adc   A, 0                         ; A:X now points to the table entry we want
; Get the pointer to the requested Report Table
    GET_WORD                            ; A:X points to the 

    NULL_PTR_CHECK .not_supported      ; Null Table entries indicated not supported
; Dereference to the requested TRANSFER DESCRIPTOR
    push  A                            ; Don't loose the pointer MSB
    mov   A, REG[USBFS_1_EP0DATA+wValueLo]  ; Get the Report ID
    mov   [USBFS_1_t2], A              ; Use the UM temp var--Selector
    pop   A                            ; Get the MSB back
    push  A                            ; Don't loose the pointer MSB
    romx                               ; Get the table size
    cmp   A, [USBFS_1_t2]              ; Range check
    jc    .not_supported_pop_1
        
    pop   A                            ; Get the MSB back

    ret                                ; Finished A:X point to the TD

.not_supported_pop_1:
    pop   A                            ; Restore the stack
.not_supported:
    mov   A, 0                         ; Return a null pointer
    mov   X, A                         ; 
    ret

;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_GetInterfaceLookupTable
;
;  DESCRIPTION:   Point to the interface lookup table
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;
;  RETURNS:
;
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
export  USBFS_1_GetInterfaceLookupTable:
USBFS_1_GetInterfaceLookupTable:
    call  USBFS_1_GET_CONFIG_TABLE_ENTRY ; Get the CONFIG_LOOKUP entry
    swap  A, X                         ; Second entry points to the HID_LOOKUP table
    add   A, 2                         ; So add two
    swap  A, X                         ; 
    adc   A, 0                         ; Don't forget the carry
    mov   [USBFS_1_t2],USBFS_1_t1      ; Set the GETWORD destination 
    call  USBFS_1_GETWORD              ; Get the pointer to the HID_LOOKUP table
                                       ; ITempW has the address
    mov   A, [USBFS_1_t1]              ; Get the table address MSB
    mov   X, [USBFS_1_t1+1]            ; Get the table address LSB
    ret




;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
;  USB 2nd Tier Dispactch Jump Tables for HID Class Requests (based on bRequest)
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ;  USB 2nd Tier Dispactch Jump Table
;
;  DESCRIPTION:   The following tables dispatch to the Standard request handler
;                 functions.  (Assumes bmRequestType(5:6) is 0, Standard)
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;
;  RETURNS:
;
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
USBFS_1_DT_h2d_cls_ifc:
;-----------------------------------------------------------------------------

    jmp     USBFS_1_CB_h2d_cls_ifc_00
    jmp     USBFS_1_CB_h2d_cls_ifc_01
    jmp     USBFS_1_CB_h2d_cls_ifc_02
    jmp     USBFS_1_CB_h2d_cls_ifc_03
    jmp     USBFS_1_CB_h2d_cls_ifc_04
    jmp     USBFS_1_CB_h2d_cls_ifc_05
    jmp     USBFS_1_CB_h2d_cls_ifc_06
    jmp     USBFS_1_CB_h2d_cls_ifc_07
    jmp     USBFS_1_CB_h2d_cls_ifc_08
    jmp     USBFS_1_CB_h2d_cls_ifc_09
    jmp     USBFS_1_CB_h2d_cls_ifc_10
    jmp     USBFS_1_CB_h2d_cls_ifc_11
    jmp     USBFS_1_CB_h2d_cls_ifc_12

USBFS_1_DT_h2d_cls_ifc_End:
USBFS_1_DT_h2d_cls_ifc_Size: equ (USBFS_1_DT_h2d_cls_ifc_End-USBFS_1_DT_h2d_cls_ifc) / 2
USBFS_1_DT_h2d_cls_ifc_Dispatch::
    CMP     [USBFS_1_Configuration], 0 ; Is the device configured?
    JNZ     .configured                ; Jump on configured
    JMP     USBFS_1_Not_Supported_Local_Hid  ; Stall the request if not configured
; Jump here if the device is configured
.configured:
    MOV     A, REG[USBFS_1_EP0DATA + bRequest]   ; Get the request number
    DISPATCHER USBFS_1_DT_h2d_cls_ifc, USBFS_1_DT_h2d_cls_ifc_Size, USBFS_1_Not_Supported_Local_Hid 

;-----------------------------------------------------------------------------
USBFS_1_DT_d2h_cls_ifc:
;-----------------------------------------------------------------------------

    jmp     USBFS_1_CB_d2h_cls_ifc_00
    jmp     USBFS_1_CB_d2h_cls_ifc_01
    jmp     USBFS_1_CB_d2h_cls_ifc_02
    jmp     USBFS_1_CB_d2h_cls_ifc_03

USBFS_1_DT_d2h_cls_ifc_End:
USBFS_1_DT_d2h_cls_ifc_Size: equ (USBFS_1_DT_d2h_cls_ifc_End-USBFS_1_DT_d2h_cls_ifc) / 2
USBFS_1_DT_d2h_cls_ifc_Dispatch::
    CMP     [USBFS_1_Configuration], 0 ; Is the device configured?
    JNZ     .configured                ; Jump on configured
    JMP     USBFS_1_Not_Supported_Local_Hid  ; Stall the request if not configured
; Jump here if the device is configured
.configured:
    MOV     A, REG[USBFS_1_EP0DATA + bRequest]   ; Get the request number
    DISPATCHER USBFS_1_DT_d2h_cls_ifc, USBFS_1_DT_d2h_cls_ifc_Size, USBFS_1_Not_Supported_Local_Hid 

IF (USB_CB_SRC_d2h_cls_ifc_00 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_d2h_cls_ifc_00
USBFS_1_CB_d2h_cls_ifc_00:
ENDIF
IF (USB_CB_SRC_d2h_cls_ifc_01 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_d2h_cls_ifc_01
USBFS_1_CB_d2h_cls_ifc_01:
ENDIF
IF (USB_CB_SRC_d2h_cls_ifc_02 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_d2h_cls_ifc_02
USBFS_1_CB_d2h_cls_ifc_02:
ENDIF
IF (USB_CB_SRC_d2h_cls_ifc_03 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_d2h_cls_ifc_03
USBFS_1_CB_d2h_cls_ifc_03:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_00 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_00
USBFS_1_CB_h2d_cls_ifc_00:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_01 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_01
USBFS_1_CB_h2d_cls_ifc_01:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_02 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_02
USBFS_1_CB_h2d_cls_ifc_02:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_03 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_03
USBFS_1_CB_h2d_cls_ifc_03:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_04 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_04
USBFS_1_CB_h2d_cls_ifc_04:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_05 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_05
USBFS_1_CB_h2d_cls_ifc_05:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_06 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_06
USBFS_1_CB_h2d_cls_ifc_06:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_07 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_07
USBFS_1_CB_h2d_cls_ifc_07:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_08 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_08
USBFS_1_CB_h2d_cls_ifc_08:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_09 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_09
USBFS_1_CB_h2d_cls_ifc_09:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_10 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_10
USBFS_1_CB_h2d_cls_ifc_10:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_11 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_11
USBFS_1_CB_h2d_cls_ifc_11:
ENDIF
IF (USB_CB_SRC_h2d_cls_ifc_12 & USB_NOT_SUPPORTED)
export  USBFS_1_CB_h2d_cls_ifc_12
USBFS_1_CB_h2d_cls_ifc_12:
ENDIF

USBFS_1_Not_Supported_Local_Hid:
    LJMP     USBFS_1_Not_Supported

USBFS_1_GetTableEntry_Local_Hid:
    LJMP     USBFS_1_GetTableEntry

;-----------------------------------------------
; Add custom application code for routines 
; redefined by USB_APP_SUPPLIED in USB_HID.INC
;-----------------------------------------------

   ;@PSoC_UserCode_BODY_1@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------

   ;---------------------------------------------------
   ; Insert your custom code above this banner
   ;---------------------------------------------------
   ;@PSoC_UserCode_END@ (Do not change this line.)

; End of File USBFS_1_cls_hid.asm

⌨️ 快捷键说明

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