cancel
Showing results for 
Search instead for 
Did you mean: 

DIfference between interrupt get and set

MRive.2
Associate

I was taking a look at this repository to get a bit used with the lis2dw12 accelerometer.

Trying to use the Activity example I've got the expected results but got a bit confused with the routing of the detection to the interrupt pin. From line 185 on it does the following:

  /* Enable activity detection interrupt */
  lis2dw12_pin_int1_route_get(&dev_ctx, &int_route.ctrl4_int1_pad_ctrl);
  int_route.ctrl4_int1_pad_ctrl.int1_wu = PROPERTY_ENABLE;
  lis2dw12_pin_int1_route_set(&dev_ctx, &int_route.ctrl4_int1_pad_ctrl);

What is the difference between "lis2dw12_pin_int1_route_get" and "lis2dw12_pin_int1_route_set". In my understanting this part of the code is just routing the Wake up bit to the Ctrl4_Int1_pad_ctrl but what is the "route_get" command doing?

Looking inside the function it only reads the current state of the register, is there any particular reason for this?

int32_t lis2dw12_pin_int1_route_get(stmdev_ctx_t *ctx,
                                    lis2dw12_ctrl4_int1_pad_ctrl_t *val)
{
  int32_t ret;
  ret = lis2dw12_read_reg(ctx, LIS2DW12_CTRL4_INT1_PAD_CTRL,
                          (uint8_t*) val, 1);
  return ret;
}

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

Hi @MRive.2​ ,

lis2dw12_pin_int1_route_get is a "get" function, so basically it configures nothing, but returns the configuration of the value of LIS2DW12_CTRL4_INT1_PAD_CTRL register.

This could be useful when you insert your function in a more complex code, that uses the interrupt multiple times and needs to store or just to know the previous value of the interrupt flag.

It is useful in general to control the "previous" status of the interrupt, before running the rest of the code, to know whether the interrupt is already risen or not, avoiding the risk of false positive / negative flags.

But if you don't need it, you can comment the function.

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster. 

-Eleon

View solution in original post

1 REPLY 1
Eleon BORLINI
ST Employee

Hi @MRive.2​ ,

lis2dw12_pin_int1_route_get is a "get" function, so basically it configures nothing, but returns the configuration of the value of LIS2DW12_CTRL4_INT1_PAD_CTRL register.

This could be useful when you insert your function in a more complex code, that uses the interrupt multiple times and needs to store or just to know the previous value of the interrupt flag.

It is useful in general to control the "previous" status of the interrupt, before running the rest of the code, to know whether the interrupt is already risen or not, avoiding the risk of false positive / negative flags.

But if you don't need it, you can comment the function.

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster. 

-Eleon