#define KB_ROWS 4
#define KB_COLS 3
#define SCANCODE(r,c) (((r)<<4) + (c) + 1 )
#define KB_ROWMASK(r) (1 << (r))
#define XNKBD_PRESSED 1
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define XNKBD_PRESSED 1
static void xnkbd_activate_all(void)
{
__raw_writeb( 0xf ,KEY_SWEEP_ADDR);
}
static void xnkbd_activate_col( unsigned int col)
{
__raw_writeb(((1<
}
static void xnkbd_reset_col(int col)
{
__raw_writeb(((1<
}
static unsigned char get_row_status( unsigned char c)
{
return __raw_readb(KEY_STATUS_ADDR);
}
int xn_get_key()
{
unsigned int row, col, rowd, scancode;
__raw_writeb(0xf,KEY_SWEEP_ADDR);
for(col = 0; col < KB_COLS; col++) {
xnkbd_activate_col(col);
udelay(10);
rowd = get_row_status(col);
//printf("rowd = 0x%x, rowd2 = 0x%x\n", rowd, rowd&0x7);
for(row = 0; row < KB_ROWS; row++) {
scancode =SCANCODE(row,col);
if ((rowd & KB_ROWMASK(row))) {
udelay(200000);
rowd = get_row_status(col);
if ((rowd & KB_ROWMASK(row)))
return scancode;
}
}
xnkbd_reset_col(col);
}
xnkbd_activate_all();
return 0;
}
阅读(1891) | 评论(0) | 转发(1) |