DESK-MX9-L/Peripherals/GPIOs

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes

2024/02/02

DESK-MX9-L-5.0.0 release
2024/05/17 DESK-MX9-L-5.1.0 release



Peripheral GPIOs[edit | edit source]

i.MX93 can handle external pins in many different ways and most of them can be configured as GPIOs. When a pin is set as a GPIO, it is possible to read its value, change its direction or change output value directly from the shell.

Accessing the peripheral[edit | edit source]

Usage with libgpiod[edit | edit source]

Information about GPIOs library libgpiod - C library and tools - can be found on git.kernel.org

It is possible to compile libgpiod in the target (if the related Yocto package is not available for installation). Once the autoconf-archive package has been installed

dnf install autoconf-archive

it is possible to clone the libgpiod git repository and compile the related sources:

git clone https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
cd libgpiod 
./autogen.sh --enable-tools=yes --prefix=/usr/local 
make
make install

Once installed, the gpio utilities are available in the target:

root@desk-mx93:~# gpio
gpiodetect  gpioget     gpioinfo    gpiomon     gpionotify  gpioset
gpiomon example[edit | edit source]

If a push button, with proper pull-up, is connected to a GPIO line available - for example using the J33.28 pin available on SBC AXEL Lite WIDE connector - the related GPIO can be used as an interrupt:

  • J33.28 is connected to J10.191 SO-DIMM pin
    • J33 connector is the WIDE connector in the AURA Evaluation Kit
    • J10 connector is the SO-DIMM connector in the AURA Evaluation Kit
    • ALT-0 alternate function for this pin is GPIO2_IO12
  • the corresponding pin number is associated to gpiochip0 line 12
  • gpiomon utility can be used for monitor the pin status and triggering, for example, the falling-edge event:
root@desk-mx93:~# gpiomon -e falling -c 0 12
503.836012614   falling gpiochip0 12
504.229875114   falling gpiochip0 12
504.229962281   falling gpiochip0 12
504.229970823   falling gpiochip0 12
^Croot@desk-mx93:~#
gpioset example[edit | edit source]

For changing a GPIO output status, the gpioset utility can be used:

  • the following example set to High the pin GPIO_IO00 connected to J10.179 SO-DIMM pin
root@desk-mx93:~# gpioset -c 0 0=1