linux2.22.6内核驱动,应用层跟驱动通讯之----用中断,休眠,唤醒机制读取按键状态

该博客详细介绍了如何在Linux 2.22.6内核中编写驱动程序,以使用中断、休眠和唤醒机制来读取按键状态。应用层通过打开设备文件并与驱动进行交互,而驱动部分配置了GPIO引脚,注册中断处理函数,并实现了中断触发时唤醒等待进程的功能。
摘要由CSDN通过智能技术生成

应用层:


#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>


/* thirddrvtest 
  */
int main(int argc, char **argv)
{
int fd;
unsigned char key_val;

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


while (1)
{
//read(fd, &key_val, 1);
//printf("key_val = 0x%x\n", key_val);
sleep(5);
}

return 0;
}

--------------------------------------------------------------------------------------------------------------------

linux内核2.22.6驱动部份:

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值