📄 keyboard.c
字号:
/*
*************************************************************************
* Copyright (c) 2003, The Lab of Embedded System and Net Security,WHUT..
* All rights reserved.
*
* Filename: keyboard.c
* Discription: This file deals with keyboard input and output.
*
* version: 1.0
* Author: Qiu Yanfei <qyfhm@tom.com>
* Accomplished Date: 2004/5/8 18:26:00
*************************************************************************
*/
#include "..\cpu\def.h"
#include "..\cpu\44breg.h"
#include "..\cpu\44blib.h"
#include "..\uart\uart.h"
#include "..\interrupt\interrupt.h"
#include "keyboard.h"
static U8 ScanKey(void);
U8 get_key(void);
extern S8 *KeyMap[MAX_KEY_NUM] = {"S46", "S47", "S48", "S49", "S50", "S51", "S52", "S53",
"S54", "S55", "S56", "S57", "S58", "S59", "S60", "S61"};
void key_init(void)
{
rPCONC &= (~0xff); //configure GPC0-3 as Input port.
rPCONC |= 0x00;
rPUPC |= 0x0f;
rPDATC &= (~0xff);
rPCONE=0x15569; //configure GPE4-7 as Output port,
rPDATE=0x10f;
rPUPE=0x6;
}
static U8 ScanKey(void)
{
U8 row;
rPDATE |= 0x1ff;
for(row=0; row<MAX_LINE_NUM; row++)
{
rPDATE &= (~(1<<(row+4)));
if((~rPDATC)&0xf)
break;
}
return row;
}
U8 get_key(void)
{
U8 row,rank,key,temp;
temp=(~rPDATC)&0x0f;
if(temp)
{
rank=temp;
rank=rank/2;
if(rank==4)
rank=3;
row=ScanKey();
if(row<MAX_LINE_NUM)
{
key=rank*MAX_LINE_NUM+row;
return key;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -