Sign inSign up

hachyang/hach-gpio-example

By hachyang

Updated almost 5 years ago

Image
0

113

hachyang/hach-gpio-example repository overview

GPIO example

GPIO example using libgpiod.

Use the following command to build a container:

docker build --build-arg GCC_PREFIX=aarch64-linux-gnu --build-arg CROSS_TC_IMAGE_ARCH=arm64 --build-arg ARCH_ARG=linux/arm64 -t hachyang/hach-gpio-example
  • After image is built, it can be either uploaded to docker hub account/some other container registry or can be moved to target machine in portable tar archive file.

  • To move it to the target machine in portable tar archive file, execute

docker save -o gpio-image.tar hachyang/hach-gpio-example
  • Now move it to target machine and load it
docker load -i gpio-image.tar

Transfer the container to the module and use the following command:

docker run --rm -it --init --device /dev/gpiochip0 --device /dev/gpiochip3 hachyang/hach-gpio-example

The gpio bank number is the GPIO number x -1: GPIOx_y => /dev/gpiochip(x-1)_y ... Use the gpiod command line tools: There are currently six command-line tools available:

gpiodetect - list all gpiochips present on the system, their names, labels and number of GPIO lines

gpioinfo - list all lines of specified gpiochips, their names, consumers, direction, active state and additional flags

gpioget - read values of specified GPIO lines

gpioset - set values of specified GPIO lines, potentially keep the lines exported and wait until timeout, user input or signal

gpiofind - find the gpiochip name and line offset given the line name

gpiomon - wait for events on a GPIO line, specify which events to watch, how many events to process before exiting or if the events should be reported to the console.

Some examples:

GPIO1_9 as J1.173 at Pin#9 of J17 on Variscite Symphony Board w/ IMX8MP gpioset /dev/gpiochip0 9=0 gpioset /dev/gpiochip0 9=1 gpiomon 0 9 gpioget 0 9 GPIO4_27 as J1.48 at Pin#5 of J17 on Variscite Symphony Board w/IMX8MP gpioset /dev/gpiochip3 27=0 gpioset /dev/gpiochip3 27=1 gpiomon 3 27 gpioget 3 27

Toggle a GPIO: gpio-toggle 3 27

Read GPIO Using Events (Interrupt Driven): gpio-event 0 9 3 27

Tag summary

Content type

Image

Digest

Size

29 MB

Last updated

almost 5 years ago

docker pull hachyang/hach-gpio-example