📄 kbd_drv.c
字号:
/*C**************************************************************************
* NAME: kbd_drv.c
*----------------------------------------------------------------------------
* Copyright (c) 2006 Atmel.
*----------------------------------------------------------------------------
* RELEASE: C51 Sample
* REVISION: 1.00
*----------------------------------------------------------------------------
*
*****************************************************************************/
#include "system\reg51.h"
#include "system\compiler.h"
#include "system\config.h"
#include "driver\kbd_drv.h" /* scheduler definition */
/*F**************************************************************************
* NAME: kbd_init
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
* Keyboard initialisation function
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
* ram/xram:
* cycle:
* stack:
* code:
*****************************************************************************/
void kbd_init (void)
{
P1 = P1|0x1f;
}
/*F**************************************************************************
* NAME: kbd_decode
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
* Decoded key pressed
*----------------------------------------------------------------------------
* PURPOSE:
* Decode the key that generated an IT
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
* ram/xram:
* cycle:
* stack:
* code:
*****************************************************************************/
/*读键盘键值程序段*/
Byte kbd_decode (void)
{
Byte key=0;
key = P1&0x1f;
if (key != 0x1f) { key_flag = High; return(key);}
else{
P1_0 = Low;
key = P1&0x1e;
if (key != 0x1e) { key_flag = High; return(key);}
else{
P1_0 = High;
P1_1 = Low;
key = P1&0x1d;
if (key != 0x1d) { key_flag = High; return(key);}
else{
P1_1 = High;
P1_2 = Low;
key = P1&0x1b;
if (key != 0x1b) { key_flag = High; return(key);}
else{
P1_2 = High;
P1_3 = Low;
key = P1&0x17;
if (key != 0x17) { key_flag = High; return(key);}
else{
P1_3 = High;
key_flag = Low; /* Have not key process */
return(0x00);
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -