📄 keydis_drv.s
字号:
.module KeyDis_Drv.c
.area lit(rom, con, rel)
_DisTab::
.byte 252,96
.byte 218,242
.byte 'f,182
.byte 190,224
.byte 254,246
.byte 238,62
.byte 156,'z
.byte 158,142
.byte 206,28
.byte 'n,124
.byte 10,16
.byte 2
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
.dbsym e DisTab _DisTab A[23:23]kc
.area text(rom, con, rel)
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
.dbfunc e SPI_INIT _SPI_INIT fV
.even
_SPI_INIT::
.dbline -1
.dbline 107
; /***********************************************************
; * 函数库说明:键盘显示模块驱动函数库 *
; * 版本: *
; * 作者: *
; * 创建日期: *
; * -------------------------------------------------------- *
; * [硬件说明] *
; * 处理器: *
; * 系统时钟: *
; * -------------------------------------------------------- *
; * [支 持 库] *
; * 支持库名称:KeyDis_Drv.h *
; * 需要版本: ----- *
; * 支持库说明:键盘显示模块驱动声明库 *
; * *
; * 支持库名称: *
; * 需要版本: ----- *
; * 支持库说明: *
; * -------------------------------------------------------- *
; * [版本更新] *
; * 修改: *
; * 修改日期: *
; * 版本: *
; * -------------------------------------------------------- *
; * [版本历史] *
; * -------------------------------------------------------- *
; * [使用说明] *
; ***********************************************************/
;
; /********************
; * 头 文 件 配 置 区 *
; ********************/
; #include <iom48v.h> //在这里填写你所用处理器的专用头文件 //
; #include "EX_Support.h"
; #include "KeyDis_Drv.h"
;
; /********************
; * 系 统 宏 定 义 *
; ********************/
;
; /*------------------*
; * 常 数 宏 定 义 *
; *------------------*/
;
; #define ExtPortNum 3
;
; #define Key_Press 0x00
; #define Key_Bounce 0x01
; #define Key_Release 0x02
;
; #define PINE PortBuffer[0]
; #define PORTF PortBuffer[1]
; #define PORTG PortBuffer[2]
;
; #define KeyPin PINE
; #define ScanPort PORTG
; #define SegPort PORTF
;
; /*------------------*
; * 动 作 宏 定 义 *
; *------------------*/
;
; #define SS_Low PORTB &= ~(1<<2)
; #define SS_High PORTB |= (1<<2)
;
; /********************
; * 模块结构体定义区 *
; ********************/
;
; /********************
; * 函 数 声 明 区 *
; ********************/
;
; /********************
; * 模块函数声明区 *
; ********************/
;
; /********************
; * 模块变量声明区 *
; ********************/
;
; /********************
; * 全局变量声明区 *
; ********************/
;
; unsigned char PortBuffer[3];
; unsigned char LEDDisBuffer[8];
; unsigned char KeyBuffer;
;
; const unsigned char DisTab[]=
; {
; 0xFC,0x60,0xDA,0xF2,0x66, //0,1,2,3,4
; 0xB6,0xBE,0xE0,0xFE,0xF6, //5,6,7,8,9
; 0xEE,0x3E,0x9C,0x7A,0x9E, //A,b,C,d,E
; 0x8E,0xCE,0x1C,0x6E,0x7C, //F,P,L,H,U
; 0x0A,0x10,0x02 //r,_,-
; };
;
; /***********************************************************
; * 函数声明:SPI初始化程序 *
; * 输入: 无 *
; * 输出: 无 *
; * 调用函数:无 *
; ***********************************************************/
;
; void SPI_INIT (void)
; {
.dbline 108
; SPCR = 0x7D; //禁止SPI中断,使能SPI模块,LSB先传送,选择主机模式,空闲时时钟为高,时钟结束沿采样,时钟频率64分频
ldi R24,125
out 0x2c,R24
.dbline 109
; SPSR = 0x00; //不使用SPI倍速
clr R2
out 0x2d,R2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.area data(ram, con, rel)
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
L3:
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
.area text(rom, con, rel)
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
.dbfunc e LEDDisplay _LEDDisplay fV
.dbsym s ScanStatu L3 c
; LocalTime -> R20
.even
_LEDDisplay::
rcall push_gset1
.dbline -1
.dbline 119
; }
;
; /***********************************************************
; * 函数说明:端口通讯程序 *
; * 输入: 无 *
; * 输出: 无 *
; * 调用函数: *
; ***********************************************************/
; void LEDDisplay (void)
; {
.dbline 123
; static unsigned char ScanStatu = 0; //扫描状态标志,扫描程序内部使用
; unsigned char LocalTime; //函数内部使用的时标
;
; LocalTime = g_wSystemTimer%20;
ldi R18,20
ldi R19,0
lds R16,_g_wSystemTimer
lds R17,_g_wSystemTimer+1
rcall mod16u
mov R20,R16
.dbline 125
;
; if (LocalTime > 16)
ldi R24,16
cp R24,R16
brsh L4
.dbline 126
; {
.dbline 127
; ScanPort = 0xFF;
ldi R24,255
sts _PortBuffer+2,R24
.dbline 128
; return;
rjmp L2
L4:
.dbline 132
; }
;
; else
; {
.dbline 133
; LocalTime >>= 1;
lsr R20
.dbline 134
; ScanPort = (~(1<<LocalTime));
ldi R16,1
mov R17,R20
rcall lsl8
mov R2,R16
com R2
sts _PortBuffer+2,R2
.dbline 135
; SegPort = (DisTab[LEDDisBuffer[LocalTime]]);
ldi R24,<_LEDDisBuffer
ldi R25,>_LEDDisBuffer
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R30,z+0
clr R31
ldi R24,<_DisTab
ldi R25,>_DisTab
add R30,R24
adc R31,R25
lpm R30,Z
sts _PortBuffer+1,R30
.dbline 136
; }
.dbline -2
L2:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r LocalTime 20 c
.dbend
.area data(ram, con, rel)
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
L10:
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
L11:
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
.area bss(ram, con, rel)
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
L12:
.blkb 1
.area text(rom, con, rel)
.dbfile D:\设计项目\深入浅出AVR\光盘文件\实例程序源代码\实例15_键盘显示模块\实例15_键盘显示模块-拨号装置\KeyDis_Drv.c
.dbfunc e Key_service _Key_service fc
.dbsym s KeyTmpValue L12 c
.dbsym s KeyTimer L11 c
.dbsym s KeyStatu L10 c
.even
_Key_service::
.dbline -1
.dbline 146
; }
;
; /***********************************************************
; * 函数说明:按键处理程序 *
; * 输入: 无 *
; * 输出: 无 *
; * 调用函数: *
; ***********************************************************/
; unsigned char Key_service (void)
; {
.dbline 151
; static unsigned char KeyStatu = Key_Press;
; static unsigned char KeyTimer = 0;
; static unsigned char KeyTmpValue;
;
; switch (KeyStatu)
lds R16,L10
clr R17
cpi R16,0
cpc R16,R17
breq L16
X0:
cpi R16,1
ldi R30,0
cpc R17,R30
breq L19
cpi R16,2
ldi R30,0
cpc R17,R30
breq L24
rjmp L13
X1:
.dbline 152
; {
L16:
.dbline 154
; case Key_Press : //检测按键按下
; {
.dbline 155
; if (KeyPin != 0xFF) //检测是否有键按下
lds R24,_PortBuffer
cpi R24,255
brne X11
rjmp L14
X11:
.dbline 156
; {
.dbline 157
; KeyTmpValue = KeyPin; //暂存键值
mov R2,R24
sts L12,R2
.dbline 158
; KeyStatu++; //如检测到有键按下则翻转处理状态
lds R24,L10
subi R24,255 ; addi 1
sts L10,R24
.dbline 159
; KeyTimer = 10; //初始化抗抖动定时器,抗抖动时间10mS
ldi R24,10
sts L11,R24
.dbline 160
; }
.dbline 161
; break;
rjmp L14
L19:
.dbline 165
; }
;
; case Key_Bounce : //抗抖动
; {
.dbline 166
; KeyTimer--;
lds R24,L11
subi R24,1
sts L11,R24
.dbline 167
; if (KeyTimer == 0)
tst R24
breq X12
rjmp L14
X12:
.dbline 168
; {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -