This version (05 Feb 2021 13:29) was approved by Michael Hennerich.The Previously approved version (28 Jan 2021 10:36) is available.Diff

iio-trig-sysfs driver


This driver adds a trigger that can be invoked by writing the sysfs file: trigger_now. This approach can be valuable during automated testing or in situations, where other trigger methods are not applicable. For example no RTC or spare GPIOs. Last but not least it allows user space applications to produce triggers.


Adding Linux driver support

Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)

Linux Kernel Configuration
	Device Drivers  --->
		[*] Staging drivers  --->
			<*>     Industrial I/O support  --->
			    --- Industrial I/O support
			    -*-   Enable ring buffer support within IIO
			    -*-     Industrial I/O lock free software ring
			    -*-   Enable triggered sampling support
			          *** Triggers - standalone ***
			    < >   Periodic RTC triggers
			    < >   GPIO trigger
			    <*>   SYSFS trigger
			    < >   Blackfin TIMER trigger

sysfs trigger creation and removal

When sysfs trigger support is enabled in the kernel configuration there will be a /sys/bus/iio/devices/iio_sysfs_trigger/ folder which can be used for sysfs trigger management. The folder contains two files “add_trigger” and “remove_trigger”. New sysfs triggers can be created by writing a ID to the “add_trigger” file. E.g. `echo 0 > add_trigger`. This will create a new sysfs trigger, which you can access at “/sys/bus/iio/devices/iio:triggerX”, where X is a the trigger number. Typically it will be 0 for the first trigger, 1 for the second, etc. The name of the trigger will be “sysfstrigID” where ID is the value writting to the “add_trigger” file.

To remove a sysfs trigger write the same ID used when registering it to the “remove_trigger” file. E.g `echo 0 > remove_trigger`.

Driver testing

This specifies any shell prompt running on the target

root:/> cd sys/bus/iio/devices/
root:/sys/bus/iio/devices> ls
root:/sys/bus/iio/devices> cd iio:trigger0
root:/sys/devices/iio:trigger0> ls
name         subsystem    trigger_now  uevent
root:/sys/devices/iio:trigger0> cat name
root:/sys/devices/iio:trigger0> echo 1 > trigger_now
root:/sys/devices/iio:trigger0> echo 1 > trigger_now

More Information

software/linux/docs/iio/iio-trig-sysfs.txt · Last modified: 05 Feb 2021 13:28 by Michael Hennerich