It is Gpio Interrupts code.
I need to use button(BTN) to generate interrupt.
My application
when i press the switch( SW2) then interrupt is generate and led should will glow.
This Problem is that i am testing this code on EVM,we using SW2 (BUTTON/SWITCH), I am facing problem in finding SW2 pin no. i have gone through dm368 evm schematics SW2 is connected to PWCTRIO0
WHAT IS THE PIN NO. OF PWCTRIO0...?
Should i need to change any thing in board file......?
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/gpio.h>
#include<linux/interrupt.h>
#include<linux/irq.h>
#include<asm/irq.h>
#define BTN ? //PWCTRIO0 IN NEED PIN NO.
#define LED 103
irqreturn_t button_irq(int irq_no,void *dev)
{
static int flag=0;
flag ^= 1;
gpio_set_value(LED,flag);
printk(KERN_INFO "This is ISR\n");
return IRQ_HANDLED;
}
static int __init mydev_init(void)
{
int req,res;
printk(KERN_ALERT "This is init function\n");
req=gpio_request(LED,"led1");
if(req < 0)
{printk(KERN_ALERT "unable to request GPIO\n");}
gpio_direction_output(LED,0); // led1; initially set to on
res=request_irq(gpio_to_irq(BTN), button_irq, IRQ_TYPE_EDGE_RISING, "btn1", NULL); // IRQF_TRIGGER_RISING
if(res < 0)
{printk(KERN_ALERT "Interrupt request is failed\n");}
return 0;
}
static void __exit mydev_exit(void)
{
printk(KERN_ALERT "This is exit function\n");
free_irq(gpio_to_irq(BTN),NULL);
gpio_free(LED);
}