#include <libsimpleio/libadc.h> void ADC_get_name(int32_t chip, char *name, int32_t namesize, int32_t *error); void ADC_get_reference(int32_t chip, double *reference, int32_t *error); void ADC_get_scale(int32_t chip, int32_t channel, double *scale, int32_t *error); void ADC_open(int32_t chip, int32_t channel, int32_t *fd, int32_t *error); void ADC_close(int32_t fd, int32_t *error); void ADC_read(int32_t fd, int32_t *sample, int32_t *error);Link with -lsimpleio.
ADC_get_name() fetches an information string for an A/D device. The chip number must be passed in chip. The destination buffer address must be passed in *name and the destination buffer size must be passed in namesize. The minimum size for the destination buffer is 16 bytes.
ADC_get_reference() returns the reference voltage for the A/D converter selected by the chip parameter in the *reference parameter. This will fail unless the reference voltage has been configured with the vref-supply property in a device tree overlay for the A/D converter.
ADC_get_scale() returns an A/D input scale factor (volts per step) in the *scale parameter. The A/D chip number must be passed in the chip parameter and the A/D input channel number must be passed in the channel parameter. This will fail unless the A/D chip implements scaling.
ADC_open() opens an A/D input channel device. The A/D chip number must be passed in the chip parameter and the A/D input channel number must be passed in the channel parameter. Upon success, a file descriptor for the A/D input channel device is returned in *fd.
ADC_close() closes a previously opened A/D input channel device.
ADC_read() reads a sample from an A/D input channel device. The file descriptor for an open A/D input channel device must be passed in the fd parameter. The analog sample data will be returned in the *sample parameter.
https://wiki.analog.com/software/linux/docs/iio/iio