Пример #1
0
/********************************************************************
* 名称 : Main()
* 功能 : 主函数
* 输入 : 无
* 输出 : 无
***********************************************************************/
void Main(void)
{
	uchar Key_Value;  //读出的键值
	L1602_init();
	L1602_string(1,1,"  4*4 KeyBoard  ");
	L1602_string(2,1,"You Press The    ");
	while(1)
	{
		P1 = 0xf0;
		if(P1 != 0xf0)
		{
			Delay_1ms(20);	//按键消抖
			if(P1 != 0xf0)
			{
				Delay_1ms(20);	//按键消抖
				if(P1 != 0xf0)
				{
					Key_Value = Keyscan();		
				}
			}
		}
		L1602_char(2,15,Key_Value / 10 + 48);
		L1602_char(2,16,Key_Value % 10 + 48);		
	}
}
Пример #2
0
static ssize_t device_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos)
{
	int ret = 0;
	int i;
	char mem[20];
	
	ret = copy_from_user(mem, buf, count);
	if(ret < 0)
	{
		printk("Error copy from user! \n");
	}
	for( i=0 ; i<count-2 ; i++)
	{
		L1602_char(mem[0], mem[1]+i, mem[i+2]);
	}
	printk("In tht write function.\n");
	printk("%d %d %c\n", mem[0], mem[1], mem[2]);
	return ret;
}