2024-03-11
05:55 AM
- last edited on
2024-03-12
04:49 AM
by
Lina_DABASINSKA
Hi
Problems with a iio interface and using of buffer.
Goal use the iio buffer interface for accel x y, z and temperture values.
Include one Channel more for the temperature.
static const struct iio_chan_spec st_accel_12bit_channels_temp[] = {
ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 12, 16,
ST_ACCEL_DEFAULT_OUT_X_L_ADDR),
ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 12, 16,
ST_ACCEL_DEFAULT_OUT_Y_L_ADDR),
ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 12, 16,
ST_ACCEL_DEFAULT_OUT_Z_L_ADDR),
ST_SENSORS_LSM_CHANNELS(IIO_TEMP,
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_PROCESSED),
ST_SENSORS_SCAN_TEMP, 1, IIO_MOD_TEMP_OBJECT, 's', IIO_LE, 12, 16,
ST_ACCEL_DEFAULT_TEMP_ADDR),
IIO_CHAN_SOFT_TIMESTAMP(4)
---------
DTB: ...
...
Individual requests for the temperature work!
cat /sys/devices/platform/bus@5a000000/5a800000.i2c/i2c-0/0-0019/iio:device0/in_temp_object_raw
145
/sys/devices/platform/bus@5a000000/5a800000.i2c/i2c-0/0-0019/iio:device0/buffer0# echo 1 > in_accel_y_en
/sys/devices/platform/bus@5a000000/5a800000.i2c/i2c-0/0-0019/iio:device0/buffer0# echo 1 > enable
/sys/devices/platform/bus@5a000000/5a800000.i2c/i2c-0/0-0019/iio:device0/buffer0# hexdump /dev/iio:device0
0000000 02e0 02d0 02d0 02a0 02c0 02b0 02b0 02e0
0000010 02d0 0300 02e0 0330 02a0 0350 02b0 02a0
0000020 0260 0240 0300 0250 0290 0260 03b0 0390 Is working ok! With x and z too!
set in_accel_y_en back to 0
/sys/devices/platform/bus@5a000000/5a800000.i2c/i2c-0/0-0019/iio:device0/buffer0# echo 1 > in_temp_object_en
/sys/devices/platform/bus@5a000000/5a800000.i2c/i2c-0/0-0019/iio:device0/buffer0# echo 1 > enable
/sys/devices/platform/bus@5a000000/5a800000.i2c/i2c-0/0-0019/iio:device0/buffer0# hexdump /dev/iio:device0
0000000 0cf0 0cf0 de60 de60 de60 de60 de60 de60
0000010 de60 de60 de60 de60 de60 de60 de60 de60
*
0000070 de60 de60 de60 de60 de60 e080 e080 e080
0000080 e080 e080 e080 e080 e080 e080 e080 e080
*
0000110 e080 e080 e080 de40 de40 de40 de40 de40
0000120 de40 de40 de40 de40 de40 de40 de40 de40
...
/sys/devices/platform/bus@5a000000/5a800000.i2c/i2c-0/0-0019/iio:device0
0x0cf -> 207 it is ok!
cat in_temp_object_raw
214 (check)
BUT
Only the first two data are correct then there is only garbage in the buffer! (1) Why?
Qustions
(2) Why the buffer not work when i activate the second interrrupt? st,drdy-int-pin = <2>;
/sys/devices/platform/bus@5a000000/5a800000.i2c/i2c-0/0-0019/iio:device0/buffer0#
echo 1 > in_accel_y_en
echo 1 > enable
hexdump /dev/iio:device0 -> Nothing is printing!
(3 ) Must change to Register 0x37 for both data ready signals in one register?
I try with STATUS_DUP (37h) and mask 0x41 or 0x01 but it is not work!
----
(4) Is
2024-03-12 07:39 AM
Hi @KScha.3 ,
I recommend using generic_buffer instead of hexdumping the file.
Furthermore, in the coming weeks, we will publish an official example driver on github in which temperature sensor management is integrated. I will update you as soon as it is released.
2024-03-12 07:51 AM
OK, Thank you very much then I will wait for your source code. P.S. hexdump was just for a quick test!
2024-03-26 06:06 AM