cancel
Showing results for 
Search instead for 
Did you mean: 

LSM9DS1 Wake Up Interrupts

Pastrana
Associate II
Posted on November 06, 2017 at 17:26

The original post was too long to process during our migration. Please click on the attachment to read the original post.
4 REPLIES 4
Miroslav BATEK
ST Employee
Posted on November 10, 2017 at 12:32

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6kI&d=%2Fa%2F0X0000000buV%2F_ea91o0WZ3EnfrIkSiKDv3CXK9zNAvRmJ2GJ7uQOgpk&asPdf=false
Posted on November 16, 2017 at 15:59

Hi

Batek.Miroslav

‌,

First of all thank you for your answer and for considering both options. I am concern about the second option, I want to wake-up the system when an acc or gyr data exceeded a threshold. I have already routed the int2 interruption to one of my GPIO, and I configured the Device tree as I explained at the beginning of this page.

I though that the driver was already prepared to attend this kind of interruptions. As you have said, I have to modified the driver by myself. I will follow your example configuration and will post the results.

I have other question, is it possible to know the value which exceed the threshold limit and caused the interrupt??

Thanks a lot,

Javi.

Posted on November 17, 2017 at 15:41

If you want be able to read output data within one ODR period after the interrupt occurs, you can read the value which exceeded the threshold.

If you are not able to read it so fast you can use the FIFO as buffer.

Posted on April 18, 2018 at 16:31

Hi

Batek.Miroslav

‌!

First of all, thank you for your answer. It was really helpful. I was working on it, but it is still not working... I made the following changes:

lsm9ds1_acc_gyr.c

+#define INT1_CTRL_DRDY_BOTH (INT1_CTRL_DRDY_XL_MASK | INT1_CTRL_DRDY_G_MASK)

+#define INT2_CTRL_OVR (INT2_CTRL_OVR_MASK)

+#define INT_GEN_SRC_XL_X_Y_Z (INT_GEN_SRC_XL_ZH_MASK | INT_GEN_SRC_XL_YH_MASK | INT_GEN_SRC_XL_XL_MASK)

+#define INT_GEN_CFG_XL_X_Y_Z (INT_GEN_CFG_XL_ZHIE_MASK | INT_GEN_CFG_XL_YHIE_MASK | INT_GEN_CFG_XL_XLIE_MASK)

+#define INT_GEN_THS_VAL (0x10)

+#define CTRL_REG1_G_DEF (0X6F) // 952Hz- 10Hz

+#define CTRL_REG3_G_DEF (0x80) // Low power mode enable

+#define CTRL_REG5_XL_DEF (0x38)

+#define CTRL_REG6_XL_DEF (0xC4)

+#define CTRL_REG8_DEF (0x44)

+#define CTRL_REG9_DEF (0x40)

.act_ths =

{.address = ACT_THS, .default_val = DEF_ZERO,},

.act_dur =

{.address = ACT_DUR, .default_val = DEF_ZERO,},

.int_gen_cfg_xl =

{.address = INT_GEN_CFG_XL, .default_val = INT_GEN_CFG_XL_X_Y_Z,},

.int_gen_ths_x_xl =

{.address = INT_GEN_THS_X_XL, .default_val = INT_GEN_THS_VAL,},

.int_gen_ths_y_xl =

{.address = INT_GEN_THS_Y_XL, .default_val = INT_GEN_THS_VAL,},

.int_gen_ths_z_xl =

{.address = INT_GEN_THS_Z_XL, .default_val = INT_GEN_THS_VAL,},

.int_gen_dur_xl =

{.address = INT_GEN_DUR_XL, .default_val = DEF_ZERO,},

.reference_g =

{.address = REFERENCE_G, .default_val = DEF_ZERO,},

.int1_ctrl =

{.address = INT1_CTRL, .default_val = INT1_CTRL_DRDY_BOTH,},

.int2_ctrl =

{.address = INT2_CTRL, .default_val = INT2_CTRL_OVR,},

.who_am_i =

{.address = WHO_AM_I, .default_val = WHO_AM_I_VAL,},

.ctrl_reg1_g =

{.address = CTRL_REG1_G, .default_val = CTRL_REG1_G_DEF,},

.ctrl_reg2_g =

{.address = CTRL_REG2_G, .default_val = DEF_ZERO,},

.ctrl_reg3_g =

{.address = CTRL_REG3_G, .default_val = CTRL_REG3_G_DEF,},

.orient_cfg_g =

{.address = ORIENT_CFG_G, .default_val = DEF_ZERO,},

.int_gen_src_g =

{.address = INT_GEN_SRC_G, .default_val = UNDEF,},

.status_reg1 =

{.address = STATUS_REG1, .default_val = UNDEF,},

.ctrl_reg4 =

{.address = CTRL_REG4, .default_val = CTRL_REG4_DEF,},

.ctrl_reg5_xl =

{.address = CTRL_REG5_XL, .default_val = CTRL_REG5_XL_DEF,},

.ctrl_reg6_xl =

{.address = CTRL_REG6_XL, .default_val = CTRL_REG6_XL_DEF,},

.ctrl_reg7_xl =

{.address = CTRL_REG7_XL, .default_val = DEF_ZERO,},

.ctrl_reg8 =

{.address = CTRL_REG8, .default_val = CTRL_REG8_DEF,},

.ctrl_reg9 =

{.address = CTRL_REG9, .default_val = CTRL_REG9_DEF,},

.ctrl_reg10 =

{.address = CTRL_REG10, .default_val = DEF_ZERO,},

.int_gen_src_xl =

{.address = INT_GEN_SRC_XL, .default_val = INT_GEN_SRC_XL_X_Y_Z,},

.status_reg2 =

{.address = STATUS_REG2, .default_val = UNDEF,},

.fifo_ctrl =

{.address = FIFO_CTRL, .default_val = DEF_ZERO,},

.fifo_src =

{.address = FIFO_SRC, .default_val = UNDEF,},

.int_gen_cfg_g =

{.address = INT_GEN_CFG_G, .default_val = DEF_ZERO,},

.int_gen_ths_xh_g =

{.address = INT_GEN_THS_XH_G, .default_val = DEF_ZERO,},

.int_gen_ths_xl_g =

{.address = INT_GEN_THS_XL_G, .default_val = DEF_ZERO,},

.int_gen_ths_yh_g =

{.address = INT_GEN_THS_YH_G, .default_val = DEF_ZERO,},

.int_gen_ths_yl_g =

{.address = INT_GEN_THS_YL_G, .default_val = DEF_ZERO,},

.int_gen_ths_zh_g =

{.address = INT_GEN_THS_ZH_G, .default_val = DEF_ZERO,},

.int_gen_ths_zl_g =

{.address = INT_GEN_THS_ZL_G, .default_val = DEF_ZERO,},

.int_gen_dur_g =

{.address = INT_GEN_DUR_G, .default_val = DEF_ZERO,},

};

I think that the problem is also related to the Device Tree. If I use the following definition for the Device Tree:

/* LSM9DS1 accelerometer/gyroscope sensor */

lsm9ds1-ag@0x6a {

compatible = 'st,lsm9ds1_acc_gyr'; /* Compatible device name, it should be register before */

reg = <0x6A>; /* I2C address */

pinctrl-names = 'default';

pinctrl-0 = <&pinctrl_imu_acc>; /* pinctrl regiter */

gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>, /* INT1 - GPIO group 4 - GPIO number 13*/

<&gpio4 14 GPIO_ACTIVE_HIGH>; /* INT2 - GPIO group 4 - GPIO number 14*/

rot-matrix = /bits/ 16 <(1) (0) (0)

(0) (1) (0)

(0) (0) (1)>;

g-poll-interval = <100>;

g-min-interval = <2>;

g-fs-range = <0>;

x-poll-interval = <100>;

x-min-interval = <1>;

x-fs-range = <0>;

aa-filter-bw = <0>;

/* Interrupts defnition */

interrupt-controller;

interrupt-parent = <&gpio4>;

#interrupt-cells = <2>;

interrupts = <13 0x1>, <14 0x1>;

wakeup-source;

};

I only see on my /proc/interrupts, one interrupt, called: lsm9ds1_acc_gyr, which is the INT1, Moreover, the last line (wakeup-source) does not work. If I included other node, as it is below:

/* GPIO WAKEUP KEYs Definition */

gpio-keys {

compatible = 'gpio-keys';

/* GPIO4_IO14 */

threshold_imu_limit {

label = 'Wakeup IMU';

gpios = <&gpio4 14 GPIO_ACTIVE_HIGH>;

linux,code = <114>; // Wakeup keyboard key not used

gpio-key,wakeup;

};

};

I see on my /proc/interrupts other new interrupt, called 'Wakeup IMU'. But I think that it is not a good approach. If these GPIO is defined by lsm9ds1 driver, it cannot be defined too by gpio-keys driver,no? The wake-up functionality should be implemented in the lsm9ds1 driver? Why I do not see the INT2 interrupt if it is only defined 'lsm9ds1-ag' node?.

Finally, if I include the gpio-keys, it does not work properly.

You can find attached the whole code, once I implement the driver, I will publish it.

Best regards,

Javier.