📄 key.c
字号:
/**********************************************************************
* 文 件 名:key.c
* 功 能:按键选择程序
* 日 期:2007.6.27
**********************************************************************/
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
void Delay_ms(word xms);
void WriteEEPROM(word data,word addr);
word temp0=0,temp1=0,temp2=0,temp3=0,temp4=0,temp5=0,temp6=0,temp7=0;
//PTH_PTH0 ~ 7
void key(void)
{
PORTB=0x00;
for(;;)
{
Delay_ms(10);
if(PTH_PTH0==0)
{
WriteEEPROM(temp0,1);
PORTB=~((byte)temp0);
temp0++;
while(PTH_PTH0==0);
}
if(PTH_PTH1==0)
{
WriteEEPROM(temp1,2);
PORTB=~((byte)temp1);
temp1++;
while(PTH_PTH1==0);
}
if(PTH_PTH2==0)
{
WriteEEPROM(temp2,3);
PORTB=~((byte)temp2);
temp2++;
while(PTH_PTH2==0);
}
if(PTH_PTH3==0)
{
WriteEEPROM(temp3,4);
PORTB=~((byte)temp3);
temp3++;
while(PTH_PTH3==0);
}
if(PTH_PTH4==0)
{
WriteEEPROM(temp4,5);
PORTB=~((byte)temp4);
temp4++;
while(PTH_PTH4==0);
}
if(PTH_PTH5==0)
{
WriteEEPROM(temp5,6);
PORTB=~((byte)temp5);
temp5++;
while(PTH_PTH5==0);
}
if(PTH_PTH6==0)
{
WriteEEPROM(temp6,7);
PORTB=~((byte)temp6);
temp6++;
while(PTH_PTH6==0);
}
if(PTH_PTH7==0)
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -