中断底半部及工作队列的用法

使用场景:

a)如果一个任务对时间非常敏感,将其放在中断处理程序中执行。
b)如果一个任务和硬件相关,将其放在中断处理程序中执行。
c)如果一个任务要保证不被其他中断(特别是相同的中断)打断,将其放在中断处理程序中执行。
d)其他所有任务,考虑放在下半部去执行。

e)不能睡眠

 

#include <linux/of.h>

#include <linux/of_address.h>

#include <linux/of_device.h>

#include <linux/of_gpio.h>

#include <linux/of_irq.h>

#include <linux/rtpm_prio.h>

static unsigned int ft_touch_irq=0

static unsigned int hf_flag=0

staic DECLARE_WAIT_QUEUE_HEAD(waiter);

void led_tasklet_action(void);

DECLARE_TASKLET(test_tasklet,led_tasklet_action,0);

 

staic irqreturn_t eint_interrupt_handler(int irq,void *dev_id)

{

tasklet_schedule(&test_tasklet);

return IRQ_HANDLED;

}

 

static int irq_registration(void)//最好写在probe

{

struct device_node *node=NULL;

int ret=0;

u32 ints[2]={0,0};

node = of_find_matching_node(node,touch_of_match);

if(node){

of_property_read_u32_array(node,”debounce”,ints,ARRAY_SIZE(ints));

gpio_set_debounce(ints[0],ints[1]);

ft_touch_irq=irq_of_parse_and_map(node,0);

ret=request_irq(ft_touch_irq,eint_interrupt_handler,IRQF_TRIGGER_RISING,”TOUCH_PANEL-eint”,NULL);

}

else{

printk(“can not find eint device node!”);

}

return 0;

}

 

void led_tasklet_action(void)

{

......

......

......//执行代码

}

 个人原创,可直接复制在代码中使用,请勿转载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值