User manual
UDOO Starting manual (beta) Version 0.3
http://www.udoo.org/
28"
5.3. i.MX6 GPI/O Management
i.MX6 can handle external pins in many different ways. In default configuration, they
can be accessed from user level through the standard Kernel Linux interface.
Some of them can be configured for specific functionalities provided by i.MX6
architecture, like
spi, i2c, i2s, audiomux, pwms output, UARTs and so on.
In next sections it will be described the way to use such functionalities.
When a pin is set as a GPIO, it is possible to read its value, change its direction or
change output value directly from console.
All available GPIOs are managed by the kernel, and it is possible to access them
simply by reading or writing value in specific files placed in a specific folder.
In the /sys/class/gpio/ folder there are other sub-folders, one for each manageable
GPIO. Each sub-folder contains files that indicate:
● direction (in / out)
● value (0 / 1)
To read a GPIO direction:
cat /sys/class/gpio/gpioXX/direction
In or Out output is now expected
To change the pin direction:
echo out > /sys/class/gpio/gpioXX/direction
or
echo in > /sys/class/gpio/gpioXX/direction
It is possible to do the same for values read or written on the pin.
To read a pin (the value read will be correct only if pin’ s direction is set as input): :
cat /sys/class/gpio/gpioXX/value
0 or 1 output is expected
To write a value on a pin:
echo 0 > /sys/class/gpio/gpioXX/value
or
echo 1 > /sys/class/gpio/gpioXX/value