fast alternative to set GPIOs

  • Dear Support-Team,


    is there a fast way to set the GPIOs on armstonea9r2 with V3.0?
    Using the /sys/class/gpio filesystem is not usable for "fast" IO changes. Is there the possibility to have direct access through a memory map or a GPIO library ?


    Thanks for your answers.

  • The Linux people seem to have noticed, too, that this is a problem, and the next mainline kernel 4.8 will introduce a new way to handle GPIOs via character devices. Then you can define GPIO groups and read and write values for each group in one go. But unfortunately for now we will have to stick with the sysfs way.


    But I think this is not too bad if used correctly. Actually you only need to configure each GPIO once. Later you can keep a file handle (descriptor) to the "value" file open and just need to write one value after the other. And if you open() the file with O_SYNC (or O_RSYNC for input lines) before, you don't even have to mess with any fsync() commands. So one open file descriptor for every GPIO that you want to handle.


    And I believe you can even use mmap() to map the "value" file into RAM. As the value itself is only one digit, it should be sufficient to write the one byte as '1' or '0'. But then you might need msync(M_SYNC) to actually send the data to the file, i.e. actually output it.


    For input lines you can also use function poll() on the "value" file descriptor to be asynchronously informed on any changes (like an interrupt), which is -- despite the name -- an interrupt driven procedure. Then you do not need to poll actively for a value change.


    But in general you should be aware that handling GPIO lines from user space is not meant for any real high speed I/O. If you need this, you should consider writing a device driver for your specific purpose.


    Your F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.