@@ -187,7 +187,7 @@ static int lis2dh_start_trigger_int2(const struct device *dev)
187187 return lis2dh -> hw_tf -> write_reg (
188188 dev ,
189189 cfg -> hw .anym_on_int1 ? LIS2DH_REG_INT1_CFG : LIS2DH_REG_INT2_CFG ,
190- LIS2DH_ANYM_CFG );
190+ ( cfg -> hw . anym_mode << LIS2DH_INT_CFG_MODE_SHIFT ) | LIS2DH_ANYM_CFG );
191191}
192192
193193int lis2dh_trigger_set (const struct device * dev ,
@@ -275,7 +275,7 @@ static void lis2dh_gpio_int1_callback(const struct device *dev,
275275
276276 atomic_set_bit (& lis2dh -> trig_flags , TRIGGED_INT1 );
277277
278- /* int is level triggered so disable until we clear it */
278+ /* int is level triggered so disable until processed */
279279 setup_int1 (lis2dh -> dev , false);
280280
281281#if defined(CONFIG_LIS2DH_TRIGGER_OWN_THREAD )
@@ -295,7 +295,7 @@ static void lis2dh_gpio_int2_callback(const struct device *dev,
295295
296296 atomic_set_bit (& lis2dh -> trig_flags , TRIGGED_INT2 );
297297
298- /* int is level triggered so disable until we clear it */
298+ /* int is level triggered so disable until processed */
299299 setup_int2 (lis2dh -> dev , false);
300300
301301#if defined(CONFIG_LIS2DH_TRIGGER_OWN_THREAD )
@@ -365,15 +365,17 @@ static void lis2dh_thread_cb(const struct device *dev)
365365 };
366366 uint8_t reg_val ;
367367
368- /* clear interrupt to de-assert int line */
369- status = lis2dh -> hw_tf -> read_reg (dev ,
370- cfg -> hw .anym_on_int1 ?
371- LIS2DH_REG_INT1_SRC :
372- LIS2DH_REG_INT2_SRC ,
373- & reg_val );
374- if (status < 0 ) {
375- LOG_ERR ("clearing interrupt 2 failed: %d" , status );
376- return ;
368+ if (cfg -> hw .anym_latch ) {
369+ /* clear interrupt to de-assert int line */
370+ status = lis2dh -> hw_tf -> read_reg (dev ,
371+ cfg -> hw .anym_on_int1 ?
372+ LIS2DH_REG_INT1_SRC :
373+ LIS2DH_REG_INT2_SRC ,
374+ & reg_val );
375+ if (status < 0 ) {
376+ LOG_ERR ("clearing interrupt 2 failed: %d" , status );
377+ return ;
378+ }
377379 }
378380
379381 if (likely (lis2dh -> handler_anymotion != NULL )) {
@@ -538,23 +540,25 @@ int lis2dh_init_interrupt(const struct device *dev)
538540 status = lis2dh -> hw_tf -> update_reg (dev , LIS2DH_REG_CTRL3 ,
539541 LIS2DH_EN_INT1_INT1 ,
540542 LIS2DH_EN_INT1_INT1 );
541-
542- /* latch int1 line interrupt */
543- status = lis2dh -> hw_tf -> write_reg (dev , LIS2DH_REG_CTRL5 ,
544- LIS2DH_EN_LIR_INT1 );
543+ if (cfg -> hw .anym_latch ) {
544+ /* latch int1 line interrupt */
545+ status = lis2dh -> hw_tf -> write_reg (dev , LIS2DH_REG_CTRL5 ,
546+ LIS2DH_EN_LIR_INT1 );
547+ }
545548 } else {
546549 /* enable interrupt 2 on int2 line */
547550 status = lis2dh -> hw_tf -> update_reg (dev , LIS2DH_REG_CTRL6 ,
548551 LIS2DH_EN_INT2_INT2 ,
549552 LIS2DH_EN_INT2_INT2 );
550-
551- /* latch int2 line interrupt */
552- status = lis2dh -> hw_tf -> write_reg (dev , LIS2DH_REG_CTRL5 ,
553- LIS2DH_EN_LIR_INT2 );
553+ if (cfg -> hw .anym_latch ) {
554+ /* latch int2 line interrupt */
555+ status = lis2dh -> hw_tf -> write_reg (dev , LIS2DH_REG_CTRL5 ,
556+ LIS2DH_EN_LIR_INT2 );
557+ }
554558 }
555559
556560 if (status < 0 ) {
557- LOG_ERR ("latch enable reg write failed (%d)" , status );
561+ LOG_ERR ("enable reg write failed (%d)" , status );
558562 return status ;
559563 }
560564
0 commit comments