I am working with Raspberry Pi 4 with connected ADS1115 ADC in a form of https://www.mikroe.com/adc-8-click mikroBUS extension board.
I am trying to configure Linux IIO buffers to read from this ADC.
My problem is that I cannot configure IIO buffer to read more than one channel at the same time. I can read every channel separately, but not more.
The error I get is related to invalid arguments when creating the IIO buffer. The same error I get from both IIO API functions and from command line tools.
Here is the output of 4 channels read separately with iio_readdev tool. I am using software trigger (trigger0) which I trigger from another terminal.
kuba@raspberrypi-kuba:~ $ sudo iio_readdev -t trigger0 -T 0 -b 1 -s 1 iio:device1 voltage0 | hexdump WARNING: High-speed mode not enabled 0000000 6692 0000002 kuba@raspberrypi-kuba:~ $ sudo iio_readdev -t trigger0 -T 0 -b 1 -s 1 iio:device1 voltage1 | hexdump WARNING: High-speed mode not enabled 0000000 0011 0000002 kuba@raspberrypi-kuba:~ $ sudo iio_readdev -t trigger0 -T 0 -b 1 -s 1 iio:device1 voltage2 | hexdump WARNING: High-speed mode not enabled 0000000 000a 0000002 kuba@raspberrypi-kuba:~ $ sudo iio_readdev -t trigger0 -T 0 -b 1 -s 1 iio:device1 voltage3 | hexdump WARNING: High-speed mode not enabled 0000000 001f 0000002
As you can see, all channels voltage0-3 are returning some values and they are correct (voltage0 is 6692 which results in 3.3V and the rest is almost 0).
If I try to read two channels at the same time, then I get the buffer error:
kuba@raspberrypi-kuba:~ $ sudo iio_readdev -t trigger0 -T 0 -b 1 -s 1 iio:device1 voltage0 voltage1 | hexdump Unable to allocate buffer: Invalid argument
The same error is returned no matter what values are put into -b and -s options. According to the iio_readdev manual and other internet sources, it should be possible to read more than one channel.
Here is the snipper from device tree which I'm using for ADS1115:
&i2c1 { pinctrl-names = "default"; pinctrl-0 = <&i2c1_pins>; clock-frequency = <100000>; ads1115: adc@48 { compatible = "ti,ads1115"; reg = <0x48>; #address-cells = <1>; #size-cells = <0>; channel@4 { reg = <4>; ti,gain = <1>; ti,datarate = <4>; }; channel@5 { reg = <5>; ti,gain = <1>; ti,datarate = <4>; }; channel@6 { reg = <6>; ti,gain = <1>; ti,datarate = <4>; }; channel@7 { reg = <7>; ti,gain = <1>; ti,datarate = <4>; }; }; };
The same errors I get from IIO API
iio_device_create_buffer()