kbd.c

来自「This is example of using Atmel at89c5131」· C语言 代码 · 共 52 行

C
52
字号
#include <Atmel/at89c5131.h>
#include "kbd.h"
#include "lcd.h"


unsigned char KeyPressed;
unsigned char KeyCode;
//-----------------------------------------------------
void EnableKbd()
{
	IEN1 |= 0x01;	/* Enable keyboard interupt */
}
//-----------------------------------------------------
void DisableKbd()
{
	IEN1 &= 0xFE;	/* Disable keyboard interupt */
}
//-----------------------------------------------------
void InitKbd()
{
	KeyPressed = 0;
	KeyCode = 0;
	EA = 1;			/* enable interrupts */
	KBE = 0x1F;		/*Enable P1 I/O as keyboard IO */
   	KBF = 0x00;		/* Clear all keyboard flags */
   	IEN1 |= 0x01;	/* Enable keyboard interupt */
}
//-----------------------------------------------------
unsigned char GetKey()
{
	while(!KeyPressed){}
	KeyPressed = 0;
	return KeyCode;
}
//-----------------------------------------------------
/**
* FUNCTION_PURPOSE:keyboard_interrupt. Save pressed key
* FUNCTION_INPUTS:void
* FUNCTION_OUTPUTS:void
*/
void keyboard_interrupt() interrupt 7 using 1
{
	//IEN1 &=0xFE;	/* Disable keyboard interupt */
	EA = 0;
	KeyCode = KBF&0x1F;	/* save pressed key */
	KeyPressed = 1;		/* set the software flag */
	KBF = 0x00;				/* clear keyboard flags */
	//IEN1 |=0x01;	/* Enable keyboard interupt */
	EA = 1;
}
//-------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?