Beaglers:
   I've just created some gpiod examples in both C and python.  You can get 
to them via:

bone$ *cd /var/lib/cloud9*
bone$ *git pull*
bone$ *git checkout v2020.08*
bone$ *cd BeagleBone/Black/gpiod*
bone$ *sudo apt update; sudo apt install libgpiod-dev*

(Or go to 
https://github.com/beagleboard/cloud9-examples/tree/v2020.08/BeagleBone/Black/gpiod
)

Here's the ReadMe.md

libgpiod is a new C library and tools for interacting with the linux GPIO 
character device. Detailed information is here 
<https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/README> and 
Adafruit 
<https://blog.adafruit.com/2018/11/26/sysfs-is-dead-long-live-libgpiod-libgpiod-for-linux-circuitpython/>
 also 
has information.

One of the advantages of gpiod is that it can toggle multiple bits on the 
same gpio chip at the same time. The toggle2 examples show how it's done.

The directory contains examples of using gpiod with *C* and *python* to 
read/write a gpio pin.
FileDescription
toggle1 
<https://github.com/beagleboard/cloud9-examples/blob/v2020.08/BeagleBone/Black/gpiod/toggle1.c>
Toggles one pin as fast as possible. (300KHz in C, 57KHz in python)
toggle2 
<https://github.com/beagleboard/cloud9-examples/blob/v2020.08/BeagleBone/Black/gpiod/toggle2.c>
Toggles two pins as fast as possible. (280KHz in C, 55KHz in python)
get 
<https://github.com/beagleboard/cloud9-examples/blob/v2020.08/BeagleBone/Black/gpiod/get.c>
Reads an input pin and prints its value.
getset 
<https://github.com/beagleboard/cloud9-examples/blob/v2020.08/BeagleBone/Black/gpiod/getset.c>
Reads an input pin and writes its value to an output pin. (5us delay in C, 
20 us Delay in python)
getsetEvent 
<https://github.com/beagleboard/cloud9-examples/blob/v2020.08/BeagleBone/Black/gpiod/getset.c>
Like *getset*, but uses events. (40 us delay in C, 75 us delay in python)
toggleLED 
<https://github.com/beagleboard/cloud9-examples/blob/v2020.08/BeagleBone/Black/gpiod/toggleLED.c>
Toggles the four built in USR LEDs.

Tip: Use *gpioinfo* to lookup chip and line numbers for various pins.


Feedback is welcome.

--Mark

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/4e673149-b692-493c-ade0-aa964f7b0a1dn%40googlegroups.com.

Reply via email to