VF61 Continuous Sampling ADC driver


I would like to sample N points of a waveform at a fixed frequency (more than 10KHz) using the internal ADC of VF61. Few days ago Sanchayan Maity added IIO buffer support for Hybrid ADC in linux kernel (linux-toradex.git - Linux kernel for Apalis and Colibri modules). I successfully build the kernel and flash it to Colibri VF61 board.

When I boot the board i can see the two adc (iio:device0 and iio:device1) in /sys/bus/iio/devices each one with several files and directories:




So I think that the driver is up and running properly. I would like to know what are the available triggers to start the sampling process.


As far as I am aware currently only software triggers are supported (sysfs trigger, triggered by the example generic_buffer).

@sanchayan.maity, is this correct?

I don`t have any iio_sysfs_trigger under devices directory. How can I enable this trigger?

I forgot to add that the CONFIG_IIO_SYSFS_TRIGGER should also be selected as it is not enabled by default.


Which image version are you using? I was not able to replicate this at my end.

I think that is something wrong with my script file because I able to setup trigger directly from the terminal. The generic_buffer program works fine for me.

Thanks a lot for the help.

sysfs can be used as a trigger to start the sampling once a channel has been selected.

echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_temp_en

echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_timestamp_en

echo 0 > /sys/bus/iio/devices/iio_sysfs_trigger/add_trigger

generic_buffer -n 4003b000.adc -t sysfstrig0 -l 512 -c 10

The generic_buffer code is available in the kernel source tree


I rebuild the kernel with the CONFIG_IIO_SYSFS_TRIGGER enabled and now I have io_sysfs_trigger under devices directory but when I try echo 0 > /sys/bus/iio/devices/iio_sysfs_trigger/add_trigger I got a Permission Denied message.



I’m trying to understand generic_buffer code but I’m having some difficulties. Just after to enable the buffer in line 280 the application reads the buffer in the file /dev/iio:device which contains the samples. Why the application never writes in /sys/bus/iio/devices/iio_sysfs_trigger/trigger0/trigger_now to start the sampling proccess?


The generic_buffer is a generic example, and it could also be used with external triggers. Also, it could be that a different application is supposed to trigger the actual ADC measurement, and hence write to trigger_now. If you would like to start the measurement within the same application, you can add a write to trigger_now as part of generic_buffer.

Where can I find information on how to implement external triggers? I can’t find much information about IIO subsystem. Is it possible to perform sampling based on a timer interruption?

Thanks for the help.

Yeah documentation on implementing IIO functionality are rather sparse. There is a text file in the kernel sources:


What I would recommend is to use at existing implementations (e.g. drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c). However, often that involves to first read about the capabilities and details of the device the that driver is for, then understand that driver code, and finally start implementing the functionality on the actual device at hand…

I think timer interrupts as triggers are possible. There is the Programmable Delay Block, which is kind of a timer. The external trigger capabilities is also documented in the Vybrid Reference Manual (“ ADC interconnections”).