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

📄 rd_usekey.s

📁 LCD1602键盘显示模块实例
💻 S
📖 第 1 页 / 共 2 页
字号:
	.dbline 201
;     }
	xjmp L6
L5:
	.dbline 203
;     else
;     {
	.dbline 204
;         s_cKeyNum = KEY_NULL;
	ldi R24,255
	sts _s_cKeyNum,R24
	.dbline 205
;         if ((g_wKeyPressTimeCounter > _USE_KEY_LONG_PRESS_DELAY_TIME) && (IfLongKeyPress == FALSE))
	ldi R24,1024
	ldi R25,4
	lds R2,_g_wKeyPressTimeCounter
	lds R3,_g_wKeyPressTimeCounter+1
	cp R24,R2
	cpc R25,R3
	brsh L9
X4:
	lds R2,L3
	tst R2
	brne L9
X5:
	.dbline 206
;         {
	.dbline 208
;             #ifdef _USE_KEY_LONG_PRESS_REPEAT
;             if (LongPressAcceleration > _USE_KEY_LONG_PRESS_FASTEST_SPEED)
	ldi R24,127
	ldi R25,0
	lds R2,L4
	lds R3,L4+1
	cp R24,R2
	cpc R25,R3
	brsh L11
X6:
	.dbline 209
;             {
	.dbline 210
;                 LongPressAcceleration >>= 1;
	lsr R3
	ror R2
	sts L4+1,R3
	sts L4,R2
	.dbline 211
;             }
L11:
	.dbline 213
;             #endif
;             s_cLongKeyPressNum = NowKeyCode;
	sts _s_cLongKeyPressNum,R20
	.dbline 214
;             IfLongKeyPress = TRUE;
	ldi R24,1
	sts L3,R24
	.dbline 215
;         }
	xjmp L10
L9:
	.dbline 217
;         else
;         {
	.dbline 219
;             #ifdef _USE_KEY_LONG_PRESS_REPEAT
;             if (!(g_wKeyPressTimeCounter & LongPressAcceleration))
	lds R2,L4
	lds R3,L4+1
	lds R4,_g_wKeyPressTimeCounter
	lds R5,_g_wKeyPressTimeCounter+1
	and R4,R2
	and R5,R3
	tst R4
	brne L13
	tst R5
	brne L13
X7:
	.dbline 220
;             {
	.dbline 221
;                 IfLongKeyPress = FALSE;
	clr R2
	sts L3,R2
	.dbline 222
;             }
	xjmp L14
L13:
	.dbline 224
;             else
;             {
	.dbline 225
;                 s_cLongKeyPressNum = KEY_NULL;
	ldi R24,255
	sts _s_cLongKeyPressNum,R24
	.dbline 226
;             }
L14:
	.dbline 230
;             #else
;             s_cLongKeyPressNum = KEY_NULL;    
;             #endif
;         }
L10:
	.dbline 231
;     }
L6:
	.dbline -2
L1:
	.dbline 0 ; func end
	ld R20,y+
	ret
	.dbsym r NowKeyCode0 20 c
	.dbend
	.dbfunc e Add_Key_Code _Add_Key_Code fV
	.even
_Add_Key_Code::
	.dbline -1
	.dbline 242
; 	 
; }
; 
; /***********************************************************
; *   函数说明:键盘缓冲处理函数                             *
; *   输入:    无                                           *
; *   输出:    无                                           *
; *   调用函数:_Key_Scan()                                  *
; ***********************************************************/
; void Add_Key_Code(void)
; {
	.dbline 243
;     _Key_Scan();
	xcall __Key_Scan
	.dbline 245
;     
; 	if ((s_cKeyNum == KEY_NULL) && (s_cLongKeyPressNum == KEY_NULL))
	lds R24,_s_cKeyNum
	cpi R24,255
	brne L16
X8:
	lds R24,_s_cLongKeyPressNum
	cpi R24,255
	brne L16
X9:
	.dbline 246
; 	{
	.dbline 247
; 	    return ;
	xjmp L15
L16:
	.dbline 250
; 	}
; 	
; 	if ((s_cKeyBUFFHeadPoint == s_cKeyBUFFTailPoint) && (s_cKeyBUFFCounter != NULL))
	lds R2,_s_cKeyBUFFTailPoint
	lds R3,_s_cKeyBUFFHeadPoint
	cp R3,R2
	brne L18
X10:
	lds R2,_s_cKeyBUFFCounter
	tst R2
	breq L18
X11:
	.dbline 251
; 	{
	.dbline 252
; 	    return ;
	xjmp L15
L18:
	.dbline 255
; 	}
; 	
; 	s_cKeyBUFF[s_cKeyBUFFTailPoint][0] = s_cKeyNum;
	ldi R24,<_s_cKeyBUFF
	ldi R25,>_s_cKeyBUFF
	lds R30,_s_cKeyBUFFTailPoint
	clr R31
	lsl R30
	rol R31
	add R30,R24
	adc R31,R25
	lds R2,_s_cKeyNum
	std z+0,R2
	.dbline 256
; 	s_cKeyBUFF[s_cKeyBUFFTailPoint][1] = s_cLongKeyPressNum;
	ldi R24,<_s_cKeyBUFF+1
	ldi R25,>_s_cKeyBUFF+1
	lds R30,_s_cKeyBUFFTailPoint
	clr R31
	lsl R30
	rol R31
	add R30,R24
	adc R31,R25
	lds R2,_s_cLongKeyPressNum
	std z+0,R2
	.dbline 258
; 	
; 	s_cKeyBUFFTailPoint ++;
	lds R24,_s_cKeyBUFFTailPoint
	subi R24,255    ; addi 1
	sts _s_cKeyBUFFTailPoint,R24
	.dbline 259
; 	if (s_cKeyBUFFTailPoint == KEY_BUFF_SIZE)
	cpi R24,8
	brne L21
X12:
	.dbline 260
; 	{
	.dbline 261
; 	    s_cKeyBUFFTailPoint = 0;
	clr R2
	sts _s_cKeyBUFFTailPoint,R2
	.dbline 262
; 	}
L21:
	.dbline 263
; 	s_cKeyBUFFCounter ++;
	lds R24,_s_cKeyBUFFCounter
	subi R24,255    ; addi 1
	sts _s_cKeyBUFFCounter,R24
	.dbline -2
L15:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Get_Key_Code _Get_Key_Code fc
	.even
_Get_Key_Code::
	.dbline -1
	.dbline 276
; }
; 
; /***********************************************************
; *   函数说明:从键盘缓冲区中获得一个按键扫描码             *
; *   输出:    返回操作是否成功TRUE / FALSE                 *
; *   输入:    无                                           *
; *   调用函数:Add_Key_Code()                               *
; * -------------------------------------------------------- *
; *   [说    明]                                             *
; *             将按键扫描码放到专门的临时缓冲变量中         *
; ***********************************************************/
; unsigned char Get_Key_Code(void)
; {
	.dbline 277
;     g_cReturnKeyNum = KEY_NULL;
	ldi R24,255
	sts _g_cReturnKeyNum,R24
	.dbline 278
;     g_cReturnLongPressKeyNum = KEY_NULL;
	sts _g_cReturnLongPressKeyNum,R24
	.dbline 284
; 	
; 	#ifdef _USE_KEY_MANUL_REFRESH
; 	    Add_Key_Code();
; 	#endif
; 	
; 	if ((s_cKeyBUFFHeadPoint == s_cKeyBUFFTailPoint) && (s_cKeyBUFFCounter == NULL))
	lds R2,_s_cKeyBUFFTailPoint
	lds R3,_s_cKeyBUFFHeadPoint
	cp R3,R2
	brne L24
X13:
	lds R2,_s_cKeyBUFFCounter
	tst R2
	brne L24
X14:
	.dbline 285
; 	{
	.dbline 286
; 	    return FALSE;
	clr R16
	xjmp L23
L24:
	.dbline 289
; 	}
; 
;     g_cReturnKeyNum = s_cKeyBUFF[s_cKeyBUFFHeadPoint][0];
	ldi R24,<_s_cKeyBUFF
	ldi R25,>_s_cKeyBUFF
	lds R30,_s_cKeyBUFFHeadPoint
	clr R31
	lsl R30
	rol R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	sts _g_cReturnKeyNum,R2
	.dbline 290
; 	g_cReturnLongPressKeyNum = s_cKeyBUFF[s_cKeyBUFFHeadPoint][1];
	ldi R24,<_s_cKeyBUFF+1
	ldi R25,>_s_cKeyBUFF+1
	lds R30,_s_cKeyBUFFHeadPoint
	clr R31
	lsl R30
	rol R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	sts _g_cReturnLongPressKeyNum,R2
	.dbline 292
; 			
; 	s_cKeyBUFFCounter--;
	lds R24,_s_cKeyBUFFCounter
	subi R24,1
	sts _s_cKeyBUFFCounter,R24
	.dbline 293
; 	s_cKeyBUFFHeadPoint++;
	lds R24,_s_cKeyBUFFHeadPoint
	subi R24,255    ; addi 1
	sts _s_cKeyBUFFHeadPoint,R24
	.dbline 294
; 	if (s_cKeyBUFFHeadPoint == KEY_BUFF_SIZE)
	cpi R24,8
	brne L27
X15:
	.dbline 295
; 	{
	.dbline 296
; 	    s_cKeyBUFFHeadPoint = 0;
	clr R2
	sts _s_cKeyBUFFHeadPoint,R2
	.dbline 297
; 	}
L27:
	.dbline 299
; 			
;     return TRUE;
	ldi R16,1
	.dbline -2
L23:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile O:\2007全国电子设计大赛\键盘显示模块\RD_UseKey.c
_s_cKeyBUFF:
	.blkb 16
	.dbsym s s_cKeyBUFF _s_cKeyBUFF A[16:8:2]c
; }

⌨️ 快捷键说明

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