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

📄 usb_id_key.asm

📁 USB ID KEY 通过USB口送数据给pc自动弹网页
💻 ASM
📖 第 1 页 / 共 5 页
字号:

;  	Revision History
;  	Product Name: TX9177
;	Version: 1.0
; 	Created by:  	Jerry Ho
;	Release Date:	2004/02/03
;	Checksum: 2B1Ah
;	Program Counter Maximum : 1822h (6178)
;	Real Program Counter    : 0EA5h (3749)

;	Modified Description:
;	1.New matrix of key scan.

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

;  	Revision History
;  	Product Name: TX9177
;	Version: 1.1
; 	Created by:  	Jerry Ho
;	Release Date:	2004/07/01
;	Checksum: 359Fh
;	Program Counter Maximum : 1822h (6178)
;	Real Program Counter    : 0EA8h (3752)

;	Problem:
;	1.NSTL USB IF test fail.

;	Modified Description:
;	1.Rc0Rdy changed or removed position.
;	2.Added 5 ms delay at power-on at TX0Task.

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

;  	Revision History
;  	Product Name: TX9177
;	Version: 1.2
; 	Created by:  	Jerry Ho
;	Release Date:	2004/09/13
;	Checksum: 3526h
;	Program Counter Maximum : 1822h (6178)
;	Real Program Counter    : 0EA8h (3758)

;	Problem:
;	1.NSTL Comparability test MAC IBook G4 fail.
;	2.Suspend mode all of keys must wake PC up.

;	Modified Description:
;	1.System reset first delay from 450ms to 200ms.
;	2.Modified suspend task.

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

;  	Revision History
;  	Product Name: TX9177
;	Version: 1.3
; 	Created by:  	Jerry Ho
;	Release Date:	2004/10/14
;	Checksum: 39EAh
;	Program Counter Maximum : 1822h (6178)
;	Real Program Counter    : 0EB6h (3766)

;	Problem:
;	1.NSTL Comparability test that kb into suspend mode can't resume when push button one time at EPSON NB. 

;	Modified Description:
;	1.Modified KB resume siginal time to 10ms.

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




;==================================================================================================
;
;       Include Definitions
;
;==================================================================================================



;==================================================================================================
;
;       Register Definitions
;
;==================================================================================================

;--------F-Plane Register Files---------------------------------------

Indf    	equ     00h
Timer0		equ 	01h
Pc		equ 	02h
Psw		equ	03h
Status		equ	03h
Fsr 		equ 	04h	;file select register bit6 ~ bit0
Pae     	equ 	05h 	;port a output enable bit7 ~ bit4  1:out  0:in
Pad		equ 	05h	;port a output data   bit3 ~ bit0
Pbd		equ 	06h	;port b output data   bit3 ~ bit0
Led		equ 	07h	;led output
Ksol		equ 	08h	;key scan output[07 ~ 00]
Ksoh		equ 	09h	;key scan output[15 ~ 08]
Ksi		equ 	0ah	;key scan input[07 ~ 00]  //R
Pdd       	equ     0dh	; PD Direct
Gpr0		equ 	0eh	;general purpose register0
Gpr1  		equ 	0fh	;general purpose register1
UsbFun		equ 	10h 	;USB function address bit6 ~ bit0 bit7 is USB function enable
Int0		equ	11h
Int1		equ	12h
Int2		equ	13h
UsbCtr		equ	13h
Rc0Cnt		equ 	14h 	;received data byte count bit3 ~ bit0
Tx0Reg		equ	15h
Tx0Cnt  	equ 	15h 	;endpoint 0 transmit byte count bit3 ~ bit0
Tx1Reg  	equ 	16h 
Tx1Cnt  	equ 	16h 	;endpoint 1 transmit byte count bit3 ~ bit0   	   		
Rc0Fifo		equ	18h	;18h ~ 1fh endpoint 0 receive buffer(8 bytes) 
				;definitions for SETUP packets
Rc0Fifo0	equ	18h	

;--------R-Plane Register Files---------------------------------------
	
Tm0Reload	equ 	01h	;Timer0 overflow reload value   
Tm0Pscl 	equ 	02h 	;Timer0 Pre-Scale, 0:div2,7:div256,8:div1
PwrDown 	equ 	03h 	;write this register to enter Power-Down Mode
WdtEn    	equ 	04h 	;write this register to clear WDT and enable WDT
KbdMask 	equ 	05h 	;mask KSI[7:0] interrupt function while the corresponding bit is "1"
PDMODE03  	equ	0ch
TestReg 	equ 	0fh 	;Test Mode option
IntEn0		equ	11h
IntEn1		equ	12h
Tx0Fifo 	equ 	18h 	;18h ~ 1fh endpoint 0 transmit buffer(8 bytes)
Tx0Fifo0	equ	18h
Tx0Fifo1	equ	19h
Tx0Fifo2	equ	1ah
Tx0Fifo3	equ	1bh
Tx0Fifo4	equ	1ch
Tx0Fifo5	equ	1dh
Tx0Fifo6	equ	1eh
Tx0Fifo7	equ	1fh
Tx1Fifo 	equ 	20h 	;20h ~ 27h endpoint 1 transmit buffer(8 bytes)
Tx1Fifo0	equ	20h
Tx1Fifo1	equ	21h
Tx1Fifo2	equ	22h
Tx1Fifo3	equ	23h
Tx1Fifo4	equ	24h
Tx1Fifo5	equ	25h
Tx1Fifo6	equ	26h
Tx1Fifo7	equ	27h
;Tx2Fifo 	equ 	28h	;28h ~ 2fh endpoint 2 transmit buffer(8 bytes)
;Tx2Fifo0	equ	28h
;Tx2Fifo1	equ	29h
;Tx2Fifo2	equ	2ah
;Tx2Fifo3	equ	2bh
;Tx2Fifo4	equ	2ch
;Tx2Fifo5	equ	2dh
;Tx2Fifo6	equ	2eh
;Tx2Fifo7	equ	2fh

;==================================================================================================
;
;       Define Bit Definitions
;
;==================================================================================================

;--------F-Plane Register Files---------------------------------------

RomPage 	defstring 	03h,6
RamBank 	defstring 	03h,4
Zero		defstring 	03h,2
DCarry 		defstring 	03h,1
Carry  		defstring 	03h,0

Data		defstring 	06h,2
Clock		defstring 	06h,3

UsbEn		defstring 	10h,7

Rc0i		defstring 	11h,7 	;endpoint 0 receive interrupt flag,write 0 to clear flag
Tx0i		defstring 	11h,6 	;endpoint 0 transmit interrupt flag,write 0 to clear flag
Tx1i		defstring 	11h,5 	;endpoint 1 transmit interrupt flag,write 0 to clear flag 
Tx2i		defstring 	11h,4 	;endpoint 2 transmit interrupt flag,write 0 to clear flag
Rsti		defstring 	11h,3 	;usb bus reset interrupt flag,write 0 to clear flag
Suspi  		defstring 	11h,2 	;usb suspend interrupt flag,write 0 to clear flag

Rsmi		defstring 	12h,3 	;usb resume interrupt flag,write 0 to clear flag
Kbdi		defstring 	12h,2 	;keyboard interrupt flag,write 0 to clear flag
Pb0i		defstring 	12h,1 	;mouse interrupt flag,write 0 to clear flag
Tm0i		defstring 	12h,0 	;timer0 interrupt flag,write 0 to clear flag

Suspend		defstring 	13h,7 	;s/w force usb interface into suspend mode
Resume		defstring 	13h,6 	;s/w force usb interface send RESUME signal in suspend mode
Ep1Cfg		defstring 	13h,5 	;set endpoint 1 configed
CtrRdy		defstring 	13h,3 	;H/W will stall an invalid out token during control read transfer 
Rc0Rdy 		defstring 	13h,0 	;endpoint 0 ready for receive,clear by H/W while RC0I occurs

Rc0Tgl 		defstring 	14h,7 	;1:received DATA1 packet; 0:received DATA0 packet  //R
Rc0Err  	defstring 	14h,6 	;endpoint 0 received data error                    //R
Ep0Dir		defstring 	14h,5 	;1:in transfer; 0:out/setup transfer               //R
Ep0Set  	defstring 	14h,4 	;SETUP Token indicator                             //R

Tx0Rdy		defstring 	15h,7 	;endpoint 0 ready for transmit,clear by H/W while TX0I occurs
Tx0Tgl		defstring 	15h,6 	;endpoint 0 transmit DATA1/DATA0 packet
Ep0Stall 	defstring 	15h,5 	;endpoint 0 will stall OUT/IN packet

Tx1Rdy		defstring 	16h,7 	;endpoint 1 ready for transmit,clear by H/W while TX1I occurs
Tx1Tgl		defstring 	16h,6 	;endpoint 1 transmit DATA1/DATA0 packet
Ep1Stall 	defstring 	16h,5 	;endpoint 1 will stall IN packet


;--------R-Plane Register Files---------------------------------------

Rc0ie   	defstring 	11h,7 	;RC0I interrupt enable 	
Tx0ie		defstring 	11h,6 	;TX0I interrupt enable 
Tx1ie		defstring 	11h,5 	;TX1I interrupt enable  
Rstie		defstring 	11h,3 	;RSTI interrupt enable 
Suspie 		defstring 	11h,2 	;SUSPI interrupt enable 


;--------Gpr0 Bit Definitions------------------------------

NewAdrFlag  		defstring 	0eh,7 	;
TableSelBit		defstring 	0eh,6 	;				
host_send_data		defstring 	0eh,5 	;
lastshowled_0		defstring 	0eh,4 	;
midshowled		defstring 	0eh,3 	;
lastshowled		defstring 	0eh,2 	;
senddatm		defstring 	0eh,1 	;
usbshowled		defstring 	0eh,0 	;		

;--------Gpr1 Bit Definitions------------------------------

SuspendFlag		defstring 	0fh,7 	;
Rc0Flag			defstring 	0fh,6 	;
Tx0Flag			defstring 	0fh,5 	;
keyup 			defstring 	0fh,4 	;
keyup_0			defstring	0fh,3
keyup_1			defstring	0fh,2
usbdelaytime		defstring	0fh,1
usbdelaytime_0		defstring	0fh,0


;==================================================================================================
;
;       Constant Definition
;
;==================================================================================================

;------------------------------------------------------------------------
; Normal Constant Definition
;------------------------------------------------------------------------

W              	equ     00h
F               equ     01h

UsbKeyboard	equ	00h
Ps2Keyboard	equ	01h

ScanInterval	equ	17h		;17h=4ms

;------------------------------------------------------------------------
; For USB Constant Definition
;------------------------------------------------------------------------

;--------Rc0Fifo Types Files-----------------------------------------

BmRequestType	equ  	18h
BRequest        equ  	19h
WValue          equ  	1ah    	;default wValue (8-bits)
WValueHi        equ  	1bh
WIndex          equ  	1ch    	;default wIndex (8-bits)
WIndexHi        equ  	1dh
WLength         equ  	1eh    	;default wLength (8-bits)
WLengthHi       equ  	1fh        	   		
           	   	
;--------Define BmRequestType Types Files----------------------------

HostToDevice	equ	00h
HostToInterface	equ	01h
HostToEndpoint	equ	02h
DeviceToHost	equ	80h
InterfaceToHost	equ	81h
EndpointToHost	equ	82h

;--------Define BRequest Types Files---------------------------------

GetStatus		equ	00h 
ClearFeature		equ	01h
;GetIdle		equ	02h                
SetFeature      	equ	03h 
SetAddress      	equ	05h 
GetDescriptor   	equ	06h 
GetConfiguration        equ	08h 
SetConfiguration        equ	09h 
GetInterface            equ	0ah 
SetInterface            equ	0bh 

;--------Standard Descriptor Types-----------------------------------

Device         	equ   	01h
Configuration   equ  	02h
String          equ   	03h
Interface       equ   	04h
Endpoint       	equ   	05h
HidClass	equ	21h
HidReport	equ	22h

String0		equ	00h
String1		equ	01h
String2		equ	02h
String3		equ	03h

Report1		equ	00h
Report2		equ	01h

;------------------------------------------------------------------------
; For HID Constant Definition
;------------------------------------------------------------------------

;-class specific descriptor types from section 7.1 Standard Requests-

HidGetRequest  	equ  	a1h
HidSetRequest	equ	21h
             
;-class specific request codes from section 7.2 Class Specific Requests

GetReport    	equ   	01h
GetIdle      	equ   	02h
GetProtocol  	equ  	03h
SetReport    	equ   	09h
SetIdle      	equ   	0ah
SetProtocol  	equ   	0bh

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

UnConfig		equ	00h
Config			equ	01h

LedValue		equ	02h
StallValue		equ	01h

DisableRemoteWakeup	equ	00h
EnableRemoteWakeup	equ	02h

Endpoint0		equ	80h
Endpoint1		equ	81h
Endpoint2		equ	82h

Interface1		equ	00h
Interface2		equ	01h

BootProtocol		equ	00h
ReportProtocol		equ	01h

SystemKeyID		equ	02h

DeviceLen		equ	12h
ConfigLen		equ	3bh
String0Len		equ	04h
String2Len		equ	1ah
HidReport1Len		equ	41h
HidReport2Len		equ	73h
HidClassLen		equ	09h

DefaultIdlePeriod	equ	7dh

ReportID2		equ	02h
ReportID3		equ	03h
KeyboardReport		equ	01h
LedReport		equ	02h

;------------------------------------------------------------
; For PS/2 Constant Definition
;------------------------------------------------------------

;Ps2Enable		equ	10h
;Ps2Disable		equ	00h
;BatPass			equ	aah
;BatFail			equ	55h
;Ps2ResendByte		equ 	feh
;Ps2EchoByte		equ	eeh
;Ps2AckByte		equ	fah			
;ScanSet1		equ	01h
;ScanSet2		equ	02h
;ScanSet3		equ	03h
;Ps2BufferLength		equ	20h	;32 bytes
;DefaultTypeRepeat	equ	025d
;DefaultTypeDelay	equ	128d
;Ghost500msTimeout	equ	125d
;Ghost750msTimeout	equ	188d

;Typematic		equ	00h
;MakeBreak		equ	01h
;Make			equ	02h
;TypematicMakeBreak	equ	03h

;ScanSet3BufferSize	equ	34d

;--------Used for Ps2KeyFlags & Ps2KeyLastFlags--

;Ps2KeyOverflow		equ	00h
;Ps2KeyExtended		equ	01h
;Ps2KeyMake		equ	02h
;;Ps2KeyGhost		equ	04h

;-----------------------------------------------------------
; For Keyboard Constant Definition
;-----------------------------------------------------------

UsbNoReport		equ	00h
UsbReportError		equ	01h
UsbReportKey		equ	02h

DebounceBufferEmpty	equ	ffh

DebounceTimes		equ	06h
KeyboardColumns		equ	12h
KeyPress		equ	ffh
KeyRelease		equ	00h

LedMask			equ	07h

;--------LED positions in LED Port-------------------------

ScrollLockLed:   	equ     01h
NumLockLed:     	equ     02h
CapsLockLed		equ     04h

;-------- Rambank0 Register Files (20h~7fh)----------------

;================== For USB Only===========================

StateTemp0		equ	20h
StateTemp1		equ	21h
Temp0			equ	22h
WLengthTemp		equ	23h
LengthCnt		equ	24h
TableCnt		equ	25h
DataLength		equ	26h
RemoteWakeupStatus	equ	27h
ConfigurationStatus	equ	28h
Endpoint1Status		equ	29h
Endpoint2Status		equ	2ah
HidProtocolStatus	equ	2bh
IdlePeriodStatus	equ	2ch
UsbPutKeyCount		equ	2dh
UsbRequireState		equ	2eh
UsbUsageTemp		equ	2fh

IdlePeriodTemp		equ	30h
UsbLedDataTemp		equ	31h
UsbResumeCount		equ	32h
;============================================================
send_08_15		defstring	3eh,0
send_08_15_0		defstring	3eh,1

;============================================================
usbkeyled		equ	35h
usbkeyled_0		equ	36h
delay			equ	40h		;40h~47h
delay_0			equ	41h
delay_1			equ	42h
;UsbKeyBuffer3		equ	43h
;UsbKeyBuffer4		equ	44h
;UsbKeyBuffer5		equ	45h
;UsbKeyBuffer6		equ	46h
;UsbKeyBuffer7		equ	47h

;================== For PS2 Only===========================

DelayCount_us		equ	20h
DelayCount_ms		equ	21h
;Ps2ByteCount		equ	22h	
;Ps2ParityTemp		equ	23h
;Ps2LastData		equ	24h
;Ps2HoldToSendData	equ	25h
;Ps2Set3CommandTemp	equ	26h	
;Ps2LedDataTemp		equ	27h
;Ps2SendTemp1		equ	28h
;Ps2SendTemp2		equ	29h
;Ps2KeyTypematicTemp	equ	2ah
;Ps2KeyScanSet		equ	2bh
;Ps2KeyGhostCounter	equ	2ch
;Ps2KeyAnyCount		equ	2dh
;Ps2KeyPutCodeTemp	equ	2eh
;Ps2KeyPutCharTemp	equ	2fh

;Ps2KeyFlags		equ	30h
;Ps2KeyLastFlags		equ	31h
;Ps2KeyInptr		equ	32h
;Ps2KeyOldInptr		equ	33h
;Ps2KeyOutptr   		equ	34h
;Ps2KeyKeyCount         	equ	35h
;Ps2KeyOldKeyCount    	equ	36h
;Ps2KeyModifyByte	equ	37h
;Ps2KeyTypematicCount	equ	38h
;Ps2KeyTypematicDelay	equ	39h
;Ps2KeyTypematicRepeat	equ	3ah
;Ps2KeyTypematicKey	equ	3bh			

;================== For Keyboard Scan Only ================

InterfaceTypeTemp	equ	48h     
PutIndexCodeTemp	equ	49h     
PutIndexCodeTemp1	equ	4ah   
ColCountTemp		equ	4bh     
RowCountTemp		equ	4ch     
ScanDataTemp		equ	4dh     
MatrixIndexTemp		equ	4eh     		
ScanHitTemp		equ	4fh			
					     		
PhantomTemp		equ	50h     
ColHitTemp		equ	51h     		
RowHitTemp		equ	52h     		
AllHitTemp		equ	53h			
KeyChangeTemp		equ	54h			
ColIndexTemp		equ	55h     		
RowIndexTemp		equ	56h			
MatrixAddr		equ	57h			
KeyUpDown		equ	58h	
AnyDataTemp		equ	59h		
AnyCountTemp		equ	5ah	
;KsolTemp		equ	5bh	
;KsohTemp		equ	5ch	
PadTemp			equ	5dh     
UsbLastKeyState		equ	5eh	
UsbCurrentState		equ	5fh  
   
ModBitTemp		equ	60h
ModByteTemp		equ	61h
DebounceKeyBuffer	equ	62h		;(62h~67h)
DebounceKeyBuffer0	equ	62h
DebounceKeyBuffer1	equ	63h
DebounceKeyBuffer2	equ	64h
DebounceKeyBuffer3	equ	65h
DebounceKeyBuffer4	equ	66h
DebounceKeyBuffer5	equ	67h

DebounceTimeBuffer	equ	68h		;(68h~6dh)

ColumnBuffer		equ	6eh		;6eh~7fh

;-------- Rambank1 Register Files (20h~7fh)---------------------------

ScanSet3Buffer		equ	20h		;20h~41h
ScanSet3BufferCount	equ	42h
ScanSet3BufferTemp	equ	43h
ScanSet3AnyTemp		equ	44h

Ps2KeyBuffer		equ	60h		;60h~7fh

;==============================================================================
;Macro:Delay_us Macro Files
;
;
;==============================================================================

Delay_us   .MAC   Time            ;Delay "Cycles" instruction cycles 

  .IF (Time+0=1)
  	goto $ + 1
        nop 
        .EXITMAC 
  .ENDIF 
  
  .IF (Time+0=2)
  	goto $ + 1
        goto $ + 1 
        nop
        .EXITMAC 
  .ENDIF 
  
  .IF (Time+0=3)
        goto $ + 1
        goto $ + 1
        goto $ + 1
        goto $ + 1
        .EXITMAC 
  .ENDIF 
  
  .IF (Time+0=4) 
        goto $ + 1 
        goto $ + 1
        goto $ + 1
        goto $ + 1
        goto $ + 1
        nop
        .EXITMAC 
  .ENDIF 
  
  .IF (Time+0=5)
  	goto $ + 1
  	goto $ + 1
  	goto $ + 1
  	goto $ + 1
        goto $ + 1
        goto $ + 1
        goto $ + 1
        .EXITMAC 
  .ENDIF 
  
  .IF (Time+0=6) 
        goto $ + 1
        goto $ + 1
  	goto $ + 1
  	goto $ + 1
  	goto $ + 1
  	goto $ + 1
  	goto $ + 1 
    	goto $ + 1
        .EXITMAC 
  .ENDIF 
  
  .IF (Time+0=7)
  	goto $ + 1
  	goto $ + 1
  	goto $ + 1
        goto $ + 1
  	goto $ + 1
  	goto $ + 1
        goto $ + 1
        goto $ + 1
        nop
        .EXITMAC 

⌨️ 快捷键说明

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