⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kbd.c

📁 This is example of using Atmel at89c5131 MCU with at49db11(spi dataflash) and epson s1d1335 graphic
💻 C
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -