C语言编程:.H文件与.C文件的关系!
扫描二维码
随时随地手机看文章
/*如下为键盘驱动的头文档*/
/////////////////////////////////////////////////////////////////
char keyhit( void ); //击键否
unsigned char Keyscan( void ); //取键值
////////////////////////////////////////////////////////////////
二、尽量使用宏定义#define
static unsigned char sts;//按键状态变量
static unsigned char Nowkeycode;//此时的键码
static unsigned char Prekeycode;//上一次的键码
static unsigned char Keydowntime;//矩形键盘按下去抖时间变量
static unsigned char Keyuptime;//矩形键盘释放去抖时间变量
static unsigned char Onoffdowntime;//关机键按下去抖时间变量
static unsigned char Onoffuptime;//关机键释放去抖时间变量
static unsigned char onoff_10ms; //判断关机键中断次数变量,累计150次大约为3S,因为前后进了两个10ms中断
const unsigned char a=1;//定义a=1,编译器不允许修改a的值
作用:保护不希望被修改的参数
const unsigned char Key_code[KEYNUM]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,
0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,
0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,
0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,
0x41
};//键码
const unsigned char Line_out[LINENUM]={0xFE,0xFD,0xFB,0xf7,0xEF,0xDF,0xBF,0x7F};//行输出编码
const unsigned char Row_in[ROWNUM]={0xFE,0xFD,0xFB,0xf7,0xEF,0xDF,0xBF,0x7F};//列输入编码
static int i=0;
int main(void)
{
...
while (1)
{
if (i)
dosomething();
}
}
/* Interrupt service routine. */
void ISR_2(void)
{
i=1;
}
树莓派Pico:仅4美元的MCU
嵌入式Linux开发板裸机程序烧写方法总结
国产16位MCU的痛点,可以用这款物美价廉产品
免责声明:本文内容由21ic获得授权后发布,版权归原作者所有,本平台仅提供信息存储服务。文章仅代表作者个人观点,不代表本平台立场,如有问题,请联系我们,谢谢!