Chinaunix首页 | 论坛 | 博客
  • 博客访问: 315146
  • 博文数量: 135
  • 博客积分: 867
  • 博客等级: 准尉
  • 技术积分: 865
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-15 14:50
文章分类

全部博文(135)

文章存档

2012年(135)

分类:

2012-09-19 11:40:04

原文地址:UBOOT 键盘防抖测试 作者:iibull



#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;
}

阅读(800) | 评论(0) | 转发(0) |
0

上一篇:UBOOT ADC 驱动流程

下一篇:UBOOT 串口测试

给主人留下些什么吧!~~