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

📄 keyboard.c

📁 s3c44b0的lcd-driver 可以运行
💻 C
字号:
/*
 *************************************************************************
 * 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;
}   

⌨️ 快捷键说明

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