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

📄 usbfs_1int.asm

📁 cypresscy74294ic键盘和鼠标原码
💻 ASM
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME: USBFS_1Common.asm
;;  Version: 1.1, Updated on 2006/06/19 at 11:41:37
;;  Generated by PSoC Designer ver 4.4  b1884 : 14 Jan, 2007
;;
;;  DESCRIPTION: USB Device User Module software implementation file
;;               for the CY8C24090 and CY7C64215 family of devices
;;
;;  NOTE: User Module APIs conform to the fastcall16 convention for marshalling
;;        arguments and observe the associated "Registers are volatile" policy.
;;        This means it is the caller's responsibility to preserve any values
;;        in the X and A registers that are still needed after the API functions
;;        returns. For Large Memory Model devices it is also the caller's 
;;        responsibility to perserve any value in the CUR_PP, IDX_PP, MVR_PP and 
;;        MVW_PP registers. Even though some of these registers may not be modified
;;        now, there is no guarantee that will remain the case in future releases.
;;-----------------------------------------------------------------------------
;;  Copyright (c) Cypress Semiconductor 2004, 2005. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************

include "m8c.inc"
include "memory.inc"
include "USBFS_1.inc"

;-----------------------------------------------
; include instance specific register definitions
;-----------------------------------------------

;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------
;-------------------------------------------------------------------
;  Declare the functions global for both assembler and C compiler.
;
;  Note that there are two names for each API. First name is
;  assembler reference. Name with underscore is name refence for
;  C compiler.  Calling function in C source code does not require
;  the underscore.
;-------------------------------------------------------------------

export    USBFS_1_EP1_ISR
export   _USBFS_1_EP1_ISR
export    USBFS_1_EP2_ISR
export   _USBFS_1_EP2_ISR
export    USBFS_1_EP3_ISR
export   _USBFS_1_EP3_ISR
export    USBFS_1_EP4_ISR
export   _USBFS_1_EP4_ISR
export    USBFS_1_RESET_ISR
export   _USBFS_1_RESET_ISR
export    USBFS_1_SOF_ISR
export   _USBFS_1_SOF_ISR
export    USBFS_1_WAKEUP_ISR
export   _USBFS_1_WAKEUP_ISR


AREA InterruptRAM (RAM, REL, CON)
;@PSoC_UserCode_INIT@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom declarations below this banner
;---------------------------------------------------

;------------------------
; Includes
;------------------------

	
;------------------------
;  Constant Definitions
;------------------------


;------------------------
; Variable Allocation
;------------------------


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

AREA text (ROM, REL)

;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_EP1_ISR
;
;  DESCRIPTION:    Handle the Endpoint 1 event by updating the data toggle
;                  and setting the endpoint state to EVENT_PENDING.  The SIE
;                  automatically set the mode to NAK both IN and out transfers
;-----------------------------------------------------------------------------
export  USBFS_1_EP1_ISR
export _USBFS_1_EP1_ISR
 USBFS_1_EP1_ISR:
_USBFS_1_EP1_ISR:
   ;@PSoC_UserCode_BODY_EP1@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers.
STD_EP1:    EQU     1   ; Set this equate to 0 to remove the standard
                        ; endpoint handling code
   ;---------------------------------------------------
   ; Insert your custom code above this banner
   ;---------------------------------------------------
   ;@PSoC_UserCode_END@ (Do not change this line.)

IF  STD_EP1
    PUSH A
    XOR     [USBFS_1_EPDataToggle], 2 ; Update EP1 data toggle
    M8C_SetBank1	; _EP1MODE is in Bank 1
    MOV     A, REG[USBFS_1_EP1MODE]    ; Get the mode
	M8C_SetBank0
	RAM_SETPAGE_IDX >USBFS_1_EndpointAPIStatus
    MOV     [USBFS_1_EndpointAPIStatus+1], EVENT_PENDING ; For the API
	RAM_X_POINTS_TO_STACKPAGE
    POP A
    RETI
ENDIF

;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_EP2_ISR
;
;  DESCRIPTION:    Handle the Endpoint 2 event by updating the data toggle
;                  and setting the endpoint state to EVENT_PENDING.  The SIE
;                  automatically set the mode to NAK both IN and out transfers
;-----------------------------------------------------------------------------
export  USBFS_1_EP2_ISR
export _USBFS_1_EP2_ISR
 USBFS_1_EP2_ISR:
_USBFS_1_EP2_ISR:

   ;@PSoC_UserCode_BODY_EP2@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers.
STD_EP2:    EQU     1   ; Set this equate to 0 to remove the standard
                        ; endpoint handling code
   ;---------------------------------------------------
   ; Insert your custom code above this banner
   ;---------------------------------------------------
   ;@PSoC_UserCode_END@ (Do not change this line.)

IF  STD_EP2
    PUSH A
    XOR     [USBFS_1_EPDataToggle], 4 ; Update EP2 data toggle
    M8C_SetBank1
    MOV     A, REG[USBFS_1_EP2MODE]    ; Get the mode
    M8C_SetBank0
    MOV     [USBFS_1_EndpointAPIStatus + 2], EVENT_PENDING ; For the API
    POP A
    RETI
ENDIF


;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_EP3_ISR
;
;  DESCRIPTION:    Handle the Endpoint 3 event by updating the data toggle
;                  and setting the endpoint state to EVENT_PENDING.  The SIE
;                  automatically set the mode to NAK both IN and out transfers
;-----------------------------------------------------------------------------
 USBFS_1_EP3_ISR:
_USBFS_1_EP3_ISR:

   ;@PSoC_UserCode_BODY_EP3@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers.
STD_EP3:    EQU     1   ; Set this equate to 0 to remove the standard
                        ; endpoint handling code
   ;---------------------------------------------------
   ; Insert your custom code above this banner
   ;---------------------------------------------------
   ;@PSoC_UserCode_END@ (Do not change this line.)

IF  STD_EP3
    PUSH A
    XOR     [USBFS_1_EPDataToggle], 8 ; Update EP3 data toggle
    M8C_SetBank1
    MOV     A, REG[USBFS_1_EP3MODE]    ; Get the mode
    M8C_SetBank0
    MOV     [USBFS_1_EndpointAPIStatus + 3], EVENT_PENDING ; For the API
    POP A
    RETI
ENDIF


;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_EP4_ISR
;
;  DESCRIPTION:    Handle the Endpoint 4 event by updating the data toggle
;                  and setting the endpoint state to EVENT_PENDING.  The SIE
;                  automatically set the mode to NAK both IN and out transfers
;-----------------------------------------------------------------------------
 USBFS_1_EP4_ISR:
_USBFS_1_EP4_ISR:

   ;@PSoC_UserCode_BODY_EP4@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers.
STD_EP4:    EQU     1   ; Set this equate to 0 to remove the standard
                        ; endpoint handling code
   ;---------------------------------------------------
   ; Insert your custom code above this banner
   ;---------------------------------------------------
   ;@PSoC_UserCode_END@ (Do not change this line.)

IF  STD_EP4
    PUSH A
    XOR     [USBFS_1_EPDataToggle], 16 ; Update EP4 data toggle
    M8C_SetBank1
    MOV     A, REG[USBFS_1_EP4MODE]    ; Get the mode
    M8C_SetBank0
    MOV     [USBFS_1_EndpointAPIStatus + 4], EVENT_PENDING ; For the API
    POP A
    RETI
ENDIF


;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_RESET_ISR
;
;  DESCRIPTION:    Handle the USB Bus Reset Interrupt
;-----------------------------------------------------------------------------
export  USBFS_1_RESET_ISR
export _USBFS_1_RESET_ISR
 USBFS_1_RESET_ISR:
_USBFS_1_RESET_ISR:
;   mov     [USBFS_1_Configuration], 0
;   mov     [USBFS_1_DeviceStatus], 0
;   mov     [USBFS_1_InterfaceSetting], 0
;   mov     [USBFS_1_EndpointStatus], 0
;   mov     [USBFS_1_TransferType], 0
;   mov     [USBFS_1_fDataPending], 0
;   mov     reg[USBFS_1_EP0MODE], USB_MODE_STALL_IN_OUT ; ACK Setup/Stall IN/OUT
;   mov     reg[USBFS_1_EP1MODE], 0
;   mov     reg[USBFS_1_EP2MODE], 0
;   mov     reg[USBFS_1_EP3MODE], 0
;   mov     reg[USBFS_1_EP4MODE], 0
;   mov     X, USB_MAX_EP_NUMBER       ; Set up loop to clear all of the endpoint data items
;.loop:
;   mov     [X + USBFS_1_EPDataToggle], 0  ; Or in the toggle
;   dec     X                          ; Are we done?
;   jnz     .loop                      ; Jump to do another endpoint    

;   mov     reg[USBFS_1_ADDR], USB_ADDR_ENABLE ; Enable Address 0

   ;@PSoC_UserCode_BODY_USB_RESET@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers.

STD_USB_RESET:    EQU     1 ; Set this equate to 0 to remove the standard
                            ; USB reset handling code below

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

IF  STD_USB_RESET
	push 	A
	push    X
	M8C_SetBank1
	mov		A, reg[USBFS_1_USB_CR1]		        ; Get the RegEnable
	M8C_SetBank0
	and 	A, 0x01					                     ; mask off the RegEnable bit
	mov		X, A					                        ; save value in X
    MOV     A, [USBFS_1_bCurrentDevice]     ; Select the current device
	LCALL   _USBFS_1_Start     ; Restart USB
    POP X
    POP A
		
ENDIF

	RETI
	
	
	
 USBFS_1_SOF_ISR:
_USBFS_1_SOF_ISR:

   ;@PSoC_UserCode_BODY_6@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers.

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

   reti

 USBFS_1_WAKEUP_ISR:
_USBFS_1_WAKEUP_ISR:

   ;@PSoC_UserCode_BODY_7@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers.

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

   reti

; End of File USBFS_1.asm

⌨️ 快捷键说明

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