From: Nitin Kulkarni <nitink@kth.se>
To: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: [Xenomai] GPIO Interrupt is registered in Xenomai but handler is not invoked when triggered
Date: Mon, 29 May 2017 20:27:41 +0000 [thread overview]
Message-ID: <1496089661516.77105@kth.se> (raw)
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");
reply other threads:[~2017-05-29 20:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1496089661516.77105@kth.se \
--to=nitink@kth.se \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.