GPIO that enable Interrupt and write string on console

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

GPIO that enable Interrupt and write string on console

跳至解决方案
1,325 次查看
enaud
Contributor III

hi,

how modified mx53_loco.c for to obtain an interrupt from a GPIO(is a button) and when is enabled write a string on Console?

i have found this from the web:

static irqreturn_t button_interrupt(int irq, unsigned long data)

{

printk(KERN_INFO "Hello World\n");

tasklet_schedule(&my_tasklet);

return IRQ_HANDLED;

}

static int __init hello_start(void)

{

int ret;

printk(KERN_INFO "Loaded hello module....\n");

ret = request_irq(gpio_to_irq(163), button_interrupt,

   IRQF_DISABLED | IRQF_TRIGGER_FALLING,

   "hello", NULL);

if(ret){

  printk(KERN_ERR "Failed to request IRQ\n");

  return ret;

}

return 0;

}

I dont undstand this code:  tasklet_schedule(&my_tasklet);

GPIO is 6_3 with interrupt 105.

cat value -----> 0 when is pressed; 1 when isnt pressed.

Where i must put this code in my mx53_loco.c?

Thanks

标签 (1)
0 项奖励
回复
1 解答
926 次查看
AlejandroSierra
NXP Employee
NXP Employee

Where are you defining the GPIO pin in you code? you should use DEFINE function called IMX_GPIO_NR(6, 3)

tasklet_schedule function means that you are starting a tasklet or "small thread" on the kernel to attend the ISR without blocking the whole system.

在原帖中查看解决方案

0 项奖励
回复
1 回复
927 次查看
AlejandroSierra
NXP Employee
NXP Employee

Where are you defining the GPIO pin in you code? you should use DEFINE function called IMX_GPIO_NR(6, 3)

tasklet_schedule function means that you are starting a tasklet or "small thread" on the kernel to attend the ISR without blocking the whole system.

0 项奖励
回复