Gpio 'interrupt'



  • Hi,

    On our i.MX27 based device, we have another device that is coupled on one of the gpio's of the processor. I manage to read the input via /sys/class/gpio/gpioXXX/value. I'm detect changes on the input by polling the 'value' file. However, the connected device is e.g. sending heartbeat pulses of about 16 usec, every 100msec . To detect them, I have to perform polling very fast, resulting in high (and not acceptable) processor loads. The goal is to have a kind of interrupt : when the input changes, I have to emit a signal to indicate the detection of a rising/falling edge of the signal on the input. Can I do this in another way ? Not using polling, but a kind of blocking read of the gpio file ? Anyone has done this already within qt ?

    (I tried with the readyRead signal of QFile(QIODevice), but the connected slot was never called. Probably because there's no data appended to the gpio file, the content of the file - one byte - gets only modified).

    Thanks for any help !

    Filip



  • Probably "QFileSystemWatcher":http://developer.qt.nokia.com/doc/qt-4.8/qfilesystemwatcher.html is what you are looking for, but I cannot guarantee that it works (reliable) with /sys/class/gpio. If not, the next step downwards would be inotify resp. poll / select.

    However, 16 ┬Ásec can be a very short timeframe, especially if there is additional load. So if catching the heartbeat is vital, you might even go one step futher downwards and directly utilize the interrupt controller, which for sure supports at least one GPIO interrupt.



  • Thanks for the information.

    I tried with QFileSystemWatcher, but without success. The slot connected to it never gets called although the heartbeat pulses are present on the input. I guess it does not really check on modification of the content of the file. I think the 'value' file I read is a kind of special file, because even if the content changes, the file date seems never be updated. To the user, it looks like the file never changes. And probably because of this, QFileSystemWatcher, never detects modifications.
    I noticed, in the same directory /sys/class/gpio/gpioxxx/, a file called uevent. I have to investigate what this file can be used for. Have no experience with it. It looks like something to report events on that input, so maybe that's what I'm looking for...
    Of course, I will also investigate the other ideas you mentioned.



  • [quote author="filip" date="1326814262"]
    I will also investigate the other ideas you mentioned.[/quote]

    Make sure you've read the "documentation":http://kernel.org/doc/Documentation/gpio.txt first.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.