你好,游客 登录 注册 搜索
背景:
阅读新闻

详细注释FL2440按键中断驱动(含poll机制)

[日期:2012-07-13] 来源:Linux社区  作者:bbs598598 [字体:大 中 小]
测试程序

 

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <poll.h>
/* thirddrvtest
  */
int main(int argc, char **argv)
{
int fd,ret;
unsigned char key_val;
struct pollfd fds[1];


fd = open("/dev/buttons", O_RDWR);打开设备
if (fd < 0)
{
printf("can't open!\n");
}


fds[0].fd=fd;
fds[0].events=POLLIN;


while (1)
{
ret=poll(fds,1,5000);//设置5S超时响应
if(ret ==0)
{
printf("time out for 5s .......\n");
}
else
{
read(fd, &key_val, 1);
printf("key_val = 0x%x\n", key_val);
}
}

return 0;
}

linux
相关资讯       FL2440 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款