外部中断按键驱动程序编写
来源:互联网 发布:c高级编程 编辑:程序博客网 时间:2024/05/12 09:50
//包含必须的头文件
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/interrupt.h>
//#include <linux/delay.h>
//#include <asm/uaccess.h>
#include <asm/arch/regs-gpio.h>
#include <asm/hardware.h>
//定义常用的变量
#define device_name
#define device_major 231
#define irq
static int
//打开函数 不起什么作用,可以不要
static
{
}
//关闭函数 不起什么作用
static int irq_close(struct inode *inode, struct file *file)
{
}
//中断服务子程序
static irqreturn_t irq_interrupt()
{
}
//之前这里的返回类型用了void,以至于在运行按键中断模块的时候,一直出现
//如下错误:
# insmod myirq.ko
Irq init_module success!!
Now key interrput occur 1 times!!
irq event 17: bogus return value 25
[<c002adac>] (dump_stack+0x0/0x14) from [<c0061220>] (__report_bad_irq+0x38/0x94)
[<c00611e8>] (__report_bad_irq+0x0/0x94) from [<c00612cc>] (note_interrupt+0x50/0x240)
[<c006127c>] (note_interrupt+0x0/0x240) from [<c006200c>] (handle_edge_irq+0x120/0x144)
[<c0061eec>] (handle_edge_irq+0x0/0x144) from [<c0026048>] (asm_do_IRQ+0x48/0x60)
[<c0026000>] (asm_do_IRQ+0x0/0x60) from [<c0026a64>] (__irq_svc+0x24/0xa0)
Exception stack(0xc39cde2c to 0xc39cde74)
de20:
de40: 40000013 00000011 c3e326e0 00000000 c3df9198 00000000 c39cde94 c39cde50
de60: c39cde74 c0061ab0 c0060fb0 a0000013 ffffffff
[<c0060e28>] (setup_irq+0x0/0x1cc) from [<c00611cc>] (request_irq+0xb4/0xd0)
[<c0061118>] (request_irq+0x0/0xd0) from [<bf00205c>] (irq_init+0x5c/0x78 [myirq])
[<bf002000>] (irq_init+0x0/0x78 [myirq]) from [<c005e2b8>] (sys_init_module+0x1404/0x149c)
[<c005ceb4>] (sys_init_module+0x0/0x149c) from [<c0026e60>] (ret_fast_syscall+0x0/0x2c)
handlers:
[<bf000040>] (irq_interrupt+0x0/0x34 [myirq])
/ #
当中断服务函数返回类型改为 irqreturn_t时,在运行模块就一切KO了!如下:
# Now key interrput occur 1 times!!
Now key interrput occur 2 times!!
Now key interrput occur 3 times!!
Now key interrput occur 4 times!!
Now key interrput occur 5 times!!
Now key interrput occur 6 times!!
Now key interrput occur 7 times!!
Now key interrput occur 8 times!!
Now key interrput occur 9 times!!
Now key interrput occur 10 times!!
//文件操作结构的填充
struct file_operations irq_fops=
{
};
//init.exit等函数
static int __init irq_init(void)
{
}
static void __exit clean_irq(void)
{
}
module_init(irq_init);
module_exit(clean_irq);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("ALV");
- 外部中断按键驱动程序编写
- 中断-----按键中断驱动程序
- Hi3515按键中断驱动程序
- ok6410按键中断驱动程序
- 按键中断驱动程序
- 中断按键驱动程序
- Hi3515按键中断驱动程序
- 外部中断按键驱动
- 按键与外部中断
- TMS320F28335---外部按键中断
- STM32按键扫描/按键中断/外部中断
- Hi3515按键中断驱动程序(完整版)
- Hi3515按键中断驱动程序(完整版)
- tiny6410_按键驱动程序_中断
- mini240外部按键中断程序
- mini240外部按键中断程序
- 外部中断(按键1)
- S3C2440 外部按键中断解析
- 《大话存储2:存储系统架构与底层原理极限剖析》电子书下载
- ZOJ 2725 SG函数 DP
- 相机标定(1)---初识相机标定 标定的含义,意义
- VMware vSphere 5.1 各种ISO文件大集合[文件数:135][47.6 GB][含激活KEY]
- CALayer1-简介
- 外部中断按键驱动程序编写
- 游戏AI之有限状态机(1)
- Share a link about Resposive Web Design
- NYOJ-死神来了
- hdu1162 Eddy's picture (最小生成树之prim 算法)
- 路由/协议系列--持续更新
- POJ1678 I Love this Game!
- 喵星战争(七):游戏分数的实现
- 《虚拟智慧:VMware vSphere运维实录》(附光盘)下载