GPIO that enable Interrupt and write string on console

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GPIO that enable Interrupt and write string on console

Jump to solution
1,053 Views
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

Labels (1)
0 Kudos
1 Solution
654 Views
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.

View solution in original post

0 Kudos
1 Reply
655 Views
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 Kudos