UCM-iMX95 Yocto Linux: GPIO
Example: controlling pin 2 of header P15
Exporting the pin in sysfs
cd /sys/class/gpio/ echo 517 > export cd gpio517
Now pin is assigned to sysfs. You can view the newly created entry in gpiochip0 by running:
gpioinfo -c 0
Writing to a pin
Set pin direction to output:
echo out > direction
Set pin value to high or low:
echo 1 > value echo 0 > value
Reading from a pin
Set pin direction to input:
echo in > direction
Read the value of the pin from the value file:
cat value