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

📄 usbfs_1_std.asm

📁 cypresscy74294ic键盘和鼠标原码
💻 ASM
📖 第 1 页 / 共 4 页
字号:
    JZ      .done

    CMP     A, USB_NUM_ENDPOINTS       ; Range check
    JNC     USBFS_1_Not_Supported

    MOV     X, A                       ; Endpoint number is the index

    OR      [X+USBFS_1_EndpointStatus], USB_ENDPOINT_STATUS_HALT  ; Halt the endpoint

    TST     REG[USBFS_1_EP0DATA+wIndexLo], USB_DIR_IN  ; IN or OUT endpoint?
    M8C_SetBank1	                      ; For EP1_MODE register
    JNZ     .in

    MOV     REG[X + USBFS_1_EP1MODE - 1], USB_MODE_STALL_DATA_EP | USB_MODE_ACK_OUT  ; Stall the endpoint
    JMP     .done    
.in:
    MOV     REG[X + USBFS_1_EP1MODE - 1], USB_MODE_STALL_DATA_EP | USB_MODE_ACK_IN  ; Stall the endpoint
.done:        
	M8C_SetBank0
    JMP     USBFS_1_NoDataStageControlTransfer_Local_Std
ENDIF
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ConfigureEP
;
;  DESCRIPTION:   Configure an endpoint
;
;  ARGUMENTS:    A contains the endpoint direction
;                X contains the endpoint number
;
;  RETURNS:
;
;  SIDE EFFECTS:  The A REGISTER IS VOLATILE.  X REGISTER IS MAINTAINED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
ConfigureEP:
    CMP     A, USB_DIR_UNUSED          ; Is this endpoint unused?
    JNZ     .enable                    ; Only enable it if it is used
    RET                                ; Quick exit if this endpoint is unused

; Jump here to enable an endpoint
.enable:
    PUSH    A		                        ; Save the endpoint direction
    MOV     A, X	                      ; We are using a JACC to dispatch to enable the interrupt
    ASL     A		                        ;  
    JACC    .EP_INT_ENABLE             ;  


.EP_INT_ENABLE:
    JMP     .EP0IntEnable              ; Enable EP0
    JMP     .EP1IntEnable              ; Enable EP1
    JMP     .EP2IntEnable              ; Enable EP2
    JMP     .EP3IntEnable              ; Enable EP3
    JMP     .EP4IntEnable              ; Enable EP4

; Jump here to enable EP0 Interrupts
.EP0IntEnable:
    M8C_EnableIntMask USBFS_1_INT_REG, USBFS_1_INT_EP0_MASK
;    JMP   .exit2
    JMP   .cont
.EP1IntEnable:
    M8C_EnableIntMask USBFS_1_INT_REG, USBFS_1_INT_EP1_MASK
    JMP   .cont
.EP2IntEnable:
    M8C_EnableIntMask USBFS_1_INT_REG, USBFS_1_INT_EP2_MASK
    JMP   .cont
.EP3IntEnable:
    M8C_EnableIntMask USBFS_1_INT_REG, USBFS_1_INT_EP3_MASK
    JMP   .cont
.EP4IntEnable:
    M8C_EnableIntMask USBFS_1_INT_REG, USBFS_1_INT_EP4_MASK  
	JMP   .cont

; Jump or flow here to continue configuring the endpoint    
;.contEP0:
;    POP   A                           ; Get the endpoint direction back
;    AND   A, USB_DIR_IN               ; Is it an IN endpoint?
;    JNZ   .inEP0                      ; Jump on IN
; Flow here for an OUT Endpoint
;    MOV   [USBFS_1_TempMode], USB_MODE_NAK_OUT ; NAK the endpoint
;    JMP   .exit2
; Jump here for an IN Endpoint
;.inEP0:
;    MOV   [USBFS_1_TempMode], USB_MODE_NAK_IN ; NAK the endpoint
;	JMP   .exit2
.cont:
    MOV     A, X	                      ; Get the endpoint number from X
    INDEX   USBFS_1_USB_EP_BIT_LOOKUP	 ; Find bit position for endpoint
    XOR     A, FFh
    AND     [USBFS_1_EPDataToggle], A ; Clear the data toggle for this endpoint

; if endpoint 0 set EP0MODE
; then exit
;    MOV     A, X	                     ; Get the endpoint number from X
;    CMP     A, EP0	                   ; Is this endpoint zero?
;    JNZ     .enable                   ; Only enable it if it is used

    M8C_SetBank1
    POP   A                            ; Get the endpoint direction back
    AND   A, USB_DIR_IN                ; Is it an IN endpoint?
    JNZ   .in                          ; Jump on IN
; Flow here for an OUT Endpoint
    MOV   REG[X+USBFS_1_EP1MODE-1], USB_MODE_NAK_OUT ; NAK the endpoint
    MOV   [X+USBFS_1_EndpointAPIStatus], NO_EVENT_PENDING ; For the API
    JMP   .exit1
; Jump here for an IN Endpoint
.in:
    MOV   REG[X+USBFS_1_EP1MODE-1], USB_MODE_NAK_IN ; NAK the endpoint
; Jump or flow here to set the API event and exit    
.exit1:
	M8C_SetBank0
.exit2:
;    MOV   [X+USBFS_1_EPDataToggle], 0  ; Clear all EP data toggles?  Is this right?
    MOV   [X+USBFS_1_EndpointAPIStatus], EVENT_PENDING ; For the API
    RET

;-----------------------------------------------------------------------------
;  USB 2nd Tier Dispactch Jump Tables for Standard 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_d2h_std_dev:
;-----------------------------------------------------------------------------

    jmp     USBFS_1_CB_d2h_std_dev_00
    jmp     USBFS_1_CB_d2h_std_dev_01
    jmp     USBFS_1_CB_d2h_std_dev_02
    jmp     USBFS_1_CB_d2h_std_dev_03
    jmp     USBFS_1_CB_d2h_std_dev_04
    jmp     USBFS_1_CB_d2h_std_dev_05
    jmp     USBFS_1_CB_d2h_std_dev_06
    jmp     USBFS_1_CB_d2h_std_dev_07
    jmp     USBFS_1_CB_d2h_std_dev_08

USBFS_1_DT_d2h_std_dev_End:
USBFS_1_DT_d2h_std_dev_Size: equ (USBFS_1_DT_d2h_std_dev_End-USBFS_1_DT_d2h_std_dev) / 2
USBFS_1_DT_d2h_std_dev_Dispatch::
    MOV    A, REG[USBFS_1_EP0DATA + bRequest]
    DISPATCHER USBFS_1_DT_d2h_std_dev, USBFS_1_DT_d2h_std_dev_Size, USBFS_1_Not_Supported 

;-----------------------------------------------------------------------------
USBFS_1_DT_h2d_std_dev:
;-----------------------------------------------------------------------------

    jmp     USBFS_1_CB_h2d_std_dev_00
    jmp     USBFS_1_CB_h2d_std_dev_01
    jmp     USBFS_1_CB_h2d_std_dev_02
    jmp     USBFS_1_CB_h2d_std_dev_03
    jmp     USBFS_1_CB_h2d_std_dev_04
    jmp     USBFS_1_CB_h2d_std_dev_05
    jmp     USBFS_1_CB_h2d_std_dev_06
    jmp     USBFS_1_CB_h2d_std_dev_07
    jmp     USBFS_1_CB_h2d_std_dev_08
    jmp     USBFS_1_CB_h2d_std_dev_09

USBFS_1_DT_h2d_std_dev_End:
USBFS_1_DT_h2d_std_dev_Size: equ (USBFS_1_DT_h2d_std_dev_End-USBFS_1_DT_h2d_std_dev) / 2
USBFS_1_DT_h2d_std_dev_Dispatch::

    MOV     A, REG[USBFS_1_EP0DATA + bRequest]
    DISPATCHER USBFS_1_DT_h2d_std_dev, USBFS_1_DT_h2d_std_dev_Size, USBFS_1_Not_Supported 


;-----------------------------------------------------------------------------
USBFS_1_DT_d2h_std_ifc:
;-----------------------------------------------------------------------------

    jmp     USBFS_1_CB_d2h_std_ifc_00
    jmp     USBFS_1_CB_d2h_std_ifc_01
    jmp     USBFS_1_CB_d2h_std_ifc_02
    jmp     USBFS_1_CB_d2h_std_ifc_03
    jmp     USBFS_1_CB_d2h_std_ifc_04
    jmp     USBFS_1_CB_d2h_std_ifc_05
    jmp     USBFS_1_CB_d2h_std_ifc_06
    jmp     USBFS_1_CB_d2h_std_ifc_07
    jmp     USBFS_1_CB_d2h_std_ifc_08
    jmp     USBFS_1_CB_d2h_std_ifc_09
    jmp     USBFS_1_CB_d2h_std_ifc_10

USBFS_1_DT_d2h_std_ifc_End:
USBFS_1_DT_d2h_std_ifc_Size: equ (USBFS_1_DT_d2h_std_ifc_End-USBFS_1_DT_d2h_std_ifc) / 2
USBFS_1_DT_d2h_std_ifc_Dispatch::
    CMP     [USBFS_1_Configuration], 0 ; Is the device configured?
    JNZ     .configured                ; Jump on configured
    JMP    _USBFS_1_Not_Supported      ; Stall the request if not configured
; Jump here if the device is configured
.configured:
    MOV     A, REG[USBFS_1_EP0DATA + bRequest]
    DISPATCHER USBFS_1_DT_d2h_std_ifc, USBFS_1_DT_d2h_std_ifc_Size, USBFS_1_Not_Supported 

;-----------------------------------------------------------------------------
USBFS_1_DT_h2d_std_ifc:
;-----------------------------------------------------------------------------

    jmp     USBFS_1_CB_h2d_std_ifc_00

USBFS_1_DT_h2d_std_ifc_End:
USBFS_1_DT_h2d_std_ifc_Size: equ (USBFS_1_DT_h2d_std_ifc_End-USBFS_1_DT_h2d_std_ifc) / 2
USBFS_1_DT_h2d_std_ifc_Dispatch::
    CMP     [USBFS_1_Configuration], 0 ; Is the device configured?
    JNZ     .configured                ; Jump on configured
    JMP    _USBFS_1_Not_Supported      ; Stall the request if not configured
; Jump here if the device is configured
.configured:
    MOV     A, REG[USBFS_1_EP0DATA + bRequest]
    
   ;---------------------------------------------------
   ;@PSoC_UserCode_BODY_2@ (Do not change this line.)
   ;---------------------------------------------------
   ; Add your custom Interface change logic below
   ;---------------------------------------------------    
    
   ;---------------------------------------------------
   ; Insert your custom code above this banner
   ;---------------------------------------------------
   ;@PSoC_UserCode_END@ (Do not change this line.)    

    DISPATCHER USBFS_1_DT_h2d_std_ifc, USBFS_1_DT_h2d_std_ifc_Size, USBFS_1_Not_Supported 

;-----------------------------------------------------------------------------
USBFS_1_DT_d2h_std_ep:
;-----------------------------------------------------------------------------
    jmp     USBFS_1_CB_d2h_std_ep_00

USBFS_1_DT_d2h_std_ep_End:
USBFS_1_DT_d2h_std_ep_Size: equ (USBFS_1_DT_d2h_std_ep_End-USBFS_1_DT_d2h_std_ep) / 2
USBFS_1_DT_d2h_std_ep_Dispatch::
    CMP     [USBFS_1_Configuration], 0 ; Is the device configured?
    JNZ     .configured                ; Jump on configured

    MOV     A, REG[USBFS_1_EP0DATA + wIndexHi] ; Is the request for EP0?
    MOV     [USBFS_1_t2], A            ; Use the UM temp var--Selector
    MOV     A, REG[USBFS_1_EP0DATA + wIndexLo] ;
    OR      [USBFS_1_t2], A            ; Use the UM temp var--Selector
    JZ      .ep0_request

    JMP    _USBFS_1_Not_Supported      ; Stall the request if not configured
; Jump here if the device is configured or EP0 request
.configured:
.ep0_request:
    MOV     A, REG[USBFS_1_EP0DATA + bRequest]
    DISPATCHER USBFS_1_DT_d2h_std_ep, USBFS_1_DT_d2h_std_ep_Size, USBFS_1_Not_Supported 


;-----------------------------------------------------------------------------
USBFS_1_DT_h2d_std_ep:
;-----------------------------------------------------------------------------
    jmp     USBFS_1_CB_h2d_std_ep_00
    jmp     USBFS_1_CB_h2d_std_ep_01
    jmp     USBFS_1_CB_h2d_std_ep_02
    jmp     USBFS_1_CB_h2d_std_ep_03

USBFS_1_DT_h2d_std_ep_End:
USBFS_1_DT_h2d_std_ep_Size: equ (USBFS_1_DT_h2d_std_ep_End-USBFS_1_DT_h2d_std_ep) / 2
USBFS_1_DT_h2d_std_ep_Dispatch::
    CMP     [USBFS_1_Configuration], 0 ; Is the device configured?
    JNZ     .configured                ; Jump on configured

    MOV     A, REG[USBFS_1_EP0DATA + wIndexHi] ; Is the request for EP0?
    MOV     [USBFS_1_t2], A            ; Use the UM temp var--Selector
    MOV     A, REG[USBFS_1_EP0DATA + wIndexLo] ;
    OR      [USBFS_1_t2], A            ; Use the UM temp var--Selector
    JZ      .ep0_request

    JMP    _USBFS_1_Not_Supported      ; Stall the request if not configured
; Jump here if the device is configured or EP0 request
.configured:
.ep0_request:
    MOV     A, REG[USBFS_1_EP0DATA + bRequest]
    DISPATCHER USBFS_1_DT_h2d_std_ep, USBFS_1_DT_h2d_std_ep_Size, USBFS_1_Not_Supported 

USBFS_1_GetTableEntry_Local_Std:
    LJMP    USBFS_1_GetTableEntry

USBFS_1_NoDataStageControlTransfer_Local_Std:
    LJMP    USBFS_1_NoDataStageControlTransfer

;-----------------------------------------------
; 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_std.asm

⌨️ 快捷键说明

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