![](https://csdnimg.cn/release/download_crawler_static/87604167/bg6.jpg)
outportb(PB_Addr, dig); // 选择数码管
delay(3); // 延迟 3ms
outportb(PB_Addr, 0xff);
dig = ((dig << 1) | 1);
}
}
u8 AllKey() //(给定)
{
u8 i;
outportb(PB_Addr, 0x0);
i = (~inportb(PC_Addr) & 0x3); // 读 C 端输入的按键
return i;
}
u8 key()//返回输入的键(给定)
{
u8 i, j, keyResult;
u8 bNoKey = 1;
while(bNoKey){
if (AllKey() == 0) //调用判有无闭合键函数
{
DIR();
DIR();
continue;
}
DIR();
DIR();
if (AllKey() == 0) //调用判有无闭合键函数
continue;
i = 0xfe;
keyResult = 0;
do
{
outportb(PB_Addr, i);
j = ~inportb(PC_Addr);
if (j & 3)
{
bNoKey = 0;
if (j & 2) //1 行有键闭合
keyResult += 8;
}
else //没有键按下
{