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

📄 cls1.asm

📁 基于HT82K96E的usb鼠标实现源程序
💻 ASM
字号:
include			ht82k96e.inc
include			usbrf.inc	


extern			bcmd_index:bit
extern			baltkbprotocol	:bit
extern			baltmouseprotocol	:bit


extern			tempkbtime		:byte
extern			tempmousetime	:byte	
extern			tempkbtime_l	:byte	
extern			tempmousetime_l	:byte

extern			fifo_type		:byte	
extern			fifo_request	:byte
extern			fifo_windexl	:byte
extern			fifo_windexh 	:byte
extern			fifo_wvaluel 	:byte
extern			fifo_wvalueh	:byte
extern			fifo_wlengthh	:byte
extern			fifo_wlengthl	:byte

extern			int_temp2		:byte
extern			fifo_out1		:byte
extern			fifo_sendlen	:byte
extern			reportkbtime	:byte
extern			reportmousetime	:byte
extern			setrpt_no		:byte


extern			movekeyboarddata	:near
extern			exitext				:near
extern			tostallpipe0		:near
extern			sendfifoout			:near
extern			sendhandshake		:near
;extern			moveacpidata		:near
;extern			movemultidata		:near

temp			equ			int_temp2

cls1			.section  at 1cbh  'code'

;----- class-specific request -----------------------------------------------


setprotocol:	;
                ;not check bmrequesttype direction because wlength = 0
                ;sz      fifo_type.@setup_d    	;host to device ?
                ;jmp		tostallpipe0           ;no: to stall
                
                mov     a,fifo_wlengthl       	;length = 0
				add		a,fifo_wlengthh
				snz		z	
                jmp		tostallpipe0            ;no: to stall
             
                sz      fifo_wvalueh          	;wvalueh = 0 ?
                jmp		tostallpipe0            ;no: to stall

				sz		fifo_windexl
				jmp		tostallpipe0
				clr		baltkbprotocol
				sz		fifo_wvaluel
				set		baltkbprotocol
                jmp     sendhandshake           ;send handshake flag
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
getprotocol:
                ;check bmrequesttype direction
                snz     fifo_type.@setup_d    	;device to host ?
                jmp		tostallpipe0            ;no: to stall

                sz		fifo_wvaluel         	;default = 0 ?
				jmp		tostallpipe0
				sz		fifo_wvalueh
                jmp		tostallpipe0            ;no: to stall
                
				sz      fifo_wlengthh         	;length = 0
                jmp		tostallpipe0            ;no: to stall
                mov     a,fifo_wlengthl       	;length = 1 ?
                xor     a,01h                   ;
                snz     z                       ;
                jmp		tostallpipe0            ;no: to stall

				clr		acc
				sz		fifo_windexl
                jmp		tostallpipe0
				sz		baltkbprotocol
				set		acc.0
				jmp		reportvl

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
setidle:
;maybe need support
               	sz		fifo_wlengthl         ;length = 0
				jmp		tostallpipe0
				sz		fifo_wlengthh
                jmp		tostallpipe0            ;no: to stall
                							
				clr		tempkbtime
				clr		tempmousetime
				clr		tempkbtime_l
				clr		tempmousetime_l
	
				mov		a,offset reportkbtime
				sz		fifo_windexl			;0-kb,	1-mouse
                jmp		tostallpipe0 
write_idle_rate:
				mov		mp0,a			
              	mov     a,fifo_wvalueh          ;get particular report time
              	mov     r0,a              		;

   ;set particular report flag
               	jmp     sendhandshake          	;send handshake flag

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
getidle:		;report_id=0, 
                ;check bmrequesttype direction
                snz     fifo_type.@setup_d    	;device to host ?
                jmp		tostallpipe0            ;no: to stall

				sz		fifo_wvalueh
                jmp		tostallpipe0            ;no: to stall
              
				sz      fifo_wlengthh         	;length = 0
                jmp		tostallpipe0            ;no: to stall
                mov     a,fifo_wlengthl       	;length = 1 ?
                xor     a,01h                   ;
                snz     z                       ;
                jmp		tostallpipe0            ;no: to stall

				mov		a,reportkbtime			;kb
                sz		fifo_windexl			;0-kb, 1-mouse
				jmp		tostallpipe0
                jmp     reportvl                ;responde

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



get_kb_input:
;kb
				mov     a,fifo_wlengthl     	;check format no.
                xor     a,report_kb_size       	;
                snz     z                   	;
                jmp		tostallpipe0        	;
				call	movekeyboarddata
				mov		a,8
				jmp		reportl
;----------------------------------------------------------------------------

classrequest:
                mov     a,fifo_type
                and     a,setup_rev
                mov     temp,a
                sub     a,04h               ;over 4 item ?
                sz      c                   ;
                jmp		tostallpipe0        ;yes
                mov     a,temp
class_request_pcl_5:
                addm    a,pcl
                jmp		tostallpipe0        ;invalid device
                jmp     interfacerev        ;invalid interface
                jmp     tostallpipe0        ;endpoint
                jmp		tostallpipe0        ;invalid other

interfacerev:
				sz      fifo_windexh        ;high byte for endpoint == 0 ?
                jmp		tostallpipe0        ;no
				mov		a,fifo_windexl	
				sub		a,interface_no		;2
				sz		c
				jmp		tostallpipe0

;check brequest		
                mov     a,fifo_request    	;brequest
                sub     a,class_request_no  ;over 12 item ?
                sz      c                   ;
                jmp		tostallpipe0        ;yes
                mov     a,fifo_request
;!!!!! need in same page
class_cmd_pcl_13:
                addm    a,pcl
                jmp		tostallpipe0        ;0
                jmp     getreport           ;1
                jmp     getidle             ;2
                jmp     getprotocol         ;3
                jmp		tostallpipe0        ;4
                jmp		tostallpipe0        ;5
                jmp		tostallpipe0        ;6
                jmp		tostallpipe0        ;7
                jmp		tostallpipe0        ;8
                jmp     setreport           ;9
                jmp     setidle             ;a
                jmp     setprotocol         ;b

;////////////////////////////////////////////////////////////////////////////
;class specific request

reportvl:
                mov     fifo_out1,a       		;
                mov     a,kb_output_size       	;fifo data length = 1

reportl:
				jmp		sendfifoout
;                mov     fifo_sendlen,a    		;
;                jmp	    requestresponse     	;responde


;----------------------------------------------------------------------------

getreport:		;report_type, report_id=0, report_length 
				;no feature report
                ;check bmrequesttype direction
                snz     fifo_type.@setup_d    	;device to host ?
                jmp		tostallpipe0            ;no:error
               	mov     a,fifo_wvalueh        	;get report type (only 3 kind)
                sub     a,report_type_no	    ;over 4 item ?
                sz      c                       ;
                jmp		tostallpipe0            ;yes
                mov     a,fifo_wvalueh
get_report_pcl_5:
                addm    a,pcl
                jmp		tostallpipe0            ;no this report type
                jmp     getinputreport
                jmp     tostallpipe0
getfeaturereport:                               ;no support getfeaturereport
                jmp		tostallpipe0
;----------------------------------------------------------------------------
getinputreport:
                sz      fifo_wlengthh     		;wlength = 8 ?
                jmp		tostallpipe0        	;no
				
				mov		a,fifo_windexl
get_input_pcl_4:
				addm	a,pcl
				jmp		get_kb_input			;0
				jmp		tostallpipe0			;1
;----------------------------------------------------------------------------


setreport:		;report_type, report_id=0, 
                ;check bmrequesttype direction
				;no feature report, input report
                sz      fifo_type.@setup_d    	;host to device ?
                jmp		tostallpipe0            ;no:error
                mov     a,fifo_wvalueh        	;get report type (only 3 kind)
                sub     a,04h                   ;over 4 item ?
                sz      c                       ;
                jmp		tostallpipe0            ;yes
                mov     a,fifo_wvalueh
setreport_pcl_5:
                addm    a,pcl
                jmp		tostallpipe0            ;no this report type
                jmp		tostallpipe0            ;no support setinputreport

				inc		setrpt_no
				mov		a, 05h
				sub		a, setrpt_no
				sz		acc
				jmp		$+2
				nop
                jmp     setoutputreport
setfeaturereport:                               ;no support setfeaturereport
                jmp		tostallpipe0
setoutputreport:
				sz		fifo_windexl			;0-kb,	1-mouse
				jmp		tostallpipe0
;kb					
				sz      fifo_wlengthh         	;wlength = 1 ?
                jmp		tostallpipe0            ;no
                mov     a,fifo_wlengthl       	;1 byte report
                xor     a,kb_output_size    	;
                snz     z                       ;
    	        jmp		tostallpipe0            ;no
                set     bcmd_index    


                jmp     exitext        	                

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



public		classrequest
public		class_request_pcl_5
public		class_cmd_pcl_13
public		get_report_pcl_5
public		get_input_pcl_4
public		setreport_pcl_5
				end

⌨️ 快捷键说明

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