UCM-iMX95 Yocto Linux: GPIO

From Compulab Mediawiki
Revision as of 15:54, 9 January 2025 by Igor (talk | contribs) (Created page with "== Example: controlling pin 2 of header P15 == '''Exporting the pin in sysfs'''</br> <pre> cd /sys/class/gpio/ echo 517 > export cd gpio517 </pre> Now pin is assigned to sysfs...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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