w83977ef_keyboard.c
来自「瑞泰创新的GX-ARM9-2410EP教学实验系统的所有基础实验源代码,内容齐全」· C语言 代码 · 共 117 行
C
117 行
#include <string.h>
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"
#include "w83977af.h"
#include "w83977ef_keyboard.h"
#include "code.h"
static unsigned int efbase = W977_EFIO_BASE;
static unsigned int efio = W977_EFIO_BASE;
static unsigned int iobase[] = { 0x180, 0x280, 0x380, ~0 };
static unsigned int KBC_SEC_ADDR = 0x384;
static unsigned flag = 0;
unsigned int getkey(unsigned int make)
{
int i;
for(i=0; i<(sizeof(_table)/sizeof(_table[0])); i++)
{
if(_table[i].make == make)
return _table[i].key;
}
return 0;
}
int w83977ef_KBC_init(void)
{
int version;
int i=2;
unsigned int readchar;
Delay(0);
Uart_Printf("\n+++++++++++++++++++++++++++++++++++++++++++++++\n");
w977_efm_enter(efbase);
readchar = w977_read_reg(0x20 ,efbase);
Uart_Printf("Addr: %x, reg: %x, data: %x\n",efbase,0x20,readchar);
readchar = w977_read_reg(0x21 ,efbase);
Uart_Printf("Addr: %x, reg: %x, data: %x\n",efbase,0x21,readchar);
w977_select_device(W977_DEVICE_KBC , efbase);
w977_write_reg(0x30, 0x01, efbase);
w977_efm_exit(efbase);
outb(0xAA, W977_BASE + 0x64);
Delay(100);
Uart_Printf(" result of KBC init is %x\n ", inb(W977_BASE + 0x60));
Uart_Printf(" Data in status reg is %x\n ", inb(W977_BASE + 0x64));
Uart_Printf(" -----------------------------------------------\n ");
outb(0xAB, W977_BASE + 0x64);
Delay(100);
Uart_Printf(" KBC init port test is %x\n ", inb(W977_BASE + 0x60));
Uart_Printf(" Data in status reg is %x\n ", inb(W977_BASE + 0x64));
Uart_Printf(" -----------------------------------------------\n ");
outb(0xAE, W977_BASE + 0x64);
Delay(100);
Uart_Printf(" KBC init enable is %x\n ", inb(W977_BASE + 0x60));
Uart_Printf(" Data in status reg is %x\n ", inb(W977_BASE + 0x64));
Uart_Printf(" -----------------------------------------------\n ");
outb(0xFF, W977_BASE + 0x60);
Delay(100);
Uart_Printf(" Result of reset is %x\n ", inb(W977_BASE + 0x60));
Uart_Printf(" Data in status reg is %x\n ", inb(W977_BASE + 0x64));
Uart_Printf(" -----------------------------------------------\n ");
outb(0xF5, W977_BASE + 0x60);
Delay(100);
Uart_Printf(" Result of stop scan is %x\n ", inb(W977_BASE + 0x60));
Uart_Printf(" Data in status reg is %x\n ", inb(W977_BASE + 0x64));
Uart_Printf(" -----------------------------------------------\n ");
while (1)
{
while (inb(W977_BASE + 0x60) != 0xf0);
Delay(100);
// Uart_Printf( "Data is %c \n",getkey(inb(W977_BASE + 0x60)));
//Uart_Printf( "Data is %c \n",inb(W977_BASE + 0x60));
Uart_Printf( "Data is %x \n",inb(W977_BASE + 0x60));
Delay(100);
}
return 1;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?