Welcome, Guest

Author Topic: OlinuXino GPIO events?  (Read 5481 times)

idragoev

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
OlinuXino GPIO events?
« on: November 27, 2012, 07:01:34 PM »
Hi,
we have a program that needs to work with GPIOs. We have to track when a GPIO configured as input has a new value. We have 2 options: to use /sys/class/gpio or using gpio-mmap.h. I have the following questions regarding GPIOs:
 1. If we use /sys/class/gpio, how can we achieve this without using pooling to check for new value? I will appreciate some examples
 2. If we use gpio-mmap.h, how can we extend it to have a function that accepts a callback as parameter so when a new values is set to the GPIO the callback is called?
 3. are there other ways of handling value change on GPIO inputs?

thanks in advance,
Ivan

jeroends

  • Jr. Member
  • **
  • Posts: 76
  • Karma: +2/-0
Re: OlinuXino GPIO events?
« Reply #1 on: November 27, 2012, 07:34:49 PM »
Have a look at the following site: https://www.ridgerun.com/developer/wiki/index.php/How_to_use_GPIO_signals.
They explain how to use the /sys/class/gpio interface in "C" and "shell" using interrupts. It's a good base to start. It's explained for another board but it works for the Olinuxino as well (U don't have to reconfigure the kernel).

dpwhittaker

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: OlinuXino GPIO events?
« Reply #2 on: November 28, 2012, 04:26:30 PM »
Gpio-mmap won't trigger an interrupt (well, you could make it trigger one, but you can't catch it in user space).  You'd have to poll for the value (manually, like in a loop).  Using poll (the syscall) on a sys/class/gpio is the most efficient way to watch for gpio changes currently.

Somewhere down my list is a kernel driver that watches a set of gpios, blocks reads on a char device until a change occurs, and gives you the timestamp at the moment of the interrupt when you do get around to reading it, but that is probably a month or two off.

Oclistediscussion

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: OlinuXino GPIO events?
« Reply #3 on: December 05, 2012, 10:29:41 PM »
Hi,
we have a program that needs to work with GPIOs. We have to track when a GPIO configured as input has a new value. We have 2 options: to use /sys/class/gpio or using gpio-mmap.h. I have the following questions regarding GPIOs:
 1. If we use /sys/class/gpio, how can we achieve this without using pooling to check for new value? I will appreciate some examples
 2. If we use gpio-mmap.h, how can we extend it to have a function that accepts a callback as parameter so when a new values is set to the GPIO the callback is called?
 3. are there other ways of handling value change on GPIO inputs?

thanks in advance,
Ivan

In debian i use inotify/incron (Sorry for french) :
http://www.sysadmin-fr.org/fr/linux/incron


dpwhittaker

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: OlinuXino GPIO events?
« Reply #4 on: December 07, 2012, 04:07:12 PM »