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

📄 usb.asm

📁 CY7C63743 usb键盘的源码
💻 ASM
字号:
        CPU 63413
label:          XPAGEON

;========================================================================
;   FILE: usb.asm 
;
;   This file includes all the files necessary to build a usb keyboard
;   executable.  
;
;========================================================================


;include all "inc" files used by the code

    include "regs.inc"
    include "usb.inc"
    include "macros.inc"
    include "at101.inc"
    include "portdef.inc"




PS2_KEYBOARD:   equ 0               
USB_KEYBOARD:   equ 1
;we need to use the endpoint 2 normally used for the mouse, to report
;power key usages. So, the following equate will enable endpoint 2 interrupts
;even though we are not using mouse code.
EP_INTERRUPTS: equ KEYBOARD_PLUS_MOUSE

;========================================================================
;  interrupt vector table -- must be located here
;========================================================================

    ORG     00h

    jmp     sys_reset               ; reset vector

    jmp     USB_Bus_Reset_ISR       ; USB bus reset

    jmp     illegal_int             ; 128us interrupt

    jmp    dual_ifc_1ms_ISR           ; 1.024ms interrupt

    jmp     USB_EP0_ISR             ; endpoint 0 interrupt

    jmp     USB_EP1_ISR             ; endpoint 1 interrupt

    jmp	USB_EP2_ISR			; endpoint 2 interrupt

    jmp     illegal_int             ; reserved interrupt

    jmp     illegal_int             ; reserved interrupt

    jmp     illegal_int             ; reserved interrupt

    jmp     DAC_ISR                 ; DAC interrupt

    jmp     GPIO_ISR                ; GPIO interrupt

    jmp     illegal_int             ; reserved interrupt

;========================================================================
;
;   FUNCTION: dual_ifc_1ms_ISR
;
;   purpose:    
;   provides the entry point for the 1 millisecond tick.
;   This ISR entry point jumps to the USB 1msec ISR.
;
;
;========================================================================
dual_ifc_1ms_ISR:
    ei                              ;allow nesting
    push    A                       ;save A
    jmp     One_mSec_ISR            ;go direct to USB ISR

;========================================================================
;
;   FUNCTION: sys_reset
;
;   purpose:    
;   reset entry point for code
;
;
;========================================================================


illegal_int:
sys_reset:
    di                                        ;disable interrupts   
    mov       A,0ffh 
    iowr      PORT3_DATA_REG
    mov        A,NORMAL                        ;configure GPIO reg
    iowr     GPIO_CONFIG_REG
    mov     A,~P3_USB_CONN_MASK             ;drive connect bit low
    iowr    PORT3_DATA_REG



    mov     a,0                             ;set psp stack to 0
    mov     psp,a                           ; 
    mov     a,0ffh                          ;set dsp stack to 0xff
    swap    a,dsp                           ;now we can call functions

    mov     A,0                             ;zero endpoint interrupt reg
    iowr    ENDPOINT_INTERRUPT_REG            
    mov     A,USB_KEYBOARD
    mov     [dual_ifc_keyboard],A           

   jmp      Reset                          ;go straight usb
.bummer:
    jmp     .bummer                         ;loop if we ever get here


; the dsp will remain at 0 for both ps2 and usb. Allow 30h bytes for it.

dsp_stack_size:                 equ     30h

; the psp will start at 0xff for ps2 and 0xe0 for usb (to avoid the
; USB queues)

psp_stack_size:                 equ     30h

ram_base:                       equ     psp_stack_size  ;application ram start
dual_ifc_keyboard:              equ     ram_base        ;keyboard type
dual_ifc_1ms:                   equ     ram_base+1      ;1msec counter
usbmain_ram_base:               equ     ram_base+2      ;start of usb main ram
;ps2main_ram_base:               equ     ram_base+2      ;and ps2 ram also

;include all code which resides in lower 4k now.

include "usbmain.asm"
;use the descriptor file that includes a description of the 2nd endpoint,
;which we'll need here because we're using the 2nd endpoint to report power
;key usage codes.

include "kbm_desc.asm"

;stub out ps2 key code, it's not in this build
ps2key_putkey:
ret


usbkey_ram_base:            equ     (usbmain_ram_base + USBMAIN_RAM_SIZE)
include    "usbkey.asm"
;note: usb_ram_end MUST compute to less than 0x70h (see note below).
usb_ram_end:                equ     (usbkey_ram_base + USBKEY_RAM_SIZE)
;
;due to a restriction on the USB code, we cannot use RAM from 070h to 07fh.
;locate the ram used by keyscan.asm at 080h to avoid this region.
;

ksc_ram_base:               equ     080h
include "keyscan.asm"
include "matrix.asm"

;locate mouse RAM after ksc RAM, and include mouse code in upper 4k.
mouse_RAM_baseC:	equ	(ksc_ram_base + KSC_RAM_SIZE)
include "kbm_stub.asm"





;define some constants which are not used but will show up in the
;listing file in a contiguous block so that we can easily examine the
;ram usage for the project in the listing file.


AAE_RAM_USB_START:      equ     usbmain_ram_base
AAF_RAM_USB_END:        equ     usbmain_ram_base + USBMAIN_RAM_SIZE- 1
AAG_RAM_USB_START:      equ     usbkey_ram_base
AAH_RAM_USB_END:        equ     usbkey_ram_base + USBKEY_RAM_SIZE - 1

AAI_RAM_KSC_START:      equ     ksc_ram_base
AAJ_RAM_KSC_END:        equ     ksc_ram_base + KSC_RAM_SIZE - 1




⌨️ 快捷键说明

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