?? keyboard.c
字號(hào):
/*
*************************************************************************
* 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);
S8 *KeyMap[MAX_KEY_NUM] = {"S46", "S47", "S48", "S49", "S50", "S51", "S52", "S53",
"S54", "S55", "S56", "S57", "S58", "S59", "S60", "S61"};
__irq void key_isr(void)
{
U8 row, rank, key;
int_disable(BIT_EINT4567);
rPDATC |= 0xff;
row = rEXTINTPND;
row = row/2;
if(row == 4)
row = 3;
rEXTINTPND = 0xf;
rank = ScanKey();
key = rank*MAX_LINE_NUM+row;
if(key<MAX_KEY_NUM)
{
Uart_Printf("enter a key: %s\n", KeyMap[key]);
}
Delay(2000);
rEXTINTPND = 0xf;
rI_ISPC |= BIT_EINT4567;
rPDATC &= (~0xff);
int_enable(BIT_EINT4567);
}
void key_init(void)
{
rPCONC &= (~0xff); //configure GPC0-3 as Output port.
rPCONC |= 0x55;
rPUPC |= 0x0f;
rPDATC &= (~0xff);
pISR_EINT4567 = (unsigned) key_isr;
int_enable(BIT_EINT4567);
}
static U8 ScanKey(void)
{
U8 line;
rPDATC |= 0xff;
for(line=0; line<MAX_LINE_NUM; line++)
{
rPDATC &= (~(1<<line));
if(rEXTINTPND)
break;
}
return line;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -