All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] GPIO Interrupt is registered in Xenomai but handler is not invoked when triggered
@ 2017-05-29 20:27 Nitin Kulkarni
  0 siblings, 0 replies; only message in thread
From: Nitin Kulkarni @ 2017-05-29 20:27 UTC (permalink / raw)
  To: xenomai@xenomai.org

Hello all,

I am new to Xenomai and I am trying to run a simple interrupt handler set up for a GPIO .

I have successfully set up and ran without ipipe and Xenomai patched.

But when I use the RTDM interfaces rtdm_irq_request() to set up a handler, it is registered and shows when I do cat /proc/xenomai/irq

but the handler is not invoked when I trigger the gpio pin.


Other thing I have observed is, after patching ipipe & Xenomai when I set up a usual linux irq handler using request_irq() ,

the handler is invoked continuously and the interrupt doesn't seem to be cleared after executing the handler once although I

am using an edge triggered interrupt.


I have seen similar issues posted but most of the solutions I found are specific to HW (usually ARM).

I am using an Intel Joule running Linux 4.4.43 kernel.. Did anyone face similar issues on x86 arch ?


Please suggest what I might be missing. Find my code below since I couldn't attach the file because my mail exchange server complained :/


Regards ,

Nitin?




#include <linux/gpio.h>
#include <linux/module.h>
#include <rtdm/driver.h>
#include <rtdm/rtdm.h>
#include <linux/interrupt.h>


MODULE_DESCRIPTION("RTDM driver for Intel Joule GPIO");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Nitin Kulkarni");
MODULE_VERSION("1.0");

static unsigned int irq_num;
static unsigned int gpioLED = 340;
static unsigned int gpioButton = 343;
static bool value = false;
static rtdm_irq_t irq_handle;
static int num_of_intr = 0;

static int gpio_irq_handler(rtdm_irq_t * irq)
{
value = !value;
gpio_set_value(gpioLED, value); // toggle the led everytime irq handler is invoked
        printk("GPIO interrupt \n");
num_of_intr++;
return RTDM_IRQ_HANDLED;
}


static int __init rtdm_init (void)
{
int err;
if ((err = gpio_request(gpioButton, THIS_MODULE->name)) != 0) {
printk(" gpio_request gpioButton failed ! \n");
return err;
}

if ((err = gpio_direction_input(gpioButton)) != 0) {

printk(" gpio_direction_input gpioButton failed ! \n");
gpio_free(gpioButton);
                return err;
}

irq_num = gpio_to_irq(gpioButton);

printk(" IRQ number %d !  \n",irq_num);

if ((err = gpio_request(gpioLED, THIS_MODULE->name)) != 0) {

printk(" gpio_request gpioLED failed ! \n");
gpio_free(gpioButton);
return err;
}

if ((err = gpio_direction_output(gpioLED, 0)) != 0) {

printk(" gpio_direction_input gpioLED failed ! \n");
gpio_free(gpioLED);
gpio_free(gpioButton);
return err;
}

err = irq_set_irq_type(irq_num,  IRQF_TRIGGER_RISING);

if(err)
{
gpio_free(gpioLED);
gpio_free(gpioButton);
printk(" irq_set_irq_type failed ! \n");
return err;
}

err = rtdm_irq_request(&irq_handle,irq_num,(rtdm_irq_handler_t)gpio_irq_handler, RTDM_IRQTYPE_EDGE,THIS_MODULE->name, NULL);

printk("after request irq = %d \n",irq_handle.irq);

if(err)
{
gpio_free(gpioLED);
gpio_free(gpioButton);?
printk(" rtdm_irq_request failed ! \n");
return err;
}

err = rtdm_irq_enable(&irq_handle);

if (err < 0) {
printk("rtdm_irq_enable failed \n");
return err;
}
return 0;
}



static void __exit rtdm_exit (void)
{
rtdm_irq_free(&irq_handle);
gpio_free(gpioLED);
gpio_free(gpioButton);

printk("The number of intr is %d \n",num_of_intr);
}


module_init(rtdm_init);
module_exit(rtdm_exit);
MODULE_LICENSE("GPL");




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-29 20:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-29 20:27 [Xenomai] GPIO Interrupt is registered in Xenomai but handler is not invoked when triggered Nitin Kulkarni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.