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

📄 macros.inc

📁 CY7C63743 usb键盘的源码
💻 INC
字号:
;========================================================================
;   FILE: macros.inc 
;
;   contains useful macro definitions
;
;========================================================================
    ;clear bit(s) in a RAM location
    MACRO CLRBIT BIT REG
    mov A,~BIT
    and [REG],A
    ENDM

    ;set bit(s) in a RAM location
    MACRO SETBIT BIT REG
    mov A,BIT
    or  [REG],A
    ENDM
  
    ;test bit(s) in a RAM location
    MACRO TSTBIT BIT REG
    mov A,BIT
    and A,[REG]
    ENDM

    ;clear carry
    MACRO CLEARC
    or    A,0
    ENDM

    ;set carry
    MACRO SETC
    cpl   A
    cpl   A
    ENDM


    ;macro for clearing blocks of RAM
    ;destroys X and A
    MACRO   CLEARRAM base,length
    mov     X,length - 1
    mov     A,0
lp:
    mov     [X + base],A
    dec     X
    jnc     lp
    ENDM


    ;macro for packing 4 2-bit fields into a byte

    MACRO TYPE a,b,c,d
        db  (a + b*4 + c*16 + d*64)
    ENDM


    ;delay macro is the front-end for a call to the delay subroutine
    ;The fixed overhead of the macro plus the subroutine is 3 us,
    ;so this technique is good for delays of 4us or greater.
    ;

    MACRO DELAY US
    push    A
    mov     A,(US-3)
    call    delay
    ENDM
;*****
; CLRC
;	Clears C bit
;*****
MACRO CLRC
	add	A,0	;Clear C-bit
			;*** END MACRO CLRC
ENDM


;*****
; SETFLAG	F
;	Sets flag F in mouse_flagsV
;*****
MACRO SETFLAG F
	mov	a,F			;a <- F bit
	or	[mouse_flagsV],a	;set flag
					;*** END MACRO SETFLAG
ENDM


;*****
; CLRFLAG F
;	Clear flag F in mouse_flagsV
;*****
MACRO CLRFLAG F
	mov	a,~F			;a <- F mask
	and	[mouse_flagsV],a	;clear flag
					;*** END MACRO CLRFLAG
ENDM


;*****
; CHKFLAG F
;	Check flag F in mouse_flagsV
;*****
MACRO CHKFLAG F
	mov	a,F			;a <- F flag
	and	a,[mouse_flagsV]	;isolate flag
					;*** END MACRO CHKFLAG
ENDM


;*****
; CPLFLAG F
;	Complement flag F in mouse_flagsV
;*****
MACRO CPLFLAG F
	mov	a,F			;a <- F flag
	xor	[mouse_flagsV],a	;toggle flag
					;*** END MACRO CPLFLAG
ENDM


;=============================================================================
; PS2_WR_PORT3
;	Replaces "iowr IO_mouse_port" instruction to the following lines of
;	code. Makes writes to bit 6 and 7 of Port3 not affecting other bits
;	which are used for keyboard LED and scan matrix columns.
;	Assumes the data to be written is in register A.
;=============================================================================
MACRO PS2_WR_PORT3
	and A, P3_PS2_MASK		; clear all bits except bit 6 and 7
	mov [ps2_tmp], A		; move write data to a temporary variable
	mov A,[ksc_p3out]			; read current content of port 3
	and A, ~P3_PS2_MASK		; reset bit 6 and 7
	or A, [ps2_tmp]			; or current port 3 data with the write data
	iowr IO_mouse_port
	mov [ksc_p3out], A			; store most recent data back to p3out
	
ENDM
MACRO enable_1ms_int
    iord    Global_Interrupt
	or		A,  TIMER_ISR_MASK		; enable 1ms interrupt
	iowr	Global_Interrupt
ENDM
MACRO disable_1ms_int:
    iord    Global_Interrupt
	and		A, ~TIMER_ISR_MASK		                    ; enable 1ms interrupt
	iowr	Global_Interrupt
ENDM


MACRO enable_EP0_int
    mov     A,[configuration_status]
    cmp     A,UNCONFIGURED
    mov     A,ENDPOINT_ZERO
    jz      .exit
    or      A,(ENDPOINT_ONE + ENDPOINT_TWO)
.exit:
    iowr    ENDPOINT_INTERRUPT_REG
ENDM
MACRO disable_EP0_int
    mov     A,[configuration_status]
    cmp     A,UNCONFIGURED
    mov     A,0
    jz      .exit
    or      A,(ENDPOINT_ONE + ENDPOINT_TWO)
.exit:
    iowr    ENDPOINT_INTERRUPT_REG
ENDM

⌨️ 快捷键说明

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