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

📄 io_scanwheel.asm

📁 電 熨 斗 程 序
💻 ASM
字号:
;==========================================================================================
;		     		    SH69P822
;
;	 (c) Copyright 2006-2007, Sino Wealth Microelectronics Corporation Limited
;		 	All Rights Reserved
;
; module name :	IO_ScanKey.asm			version : 3.0
; function    : 
; by	      : CLR
; in	      : 2006-11-10
;
;==========================================================================================
WHEEL_DEBOUNCE_TIMER	EQU			3/1		;3ms

;ClockWise:	11,01,00,10,11...
;AntiClockWise:	11,10,00,01,11...
;--------------------------------------------------------------------------------------
ScanWheelIO:
		andim		PIN_WHEEL_Cfg		,(WHEELA+WHEELB)^0x0f
		orim		PIN_WHEEL		,WHEELA+WHEELB
		nop
		nop
		nop
		nop
		nop
		nop
		nop
		nop
		nop
		nop
		lda		PIN_WHEEL		,0
		sta		zWheelTMP		,0
		andim		zWheelTMP		,WHEELA+WHEELB
		;----- Result save in zWheelTMP-------
		rtni		
;======================================================================================
;			ScanWheel
;======================================================================================	
ScanWheel:
		;whether ever get different Wheel value than the last Wheel state
		lda		zWdebounce		,0	
		;yes,check whether maintain stable
 		ba0		ContinueScanWheel	
 		;no,check whether get different Wheel value	
LookUpWheelState:					
		call		ScanWheelIO	
		eor		zWheelState		,0	
		;if different from the last stable state
		bnz		BeginScanWheel	
		;if equal to the last state		
	  	jmp		Finish_ScanWheel
BeginScanWheel:
		;save current state to zWheelState buffer
		lda		zWheelTMP			,0
  		sta		zWheelState		,0	
  		;----- Reload Debounce counter and clear debounce done flag -----
		ldi		zWheelPeriod		,WHEEL_DEBOUNCE_TIMER
		andim		zIntFlag		,1101b
		;----------------------------------------------------------------
		 ;mark ever get different Wheel value than the last Wheel state flag
		orim		zWdebounce	,0001b	
	  	jmp		Finish_ScanWheel               ;exit 	
ContinueScanWheel:
		call		ScanWheelIO	
		eor		zWheelState		,0
		;if different from the last stable state again
		bnz		BeginScanWheel
		;if still equal to the last state
DebounceScanWheel:
		;the Wheel state must be stable here
		lda		zIntFlag		,0
		ba1		$+2
		jmp		Finish_ScanWheel
		andim		zIntFlag		,1101b
		;Judge whether finish debouncing work.
		sbim		zWheelPeriod		,01h
		baz		VerifyWheelValue
	 	jmp		Finish_ScanWheel
VerifyWheelValue:
		andim		zWdebounce	,1110b
		;whether state chage?
		lda		zWheelTMP	,0
		eor		zWheelValue	,0
		baz		Finish_ScanWheel
;judge clockWise or anti-clockWise
		sbi		zWheelTMP	,0100b
		baz		?mayBeAntiClockWise
		sbi		zWheelTMP	,1000b	
		baz		?mayBeClockWise
		jmp		?next
?mayBeClockWise:
		sbi		zWheelValue	,1100b
		bnz		?next
		call		IncreaseIronSetpoint		;refer to Iron.asm
		jmp		?next
?mayBeAntiClockWise:
		sbi		zWheelValue	,1100b
		bnz		?next
		call		DecreaseIronSetpoint		;refer to Iron.asm
?next:		
;save------------------------------------------------------------------------------------
SaveWheelState:
		;curren state as stable state
		lda		zWheelTMP		,0		
		sta		zWheelValue		,0
Finish_ScanWheel:          
		call		ReturnToWorkState		;refer to Iron.asm	
		jmp		Exit_ScanWheel		
;----------------------------------END-----------------------------------------------------

⌨️ 快捷键说明

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