On Debian distribution install the Python3 libgpiod libraries by typing:
sudo apt update
sudo apt install python3-libgpiod
# GPIO used PA17
import gpiod
import time
chip=gpiod.Chip('gpiochip0')
line = gpiod.find_line("PA17")
lines = chip.get_lines([line.offset()])
lines.request(consumer='foobar', type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0])
while True:
lines.set_values([1])
time.sleep(1)
lines.set_values([0])
time.sleep(1)
With this loop is possible to generate a 42kHz square signal on a GPIO line using a Roadrunner SOM @ 500mHz
while True:
lines.set_values([1])
lines.set_values([0])
# GPIO used PD30
import gpiod
import time
chip = gpiod.Chip('gpiochip0')
line = gpiod.find_line("PD30")
lines = chip.get_lines([line.offset()])
lines.request(consumer='foobar', type=gpiod.LINE_REQ_DIR_IN)
while True:
print(lines.get_values())
time.sleep(1)
print(lines.get_values())
time.sleep(1)
Lauch the python3 interpreter
python3
then type:
>>> import gpiod
>>> help(gpiod)
On Debian distribution install the libgpiod libraries and build essential tools by typing:
sudo apt update
sudo apt install libgpiod-dev build-essential
Install git
sudo apt git
Then clone where you can find some lite examples (https://github.com/starnight/libgpiod-example):
git clone https://github.com/starnight/libgpiod-example
With this loop is possible to generate a 300kHz square signal on a GPIO line using a Roadrunner SOM @ 500mHz
val = 0;
for (i = 10000; i > 0; i--) {
ret = gpiod_line_set_value(line, val);
val = !val;
}