8279.c

来自「单片机系统中基于8279的键盘扫描程序及显示程序。」· C语言 代码 · 共 64 行

C
64
字号
#include "8279.h"
/************************************************************************/
//ch: the number 0~9  position:the position in led line 0~7
/************************************************************************/
void Display(uchar ch,uchar position)
{
	ComPort = 0x80 + position;
	DataPort = DisplayTable[ch];		
}
/************************************************************************/
/************************************************************************/
void ClearLed( void )
{
	ComPort = 0xdd;                       /*总清除命令*/
  do{
		ACC=ComPort;
	}while(ClearFlag==1);              /*等待清除结束*/
}
/************************************************************************/
/************************************************************************/
bit KeyPress( void )
{
	uchar temp;
	temp = ComPort;
	return ((ComPort&0x0f) == 0) ? 0 : 1;
}
/************************************************************************/
/************************************************************************/
uchar GetKeyCode( void )
{
	uchar tempData = 0x00;
	ComPort = 0x2a;
	if( KeyPress())
	{
		ComPort = 0x40;
		tempData = DataPort;
		tempData &= 0x3f; 
		
		return tempData;		
	}
	return 0x00;
}
/************************************************************************/
/************************************************************************/
void Init8279Dis( void )
{
	ComPort = 0xdd;
	ComPort = 0x00;
}
/************************************************************************/
/************************************************************************/
uchar GetKeyNum( uchar keyCode)
{
	uchar i;
	for( i = 0; i < 10; i++)
	{
		if( keyCode == KeyCodeTable[i])
			return i;
	}
	
	return 0xff;
}
/************************************************************************/
/************************************************************************/

⌨️ 快捷键说明

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