📄 usbfs_1_cls_hid.asm
字号:
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_d2h_cls_ifc_02 & USB_UM_SUPPLIED)
; TODO: Should this table move to another file (GetIdleTable)
; TODO: How will we build this table to the correct size? (GetIdleTable)
.LITERAL
GetSetIdleTable:
TD_START_TABLE 1h ; One entry for each interface
TD_ENTRY USB_DS_RAM, 1, USBFS_1_IdleReload, NULL_PTR ; Reuse the transfer buffer
TD_ENTRY USB_DS_RAM, 1, USBFS_1_IdleReload+1, NULL_PTR ; Reuse the transfer buffer
.ENDLITERAL
export USBFS_1_CB_d2h_cls_ifc_02
USBFS_1_CB_d2h_cls_ifc_02:
; TODO: Verify that report numbers 1 to n (or 0 to n-1)
mov A, REG[USBFS_1_EP0DATA+wValueLo] ; Get the report number
cmp A, 0 ; We don't support report by report idle
jnz USBFS_1_Not_Supported_Local_Hid
mov A, REG[USBFS_1_EP0DATA+wIndexLo] ; Get the interface number
cmp A, 1h ; We don't support report by report idle
jnc USBFS_1_Not_Supported_Local_Hid
mov [USBFS_1_t2], A ; Use the UM temp var--Selector
mov A,>GetSetIdleTable ; Get the ROM Address MSB
mov X,<GetSetIdleTable ; Get the ROM Address LSB
jmp USBFS_1_GetTableEntry_Local_Hid
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: USBFS_1_CB_d2h_cls_ifc_03
;
; DESCRIPTION: Get Protocol
;
;****************************************************************
; HID CLASS INTERFACE IN REQUEST: Get_Protocol
;****************************************************************
;
; bmRequestType : (OUT | CLASS | INTERFACE) = A1h
; bRequest : GET_PROTOCOL = 03h
; wValue : RESERVED = 0000h
; wIndex : INTERFACE = --xxh
; wLength : SIZEOF_INTERFACE_PROTOCOL = 0001h
;
; The GET_PROTOCOL request reads which protocol is currently
; active.
;
;****************************************************************
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_d2h_cls_ifc_03 & USB_UM_SUPPLIED)
.LITERAL
GetProtocolTable:
TD_START_TABLE 2 ; One entry for BOOT/One entry for REPORT
TD_ENTRY USB_DS_ROM, 1, ROM_ZERO, NULL_PTR ; Simply use a a hard coded zero or one
TD_ENTRY USB_DS_ROM, 1, ROM_ONE, NULL_PTR ;
ROM_ZERO: DB 0
ROM_ONE: DB 1
.ENDLITERAL
export USBFS_1_CB_d2h_cls_ifc_03
USBFS_1_CB_d2h_cls_ifc_03:
mov A, REG[USBFS_1_EP0DATA+wIndexLo] ; Get the interface number
cmp A, 1h ; Range check
jnc USBFS_1_Not_Supported_Local_Hid
mov X, A ; Get the protocol for the requested interface
mov A, [X + USBFS_1_Protocol] ;
mov [USBFS_1_t2], A ; Use the UM temp var--Selector
mov A,>GetProtocolTable ; Get the ROM Address MSB
mov X,<GetProtocolTable ; Get the ROM Address LSB
jmp USBFS_1_GetTableEntry_Local_Hid
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: USBFS_1_CB_h2d_cls_ifc_09
;
; DESCRIPTION: Set Report
;
;****************************************************************
; HID CLASS INTERFACE OUT REQUEST: Set_Report
;****************************************************************
;
; bmRequestType : (OUT | CLASS | INTERFACE) = 21h
; bRequest : SET_REPORT = 09h
; wValue : REPORT TYPE | REPORT ID = xxxxh
; wIndex : INTERFACE = --xxh
; wLength : REPORT LENGTH = --xxh
;
; The SET_REPORT request allows the host to send a report to the
; device, possibly setting the state of input, output or feature
; controls.
;
;****************************************************************
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_h2d_cls_ifc_09 & USB_UM_SUPPLIED)
export USBFS_1_CB_h2d_cls_ifc_09
USBFS_1_CB_h2d_cls_ifc_09:
CALL Find_Report
NULL_PTR_CHECK USBFS_1_Not_Supported_Local_Hid
JMP USBFS_1_GetTableEntry_Local_Hid
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: USBFS_1_CB_h2d_cls_ifc_10
;
; DESCRIPTION: Set Idle
;
;****************************************************************
; HID CLASS INTERFACE OUT REQUEST: Set_Idle
;****************************************************************
;
; bmRequestType : (OUT | CLASS | INTERFACE) = 21h
; bRequest : SET_IDLE = 0Ah
; wValue : DURATION | REPORT ID = xxxxh
; wIndex : INTERFACE = --xxh
; wLength : ZERO = 0000h
;
; The SET_IDLE request silences a particular input report (or all
; input reports) on a specific interface until a new event occurs
; or the specified amount of time passes.
;
;****************************************************************
; Note: This function does not support multiple reports per interface.
;****************************************************************
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_h2d_cls_ifc_10 & USB_UM_SUPPLIED)
export USBFS_1_CB_h2d_cls_ifc_10
USBFS_1_CB_h2d_cls_ifc_10:
; TODO: Verify that report numbers 1 to n (or 0 to n-1)
mov A, REG[USBFS_1_EP0DATA+wValueLo] ; Get the report number
cmp A, 0 ; We don't support report by report idle
jnz USBFS_1_Not_Supported_Local_Hid
mov A, REG[USBFS_1_EP0DATA+wIndexLo] ; Get the interface number
cmp A, 1h ; Range Check
jnc USBFS_1_Not_Supported_Local_Hid
mov X, A ; Interface Number becomes an index
mov A, REG[USBFS_1_EP0DATA+wValueHi] ; Get the duration
mov [X+USBFS_1_IdleReload], A ; Save the reload immediately
cmp A, 0 ; Is this request setting the duration to indefinite?
jz .reload ; If so, reload the timer
; Otherwise, we need to determine if we reset the current expiry
; (HID Spec says to send the next report if we are within 4 ms (1 count)
; of sending the next report
cmp [X+USBFS_1_IdleTimer], 1 ; Within 4 ms?
jz .done ; Jump to let the timer expire "naturally"
; Jump or Flow here to reload the timer
.reload:
mov [x+USBFS_1_IdleTimer], A ; Reload the timer
.done:
jmp USBFS_1_NoDataStageControlTransfer
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: USBFS_1_CB_h2d_cls_ifc_11
;
; DESCRIPTION: Set Idle
;
;****************************************************************
; HID CLASS INTERFACE OUT REQUEST: Set_Protocol
;****************************************************************
;
; bmRequestType : (OUT | CLASS | INTERFACE) = 21h
; bRequest : SET_PROTOCOL = 0Bh
; wValue : DURATION | REPORT ID = xxxxh
; wIndex : PROTOCOL = --xxh
; wLength : ZERO = 0000h
;
; The SET_PROTOCOL request switches between the boot protocol and
; the report protocol (or vice versa).
;
;****************************************************************
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
IF (USB_CB_SRC_h2d_cls_ifc_11 & USB_UM_SUPPLIED)
export USBFS_1_CB_h2d_cls_ifc_11
USBFS_1_CB_h2d_cls_ifc_11:
mov A, REG[USBFS_1_EP0DATA+wIndexLo] ; Get the interface number
cmp A, 1h ; Range check
jnc USBFS_1_Not_Supported_Local_Hid
mov X, A ; Save the interface number
mov A, REG[USBFS_1_EP0DATA+wValueLo] ; Get the protocol
cmp A, (1+1) ; Must be zero or one
jnc USBFS_1_Not_Supported_Local_Hid
mov [X + USBFS_1_Protocol], A ; Save the new protocol
jmp USBFS_1_NoDataStageControlTransfer
ENDIF
;-----------------------------------------------------------------------------
; FUNCTION NAME: Find_Report
;
; DESCRIPTION: Scan the HID Report Tree and return a pointer to the
; HID Report Transfer Descriptor (TD) or NULL
; This function is called in during the processing of
; GET_REPORT or SET_REPORT HID Class Requests.
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -