cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DW12 using iio buffer, + temperature channel

KScha.3
Associate II

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: ...

st,drdy-int-pin = <1>;
 
interrupts-extended =
<&lsio_gpio4 10 IRQ_TYPE_EDGE_RISING>;
/* <&lsio_gpio4 11 IRQ_TYPE_EDGE_RISING>; */

...

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? 

(st_accel_core.c) 
...
.drdy_irq = {
.int1 = {
.addr = 0x23,
.mask = 0x01,
.addr_od = 0x22,
.mask_od = 0x20,
},
.int2 = {
.addr = 0x24,
/* .mask = 0x11, */   /* Temperature data-ready enable and Data-ready enable */
.mask = 0x10,      /* activate Data Ready Temp on int2*/
  .addr_od = 0x22,
.mask_od = 0x20,
},
.addr_ihl = 0x22,
.mask_ihl = 0x08,
.stat_drdy = {
.addr = ST_SENSORS_DEFAULT_STAT_ADDR,  /* 0x37  */
.mask = 0x01,    /*0x41 */ /*0x01*/
},
...

I try with STATUS_DUP (37h) and mask 0x41 or 0x01 but it is not work!

---- 

(4) Is 

.addr_ihl = 0x22,
.mask_ihl = 0x08,
.stat_drdy = {
.addr = ST_SENSORS_DEFAULT_STAT_ADDR,  
.mask = 0x01,  
 
not the same like 
 
.addr_ihl = 0x22,
.mask_ihl = 0x08,
.stat_drdy = {
.addr =  0x37
.mask = 0x01,  
(5)  Is not the information in Reg 0x27 bit 1 and Reg 0x37 bit 1 the same?  (data ready x,y,z)
3 REPLIES 3
Federica Bossi
ST Employee

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.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

OK, Thank you very much then I will wait for your source code. P.S. hexdump was just for a quick test!

Federica Bossi
ST Employee

Hi @KScha.3 ,

You can find the new release here.

Hope this helps :)

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.