TS-4100 DIO: Difference between revisions

From embeddedTS Manuals
(Updated to GPIO character device tools)
(Formatting changes)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
The i.MX6UL CPU and FPGA GPIO are exposed using a kernel character device. This interface provides a set of files and directories for interacting with GPIO which can be used from any language that interact with special files in linux using ioctl() or similar. For our platforms, we pre-install the "libgpiod" library and binaries. Documentation on these tools can be found [https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/README here]. This section only covers using these userspace tools and does not provide guidance on using the libgpiod library in end applications. Please see the libgpiod documentation for this purpose.
The i.MX6UL CPU and FPGA GPIO are exposed using a kernel character device. This interface provides a set of files and directories for interacting with GPIO which can be used from any language that interact with special files in linux using ioctl() or similar. For our platforms, we pre-install the "libgpiod" library and binaries. Documentation on these tools can be found [https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/README here]. This section only covers using these userspace tools and does not provide guidance on using the libgpiod library in end applications. Please see the libgpiod documentation for this purpose.


A user with suitable permissions to read and write /dev/gpiochip* files can immediately interact with GPIO pins. For example, to read the push switch on the TS-4100-8551 which is connected to [[#FPGA_GPIO_Table|FPGA DIO_9]]:
A user with suitable permissions to read and write <source inline>/dev/gpiochip*</source> files can immediately interact with GPIO pins. For example, to read the push switch on the TS-8551-4100 which is connected to [[#FPGA_GPIO_Table|FPGA DIO_9]]:
<source lang=bash>
<source lang=bash>
gpioget 5 46
gpioget 5 46
Line 7: Line 7:
Multiple pins in the same chip can be read simultaneously by passing multiple pin numbers separated by spaces.
Multiple pins in the same chip can be read simultaneously by passing multiple pin numbers separated by spaces.


To write to a pin, the 'gpioset' command is used. For example, to set [[#CPU_GPIO_Table|LCD_D02]]:
To write to a pin, the <source inline>gpioset</source> command is used. For example, to set [[#CPU_GPIO_Table|LCD_D02]]:
<source lang=bash>
<source lang=bash>
gpioset 2 7=0
gpioset 2 7=0
</source>
</source>
Multiple pins in the same chip can be set simultaneously by passing multiple pin=value pairs separated by spaces.
Multiple pins in the same chip can be set simultaneously by passing multiple <source inline><pin>=<value></source> pairs separated by spaces.


If a call with 'gpioset' or 'gpioget' fails with "Device or resource busy," that means that specific GPIO is claimed by another device. The command 'cat /sys/kernel/debug/gpio' can be used to get a list of all of the system GPIO and what has claimed them.
If a call to <source inline>gpioset</source> or <source inline>gpioget</source> fails with the message <source inline>Device or resource busy</source> that means that specific GPIO is claimed by another device. The command <source inline>cat /sys/kernel/debug/gpio</source> can be used to get a list of all of the system GPIO and what has claimed them.


The 'gpiomon' tool can be used to monitor pins for changes.
The <source inline>gpiomon</source> tool can be used to monitor pins for changes.

Latest revision as of 16:09, 19 October 2021

The i.MX6UL CPU and FPGA GPIO are exposed using a kernel character device. This interface provides a set of files and directories for interacting with GPIO which can be used from any language that interact with special files in linux using ioctl() or similar. For our platforms, we pre-install the "libgpiod" library and binaries. Documentation on these tools can be found here. This section only covers using these userspace tools and does not provide guidance on using the libgpiod library in end applications. Please see the libgpiod documentation for this purpose.

A user with suitable permissions to read and write /dev/gpiochip* files can immediately interact with GPIO pins. For example, to read the push switch on the TS-8551-4100 which is connected to FPGA DIO_9:

gpioget 5 46

Multiple pins in the same chip can be read simultaneously by passing multiple pin numbers separated by spaces.

To write to a pin, the gpioset command is used. For example, to set LCD_D02:

gpioset 2 7=0

Multiple pins in the same chip can be set simultaneously by passing multiple <pin>=<value> pairs separated by spaces.

If a call to gpioset or gpioget fails with the message Device or resource busy that means that specific GPIO is claimed by another device. The command cat /sys/kernel/debug/gpio can be used to get a list of all of the system GPIO and what has claimed them.

The gpiomon tool can be used to monitor pins for changes.