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

📄 key.mac

📁 calculator code ,use toshibaor nec LSI
💻 MAC
📖 第 1 页 / 共 2 页
字号:
	$nolist
;*******************************************************************************
;*******************************************************************************
;*                                                                             *
;*              (C)Copyright, CLOVER China Electronics Co.,LTD.                *
;*                          All Rigits Reserved                                *
;*   add:No.58-F Yang Dong Road, LuoFeng Demonstrative Zone Suzhou, China      *
;*                    Tel: 0512-67261886 Fax:0512-67261882                     *
;*                        http://www.clover.co.jp                              *
;*                                                                             *
;*******************************************************************************
;*******************************************************************************
;
;		OBS CPD3212T source program
;		CPU: TOSHIBA TLC-870/C series TMP86CM74A
;		RAM: 2Kbytes(0040h - 083Fh)
;		ROM: 32Kbytes(8000h - FFFFh)
;
;Sub routines

	?trigger(@)
	@include	"symdef_ram.inc"
	@include	"macro.inc"
	@include	"define.inc"
	$list

	public	init_scan,key_scan,key_get,init_keybuf,update_md,mdsw_update,initial_mdsw_update
	public	wait_100ms,wait_50ms,wait_xms
	extern	off_key,lcd_display_symbol,vft_enable,vft_disable,disp_to_dbr
ROM	section	code 

;==============================================================================
;	I/O port bit assignment for reference 
;==============================================================================
;------------------------------------------------
;Port assignment (P7) key matrax scan; output low level if key pressed
;------------------------------------------------
;P90	Key matrix scan0	out	;HH______________________HH______________________
;P91	Key matrix scan1	out	;__HH______________________HH____________________
;P92	Key matrix scan2	out	;____HH______________________HH__________________
;P93	Key matrix scan3	out	;______HH______________________HH________________
;P94	Key matrix scan4	out	;________HH______________________HH______________
;P95	Key matrix scan5	out	;__________HH______________________HH____________
;P96	Key matrix scan6	out	;____________HH______________________HH__________
;P97	Key matrix scan7	out	;______________HH______________________HH________
;============================================================================
;Port assignment (P3) and P20, key scan return and slider return
;-----------------------------------------------
;key return
;P10	Key matrix return0	in	;valid senser with high level
;P11	Key matrix return1	in	;
;P12	Key matrix return2	in	;
;P13	Key matrix return3	in	;
;P15	Key matrix return4	in	;
;slider return
;P50	slide matrix return0	in	;valid senser with high level
;P51	slide matrix return1	in	;
;P52	slide matrix return2	in	;
;P53	slide matrix return3
RET_GT		equ	0y00000001	;V1.23 return for GT key
SCAN_GT		equ	0x03		;V1.23 scan for GT key
RET_IC		equ	0y00001000	;V1.23return for IC key
SCAN_IC		equ	0x07		;V1.23 scan for IC key
RET_RATE	equ	0y00000001	;return for RATE key
RETV1205_RATE	equ	0y00000100	;V1.28
SCAN_RATE	equ	0x0a		;scan for RATE key
SCANV1205_RATE	equ	0x05		;V1.28
RET_FEED	equ	0y00000001	;return for FEED key
SCAN_FEED	equ	0x0b		;scan for FEED key
RET_SET		equ	0y00001000	;return for set(time) key
SCAN_SET	equ	0x0a		;scan for set(time) key
COLOR		equ	3
;==============================================================================
;		Key scan interrupt (set 800us interval for TC4)
;==============================================================================
init_scan:
		ld	(P9DR),0y00000000	;data latch to 0 (for initial value)
		or	(P1DR),0y00111111	;
		ld	(P5CR),0y00000000	;
		ld	(P5DR),0y00000000	;set P50-P53 as input port
;T4CR: bit7(TFF4) bit654(TC4CK) bit3(TC4S) bit210(TC4M)
		clr	(ILH).IL10			;clear TC4 interrupt flag
		ld	(TC4DR),100			;16MHz/2^7/100 = 125Hz(800us)
		di				;V2.05
		set	(EIRH).EF10			;TC4 interrupt enable
		ei				;V2.05
		ld	(TC4CR),0y00000100
		ld	(TC4CR),0y00100100		;TC4S=1(count start) TC4CK=001(select fc/2^7) TC4M=000(select 8bittimer mode)
		ret

;==============================================================================
;		Initialize key buffer pointer, counter
;==============================================================================
init_keybuf:
		di
		ld	(KEY_CT),0	;key counter clear
		ld	(KEY_WPTR),0	;key bufeer write pointer clear
		ld	(KEY_RPTR),0	;key buffer read pointer clear
		ei
		ret

;==============================================================================
;		Get key code from key buffer
;		out: reg.a <- key code
;		     KEYIN <- key code
;		     c clear: illegal key
;		use register:	c,hl
;==============================================================================
key_get:
		ld	c,(KEY_RPTR)	;key buffer read pointer-->c
		ld	hl,KEY_BUF	;key buffer start address-->hl
		ld	a,(hl+c)	;key code wanted-->a
		ld	(KEYIN),a	;key code in a-->register KEYIN
		inc	c		;prepared for next key code
		and	c,0x3f		;\recycle KEY_RPTR in key buffer(3fh)
		ld	(KEY_RPTR),c	;/
		dec	(KEY_CT)	;key counter decrease one
		cmp	a,K_MAX		;over the max key code? no, set c is OK
		ret

;==============================================================================
;		and update MDFLG,DP_POS from MDFLG_RT,DP_POS_RT
;==============================================================================
;MDFLG_0:
;SW_DP0	;SW_DP1;SW_DP2;SW_DP3;SW_DP4;SW_DP5;SW_DP6;SW_ADM
;MDFLG_1:
;SW_SGT,SW_SGM,SW_SGG,SW_SGK,SW_GT,SW_MGT,SW_RNDUP,SW_RND54
;MDFLG_2:
;SW_SG,SW_ICPM,SW_IC,SW_NP,SW_OFF,SW_AC,SW_V15,SW_FEED,SW_A,SW_M2,SW_AMZ
;MDFLG_3:
;SW_DTST,SW_ADM12,SW_EUTX,SW_D14,SW_D10,SW_TA,SW_M2,SW_FIN
;MDFLG_01:no use
;MDFLG_11:no use
;MDFLG_21:no use
;------------------------------------------
;===========================================================
update_md:
		ld	a,(MDFLG_RT0)	;
		ld	(MDFLG_0),a
		ld	a,(MDFLG_RT1)	;
		ld	(MDFLG_1),a	
		ld	a,(MDFLG_RT2)	;
		ld	(MDFLG_2),a	
		ld	a,(MDFLG_RT3)	;
		ld	(MDFLG_3),a
		ld	a,(DP_POS_RT)	;
		ld	(DP_POS),a
		@BBC	(M_FX_SGM,to_fix_ac)	;V2.06
to_fix_sgm:					;V2.06
		@SEB	(SW_SGM)		;V2.06
		
to_fix_ac:
		@BBC	(M_FX_AC,to_fix_m14)	;V2.06
		@SEB	(SW_AC)		;V2.06
to_fix_m14:
		@BBC	(M_FX_M14,to_fix_54)	;V4.07
		@SEB	(M14)			;V4.07
to_fix_54:					;V2.06
;V3.00		@BBC	(M_FX_54,to_fix_sd)	;V2.06
;V3.00		@SEB	(SW_RND54)		;V2.06
;V3.00to_fix_sd:					;V2.06
;V3.00		@BBC	(M_FX_SD,to_set_icpm)	;V2.06
;V3.00		@SEB	(SW_DTST)		;V2.06
;V3.00to_set_icpm:
;V3.00		@BBC	(SW_V15,to_fix_end)	;V2.07
;V3.00		@BBC	(F_ICPM,to_set_icpm_1)	;V2.07 to set IC_PM
;V3.00		@SEB	(SW_ICPM_RT)		;V2.07
;V3.00		@SEB	(SW_ICPM)		;V2.07
;V3.00		jp	to_fix_end		;V2.07
;V3.00to_set_icpm_1:
;V3.00		@CLB	(SW_ICPM_RT)		;V2.07
;V3.00		@CLB	(SW_ICPM)		;V2.07			
;V3.00to_fix_end:
		ret

;V2.00disp_rate_blink:

;V2.00	ret
;==============================================================================
;auto switch off time check, 5 minutes=300000us. (AUTO_OFF_TIME)=300000/400=750
;==============================================================================
;V2.03auto_off_check:				;V1.08
;V2.03	@BBC	(M_HAND,auto_off_check_end)	;V1.18
;V2.03	ld	wa,(AUTO_OFF_TIM)
;V2.03	cmp	wa,0
;V2.03	jr	eq,auto_off_check_end
;V2.03	dec	wa
;V2.03	ld	(AUTO_OFF_TIM),wa
;V2.03	cmp	wa,0
;V2.03	jr	ne,auto_off_check_end
;V2.03	ld	wa,AUTOOFFTIME	;750 x 400=300000us=5 minutes
;V2.03	ld	(AUTO_OFF_TIM),wa
;V2.03	@SEB	(F_WAKE)
;V2.03auto_off_check_end:
;V2.03	ret
;==============================================================================
;display backlight color control green, green+red=salmon pink
;==============================================================================
blink_vfd:
;V4.11	@BBS	(F_OFF,blink_vfd_off)		;V2.06
;V4.11	@BBS	(IO_MT,blink_vfd_off)		;V2.07
;V3.00	@BBS	(RATE_PROG,blink_vfd_start)
;V3.00	@BBS	(EURO_PROG,blink_vfd_start)
;V4.11	@BBS	(IC_PROG,blink_vfd_start)
;V3.00	@BBS	(RTC_SET,blink_vfd_start)
;V4.11	@CLB	(F_BLINK)	;V2.10
;V4.11	ret
blink_vfd_start:
;V4.11	inc	(BLK_CT)
;V4.11	inc	(BLK_CT)
;V4.11	ld	a,(BLK_CT)
;V4.11	and	a,0x7f
;V4.11	cmp	a,0x40
;V4.11	j	ge,blink_vfd_on
;V4.11	@CLB	(F_BLINK)	;V2.10
;V4.11	jp	blink_vfd_end	;V2.10
blink_vfd_on:
;V4.11	@SEB	(F_BLINK)	;V2.10
blink_vfd_end:
;V4.11	call	disp_to_dbr	;V2.10
;V4.11	ret			;V2.10
blink_vfd_off:			;V2.10
;V4.11	call	vft_disable	;V2.10
;V4.11	@CLB	(F_BLINK)	;V2.10
	ret			;V2.10
;------------------------------------V2.05
wait_100ms:
		ld	(DELAY_CT),125		;800usx125 -> 100ms
		j	wait_xms
wait_50ms:
		ld	(DELAY_CT),62		;800usx62-> 49.6ms
wait_xms:
		cmp	(DELAY_CT),0
		j	ne,wait_xms
		ret
;==============================================================================
;		Key scan interrupt
;==============================================================================
;V1.39aKON_TIM		equ	2			;judgement for key press (800us*12scan*2=19.2ms to 19.2ms+800*11scan=28ms)
;V1.34KOFF_TIM	equ	4			;judgement for key release (800us*12scan*4=38.4ms to 38.4ms+800*11scan=47.2ms)
;V1.39aKOFF_TIM	equ	2
KON_TIM		equ	1	;V1.39a
KOFF_TIM	equ	3	;V1.39a
MD_TIM		equ	15			;judgement for mode sw moved (800us*12scan*15=144ms)
;MD_TIM		equ	10			;judgement for mode sw moved (392us*12scan*10=47.040ms)

key_scan:
		@PUSH_REG
		cmp	(DELAY_CT),0
		j	eq,check_delay_time
		dec	(DELAY_CT)
check_delay_time:
		@BBC	(IO_MT,key_scan00)
;V3.00		@RST_IN_ON(key_scan99)	;when print reset sign checked in, jump out
;V3.12		ei			;V3.00
key_scan00:
		ld	a,(EP_TIM)	;\
		j	z,key_scan_01	;|during EEPROM reading and writing, skip to key scan end 
		dec	(EP_TIM)	;|
		jp	key_scan99	;/
key_scan_01:
		@BBS	(EP_ACCES,key_scan99)
;V2.13		call	feed_check		
		@BBS	(F_KON,key_scan_02)	
;V1.39key_scan_01x:				
		call	mdsw_scan		
		call	update_mdsw		;for remove mode sw chattaring
key_scan_02:
;V4.11		@BBS	(SW_OFF_RT,key_scan90)	;power sw move to OFF mode? yes -> exit
;V4.11		@BBS	(F_OFF,key_scan90)	;if OFF mode? yes -> exit
		@BBS	(IO_MT,key_scan_03)	
		@BBS	(F_DOFF,key_scan_03)	
		cmp	(OFF_CT),0		
		j	eq,key_scan_030		
		dec	(OFF_CT)		
		jp	key_scan_03		
key_scan_030:
		call	vft_enable		
key_scan_03:		
		ld	b,(P1PRD)	
		@BBS	(F_KON,key_scan20)	;branch if on or off check  yes->
		and	b,0y00111111		;
		j	z,key_scan90		;no key press   yes->

;Detect key press...............................
		ld	c,0xff;V1.01
;V3.00		swap	b
		;--------------------------------------------------------------
key_scan12:;V1.01		
;V3.00		shlc	b		;shift current key return
		shrc	b
		inc	c		;count which bit is high in register b
		j	cc,key_scan12	
		;--------------------------------------------------------------
		ld	hl,tbl_rtndt	;\
		ld	b,(hl+c)	;|key return (matrix vertical)-->RET_BK
		ld	(RET_BK),b	;/
		ld	a,(SCAN_CT)	;\
		ld	(SCAN_BK),a	;/key scan (matrix horizontal)-->SCAN_BK 
		ld	(KI_CT),KON_TIM
		@SEB	(F_KON)		;indicate some key already pressed.
		ld	(BLK_CT),0	
		j	key_scan90

;Key on check...................................
key_scan20:
		ld	a,(SCAN_CT)		;whether the same key keep in pressing
		cmp	a,(SCAN_BK)		;//
		j	ne,key_scan90		;/different scan line?  yes-> exit
		@BBS	(F_KOFF,key_scan30)	;off check? yes->
		and	b,0y00111111		;reg.b = current key return
		j	z,key_scan32		;for make sure
		and	b,(RET_BK)		;previous key on continue?
		j	z,key_scan32		;If chataling?  yes->
		dec	(KI_CT)
		j	nz,key_scan90		
		ld	(KI_CT),KOFF_TIM	;detect key on?
		@SEB	(F_KOFF)		; yes -> next action is off check
		
;Key code calculation...........................
		ld	c,0xff
key_scan22:	
		shrc	b	;shift current key return
		inc	c		;reg.c = lower 2bit of key code
		j	cc,key_scan22
		ld	a,(SCAN_CT)
;V3.00		shlc	a		;--ax4
;V3.00		shlc	a		;/

⌨️ 快捷键说明

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