Skip to contentSkip to conversation

gpio-keys with xenomai

Xenomai-help Peter Breuer 3 participants 3 messages Mar 17, 2010 – Mar 18, 2010

lore
Share & tools
lore
#0 lore raw

Hello everyone,
I am new to xenomai, so please be patient.
I am working with an AT91SAM9621S (Board SBC6000X) and I successfully patched my linux 2.6.24 with xenomai 2.4.9.1. I also have a signal on on of the GPIOs and I want a program to react, every time the signal arrives (~10Hz).
Before compiling I added some lines to the board description file (arch/arm/mach-at91/board-sbc9621.c):
...
static struct gpio_keys_button sbc9261_buttons[] = {
...
//begin changes

    {
        .gpio        = AT91_PIN_PC4,
        .code        = BTN_2,
        .desc        = "GPIO 1",
        .active_low    = 1,
    },

//end changes
};
...
static void __init sbc9261_add_device_buttons(void) {
...
//begin changes

    at91_set_gpio_input(AT91_PIN_PC4, 1);    /* btn1 */
    at91_set_deglitch(AT91_PIN_PC4, 1);

//end changes

    platform_device_register(&sbc9261_button_device);
}

Now a new event showed up in /dev/input/
Without the xenomai patch there was an interrupt, that I could listen to with a program (open(/dev/input/event2) and select for listening) and react to the signal.
With the xenomai patch nothing is coming trough, and even though GPIO 1 still shows up in /proc/interrupts, it doesnt show up
in /proc/xenomai/irq.
I tried to use the native API (I used the usr_irq.c) to create and wait for the signal, but nothin happend (rt_intr_wait() returned -1). I would be very happy about every hint in the right direction. greetings,
Peter

#1 lore raw
Quoted 29 lines · Peter Breuer

Hello everyone,
I am new to xenomai, so please be patient.
I am working with an AT91SAM9621S (Board SBC6000X) and I successfully patched my linux 2.6.24 with xenomai 2.4.9.1. I also have a signal on on of the GPIOs and I want a program to react, every time the signal arrives (~10Hz).
Before compiling I added some lines to the board description file (arch/arm/mach-at91/board-sbc9621.c):
...
static struct gpio_keys_button sbc9261_buttons[] = {
...
//begin changes

    {
        .gpio        = AT91_PIN_PC4,
        .code        = BTN_2,
        .desc        = "GPIO 1",
        .active_low    = 1,
    },

//end changes
};
...
static void __init sbc9261_add_device_buttons(void) {
...
//begin changes

    at91_set_gpio_input(AT91_PIN_PC4, 1);    /* btn1 */
    at91_set_deglitch(AT91_PIN_PC4, 1);

//end changes

Quoted 7 lines
    platform_device_register(&sbc9261_button_device);
}

Now a new event showed up in /dev/input/
Without the xenomai patch there was an interrupt, that I could listen to with a program (open(/dev/input/event2) and select for listening) and react to the signal.

That is one thing. It could be due to a edge vs level issue. First when you tell this, you must be 100% sure that you are exactly using the same configuration except for the xenomai settings. Second, please try and recompile a kernel with only CONFIG_IPIPE enabled, but not with CONFIG_XENOMAI.

Quoted 3 lines

With the xenomai patch nothing is coming trough, and even though GPIO 1 still shows up in /proc/interrupts, it doesnt show up
in /proc/xenomai/irq.

That is not your problem. Irqs appear in /proc/xenomai/irq only when the IRQ is used in the real-time domain.

Quoted 2 lines

I tried to use the native API (I used the usr_irq.c) to create and wait for the signal, but nothin happend (rt_intr_wait() returned -1).

That is yet another story. Error codes are documented in the API documentation. -1 is -EPERM. It usually means that the task calling the function is not a real-time task and should be one.

Quoted 11 lines

I would be very happy about every hint in the right direction. greetings,
Peter

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 4 lines
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#2 lore raw
In reply to Peter Breuer
Quoted 32 lines · Peter Breuer

Hello everyone,
I am new to xenomai, so please be patient.
I am working with an AT91SAM9621S (Board SBC6000X) and I successfully patched my linux 2.6.24 with xenomai 2.4.9.1. I also have a signal on on of the GPIOs and I want a program to react, every time the signal arrives (~10Hz).
Before compiling I added some lines to the board description file (arch/arm/mach-at91/board-sbc9621.c):
...
static struct gpio_keys_button sbc9261_buttons[] = {
...
//begin changes

    {
        .gpio        = AT91_PIN_PC4,
        .code        = BTN_2,
        .desc        = "GPIO 1",
        .active_low    = 1,
    },

//end changes
};
...
static void __init sbc9261_add_device_buttons(void) {
...
//begin changes

    at91_set_gpio_input(AT91_PIN_PC4, 1);    /* btn1 */
    at91_set_deglitch(AT91_PIN_PC4, 1);

//end changes

    platform_device_register(&sbc9261_button_device);
}
Quoted 10 lines

Now a new event showed up in /dev/input/
Without the xenomai patch there was an interrupt, that I could listen to with a program (open(/dev/input/event2) and select for listening) and react to the signal.
With the xenomai patch nothing is coming trough, and even though GPIO 1 still shows up in /proc/interrupts, it doesnt show up
in /proc/xenomai/irq.
I tried to use the native API (I used the usr_irq.c) to create and wait for the signal, but nothin happend (rt_intr_wait() returned -1). I would be very happy about every hint in the right direction.

rt_intr_wait() should be called from a real-time task, obtained from rt_task_create/spawn; failure to do so causes the Xenomai core to dismiss your request with -EPERM.

There is a simple rule of thumb to know whether a Xenomai syscall shall be called from a real-time task: if a Xenomai service may block the caller, or has an effect on some of its dynamic properties (like its real-time scheduling priority, some of its runtime options or current execution mode within the Xenomai domain etc.), then it may only be called on behalf of a real-time task.

Additionally, you should call rt_intr_enable() to explicitly unmask the interrupt channel, since it is left masked upon creation. Maybe that is what is missing (user_irq.c is wrong in this respect) to get the first IRQ.

Quoted 9 lines

greetings,
Peter

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 1 line
Philippe.