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

📄 mouseisr.asm

📁 mcs51,2051,x86系列MCU
💻 ASM
字号:
TITLE "MOUSEISR.ASM"
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;   File:        mouseisr.asm
;   Author:      Steve Roberts    8/2/96
;   Description: Converts Microsoft serial mouse signals to USB format
;                and stores them in the MOUSE BUFFER.  The buffer
;                contents will eventually be written to the TXFIFO when
;                a TXD interrupt is received.  If the buffer is empty,
;                the first mouse report seen here will call the 
;                "MOUSE REPORT GENERATOR" which automatically loads
;                the TXFIFO with this new report.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include externs.inc
include donconst.inc
include 82930.inc

extern MOUSE_REPORT_GENERATOR

define MOUSE_ISR_VECTOR,SPACE=CODE, ORG=004023h   ;For Debugger
segment MOUSE_ISR_VECTOR
    ljmp    MOUSE_ISR

;define MOUSE_ISR_VECTOR,SPACE=CODE, ORG=FF0023h  ;For Flash
;segment MOUSE_ISR_VECTOR
;    ljmp   MOUSE_ISR


define MOUSEISR,SPACE=CODE
segment MOUSEISR

MOUSE_ISR:
    push  PSW
    push  PSW1
    push  WR30
    push  WR10 
    push  WR12
    push  R0                      

    jb    RI, RCV_READY           ; Go receive.
    clr   TI                      ; It was just a transmit

                                  ; This should never happen...
    mov   P1, #012h               ; Debug display LEDs
    jmp   EXIT_MOUSE_ISR

RCV_READY:
    clr   RI
    mov   R0, SBUF
    cmp   R0, #0CDh               ; Upon power up, mouse sends CD hex
    je    EXIT_MOUSE_ISR          ; This byte must be ignored

    mov   P1, R0                     ; Send char to LEDs

    mov   R10, MOUSE_BUFFER_WOFFSETH ; Get offset to free loc. in Mouse buffe
    mov   R11, MOUSE_BUFFER_WOFFSETL ; H & L needed since "dw" not allowed
                                     ; in variable declaration (only "ds")
    mov   WR30, #MOUSE_BUFFER        ; Get address of start of Mouse buffer
    add   WR30, WR10                 ; Add offset to first empty location

    mov   @WR30, R0                  ; Store byte recd. in Buffer

    inc   WR10, #01h
    anl   WR10, #RINGWORDMASK        ; Sets Write offset to beginning if full
    mov   MOUSE_BUFFER_WOFFSETH, R10 ; Update the buffer end
    mov   MOUSE_BUFFER_WOFFSETL, R11

    mov   R10, MOUSE_DATA_COUNTH     ; Increment MOUSE_DATA_COUNT
    mov   R11, MOUSE_DATA_COUNTL
    inc   WR10, #01h
    mov   MOUSE_DATA_COUNTH, R10
    mov   MOUSE_DATA_COUNTL, R11

    cmp   WR10, #MOUSE_DATA_LENGTH   ; Make sure 3 bytes are avail
    jl    EXIT_MOUSE_ISR
    setb  EPCON3.1                   ; Enables TX on EP3.  This may have
                                     ; been clr'd by an IDLE req 

INITIAL_REPORT_CHECK:      ; If buffer is empty, need to call the
                           ; REPORT_GENERATOR in repreqisr.asm to
                           ; fill the TXFIFO1 (otherwise, NACK sent)

    mov   R10, MOUSE_BUFFER_ROFFSETH
    mov   R11, MOUSE_BUFFER_ROFFSETL   ; Read will be three positions
    add   WR10, #3                     ; behind write if it was empty
    anl   WR10, #RINGWORDMASK          ; Rollover to beginning of buffer
    mov   R12, MOUSE_BUFFER_WOFFSETH   ; if full
    mov   R13, MOUSE_BUFFER_WOFFSETL
    cmp   WR10, WR12
    jne   EXIT_MOUSE_ISR
   
    lcall MOUSE_REPORT_GENERATOR


EXIT_MOUSE_ISR:
    pop    R0
    pop    WR12
    pop    WR10
    pop    WR30
    pop    PSW1
    pop    PSW
      
    reti

⌨️ 快捷键说明

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