drivers/sensor: lis2dw12: Fix the logic to set TAP interrupt
The lis2dw12 sensor can generate the TAP interrupt only on INT1, while DRDY can be generated on both. The int-pin DT property specifiy on which pin the DRDY (and not the TAP) can be generated. This commit fix the way the trigger is set: first the driver checks the trigger type (DRDY or TAP), then it uses the int-pin information only in DRDY case but allows setting TAP regardless of int-pin (it always routes it on INT1). The previous code was first checking int-pin: if it was INT2 then the driver refused setting TAP triggers. Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
parent
9217e37901
commit
de0ff0c354
1 changed files with 35 additions and 32 deletions
|
@ -29,44 +29,47 @@ static int lis2dw12_enable_int(const struct device *dev,
|
||||||
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
|
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
|
||||||
lis2dw12_reg_t int_route;
|
lis2dw12_reg_t int_route;
|
||||||
|
|
||||||
if (cfg->int_pin == 1U) {
|
switch (type) {
|
||||||
/* set interrupt for pin INT1 */
|
case SENSOR_TRIG_DATA_READY:
|
||||||
lis2dw12_pin_int1_route_get(ctx, &int_route.ctrl4_int1_pad_ctrl);
|
if (cfg->int_pin == 1) {
|
||||||
|
/* set interrupt for pin INT1 */
|
||||||
switch (type) {
|
lis2dw12_pin_int1_route_get(ctx,
|
||||||
case SENSOR_TRIG_DATA_READY:
|
&int_route.ctrl4_int1_pad_ctrl);
|
||||||
int_route.ctrl4_int1_pad_ctrl.int1_drdy = enable;
|
int_route.ctrl4_int1_pad_ctrl.int1_drdy = enable;
|
||||||
break;
|
|
||||||
#ifdef CONFIG_LIS2DW12_TAP
|
return lis2dw12_pin_int1_route_set(ctx,
|
||||||
case SENSOR_TRIG_TAP:
|
&int_route.ctrl4_int1_pad_ctrl);
|
||||||
int_route.ctrl4_int1_pad_ctrl.int1_single_tap = enable;
|
} else {
|
||||||
break;
|
/* set interrupt for pin INT2 */
|
||||||
case SENSOR_TRIG_DOUBLE_TAP:
|
lis2dw12_pin_int2_route_get(ctx,
|
||||||
int_route.ctrl4_int1_pad_ctrl.int1_tap = enable;
|
&int_route.ctrl5_int2_pad_ctrl);
|
||||||
break;
|
int_route.ctrl5_int2_pad_ctrl.int2_drdy = enable;
|
||||||
#endif /* CONFIG_LIS2DW12_TAP */
|
|
||||||
default:
|
return lis2dw12_pin_int2_route_set(ctx,
|
||||||
LOG_ERR("Unsupported trigger interrupt route");
|
&int_route.ctrl5_int2_pad_ctrl);
|
||||||
return -ENOTSUP;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
|
case SENSOR_TRIG_TAP:
|
||||||
|
/* set interrupt for pin INT1 */
|
||||||
|
lis2dw12_pin_int1_route_get(ctx,
|
||||||
|
&int_route.ctrl4_int1_pad_ctrl);
|
||||||
|
int_route.ctrl4_int1_pad_ctrl.int1_single_tap = enable;
|
||||||
|
|
||||||
return lis2dw12_pin_int1_route_set(ctx,
|
return lis2dw12_pin_int1_route_set(ctx,
|
||||||
&int_route.ctrl4_int1_pad_ctrl);
|
&int_route.ctrl4_int1_pad_ctrl);
|
||||||
} else {
|
case SENSOR_TRIG_DOUBLE_TAP:
|
||||||
/* set interrupt for pin INT2 */
|
/* set interrupt for pin INT1 */
|
||||||
lis2dw12_pin_int2_route_get(ctx, &int_route.ctrl5_int2_pad_ctrl);
|
lis2dw12_pin_int1_route_get(ctx,
|
||||||
|
&int_route.ctrl4_int1_pad_ctrl);
|
||||||
|
int_route.ctrl4_int1_pad_ctrl.int1_tap = enable;
|
||||||
|
|
||||||
switch (type) {
|
return lis2dw12_pin_int1_route_set(ctx,
|
||||||
case SENSOR_TRIG_DATA_READY:
|
&int_route.ctrl4_int1_pad_ctrl);
|
||||||
int_route.ctrl5_int2_pad_ctrl.int2_drdy = enable;
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
break;
|
default:
|
||||||
default:
|
LOG_ERR("Unsupported trigger interrupt route %d", type);
|
||||||
LOG_ERR("Unsupported trigger interrupt route");
|
return -ENOTSUP;
|
||||||
return -ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lis2dw12_pin_int2_route_set(ctx,
|
|
||||||
&int_route.ctrl5_int2_pad_ctrl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue