08-19-2020, 04:41 PM
Hello,
With pleasure. I have uploaded it once in this post:
https://forum.pine64.org/showthread.php?...7#pid49547
I am attaching again here for convenience (file GPIOsrc.tar). I have been busy with other tasks, so have not developed it further. It is still in experimental phase and documentation is still very ‘sparse’...
GPIOsrc.tar (Size: 180 KB / Downloads: 489)
I have to admit, that I tested the standard fs-interface again on another board, with the Allwinner A20 processor. This time I have operated the interface files directly from C-code. It means, I opened the interface files, like e.g. /sys/class/gpio/gpio86/value, and then written or read using the file descriptor. The resulting speed of operations was much, much higher than in tests performed with Shell commands. So maybe scripts (Shell or Python) are so slow in interaction with the files, and not the interface itself. The only peculiarity in C is during reading: It is necessary to seek to the beginning each time before reading new value. But it is still very fast.
So maybe it is not worthy to operate directly on registers. I will compare it on the A20 board, once I have some time. The standard interface has important advantages: It takes care of race conditions and allows using interrupts (async reading with select()).
And there is also the 'new standard' - The character-device interface (libgpiod). But I have not tried it, so far.
Best regards,
Gienek.
With pleasure. I have uploaded it once in this post:
https://forum.pine64.org/showthread.php?...7#pid49547
I am attaching again here for convenience (file GPIOsrc.tar). I have been busy with other tasks, so have not developed it further. It is still in experimental phase and documentation is still very ‘sparse’...
GPIOsrc.tar (Size: 180 KB / Downloads: 489)
I have to admit, that I tested the standard fs-interface again on another board, with the Allwinner A20 processor. This time I have operated the interface files directly from C-code. It means, I opened the interface files, like e.g. /sys/class/gpio/gpio86/value, and then written or read using the file descriptor. The resulting speed of operations was much, much higher than in tests performed with Shell commands. So maybe scripts (Shell or Python) are so slow in interaction with the files, and not the interface itself. The only peculiarity in C is during reading: It is necessary to seek to the beginning each time before reading new value. But it is still very fast.
So maybe it is not worthy to operate directly on registers. I will compare it on the A20 board, once I have some time. The standard interface has important advantages: It takes care of race conditions and allows using interrupts (async reading with select()).
And there is also the 'new standard' - The character-device interface (libgpiod). But I have not tried it, so far.
Best regards,
Gienek.