/* 4D enable: 4D detection is enabled on INT1 pin when 6D bit on INT1_CFG(30h) is set to 1.  */
int32_t lis2dh12_int1_pin_detect_4d_set(stmdev_ctx_t *ctx, uint8_t val)
/* 4D enable: 4D detection is enabled on INT1 pin when 6D bit on INT1_CFG(30h) is set to 1.  */
int32_t lis2dh12_int1_pin_detect_4d_set(stmdev_ctx_t *ctx, uint8_t val)
{
  lis2dh12_ctrl_reg5_t ctrl_reg5;
  int32_t ret;
  ret = lis2dh12_read_reg(ctx, LIS2DH12_CTRL_REG5,
                          (uint8_t *)&ctrl_reg5, 1);
  if (ret == 0)
  {
    ctrl_reg5.d4d_int1 = val;
    ret = lis2dh12_write_reg(ctx, LIS2DH12_CTRL_REG5,
                             (uint8_t *)&ctrl_reg5, 1);
  }
  return ret;
}