This is a basic ADC example for Guinnux 5. It shows how the ADC can be used from:
The ADC peripheral uses the iio kernel subsystem.
The ADC is triggered by reading from the in_voltageX_raw file:
$ cat /sys/bus/iio/devices/iio:device0/in_voltageX_raw
Where X is the desired channel. The result is printed to the screen.
It might be necessary to enable the channel first. This is done by writing a 1 to in_voltageX_en file:
$ echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltageX_en
The analogue voltage can be obtained by reading the scaling factor from the in_voltage_scale file and multiplying the result with the digital representation. Note that the result is in mV.
$ cat /sys/bus/iio/devices/iio:device0/in_voltage_scale