文件里的anjian.c文件调用其他.c文件出现一些情况,各位大神帮忙看一下下面是anjian.c文件
#include <reg52.h>
#include <stdio.h>
#include <string.h>
#include "LCD.h"
#define uint unsigned int //宏定义无符号整型数据
#define uchar unsigned char //宏定义无符号字符型数?
uchar key=0; //定义键值全局变量
void keyscan() //按键扫描程序
{
static bit sign=0; //按键有效标志
static uint count=0; //消抖计数变量
uchar num=0; //临时变量
P2=0xf0; //赋值P2 1111 0000
if(P2!=0xf0) //检测有按键按下
{
count++; //消抖计数
if((count>=500)&&(sign==0))//100~1000,根据主循环周期调整约10~20ms
{
sign=1; //按键有效标志置1
num=P2; //保存P2值xxxx 0000,x为0或1
num|=0x0f; //保存num按位或0x0f值xxxx 1111
P2=num; //赋值P2xxxx 1111
num=P2; //保存P2值xxxx xxxx
switch(num)
{
case 0xee: key= 1; break;
case 0xde: key= 2; break;
case 0xbe: key= 3; break;
case 0x7e: key= 4; break;
case 0xed: key= 5; break;
case 0xdd: key= 6; break;
case 0xbd: key= 7; break;
case 0x7d: key= 8; break;
case 0xeb: key= 9; break;
case 0xdb: key=10; break;
case 0xbb: key=11; break;
case 0x7b: key=12; break;
case 0xe7: key=13; break;
case 0xd7: key=14; break;
case 0xb7: key=15; break;
case 0x77: key=16; break;
}
}
}
else //键抬起
{
sign=0; //按键有效标志清0
count=0; //消抖计数清0
}
}
GPS相关程序.rar
(107.09 KB, 下载次数: 5)
|