Configure a GPIO pin for interrupt

130 views
Skip to first unread message

Siva

unread,
Feb 11, 2015, 7:06:49 AM2/11/15
to wand...@googlegroups.com
Hi,
 
I am new to Wandboard. I would like to configure a GPIO pin for interrupt. When i receive the interrupt i would like to read the data on GPIO.
 
Please let me know what are all the modifications that i need to do for Kernel and how can i read from user space.
 
Any sample code would be more helpful for better understanding.
 
Thanks,
Siva

Jorge Rodriguez

unread,
Feb 11, 2015, 12:19:31 PM2/11/15
to wand...@googlegroups.com
Hello,
here is a code abstract of what you have to keep on mind for gpio, irq mapping. I developed this code for other board, but you know.... it's Linux.
Once that you get it to work on Wandboard, could you provide us with the code?

    u16     irq, irq_pin, gpio_pin0;
   
    void* addr = ioremap( <port config address> , 4); // map the i/o addresses to kernel high memory
    iowrite32( <port config> , addr);       // write settings for each pin
    iounmap(addr);
     
    irq_pin = <port number>;
    gpio_pin0 = <irq pin number>;
   
    gpio_request_one(gpio_pin0, GPIOF_IN, DRV_NAME " gpio");
    gpio_request_one(irq_pin, GPIOF_IN, DRV_NAME " irq");
    irq = (u16)gpio_to_irq(stTestData.irq_pin);;

    gpio_get_value(gpio_pin0);  // Read gpio
    request_any_context_irq( irq, <ISR function> , IRQF_TRIGGER_FALLING | IRQF_DISABLED, DRV_NAME, (void*)&stTestData );  // Configure ISR
   
    if (!stTestData.irq_enabled)
        enable_irq(stTestData.irq);

   gpio_free(stTestData.gpio_pin0);
   gpio_free(stTestData.irq_pin);


Regards,
Jorge.

--
You received this message because you are subscribed to the Google Groups "Wandboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wandboard+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages