/* User-defined threshold value for xl interrupt event on generator 2. LSb = 16mg@2g / 32mg@4g / 62mg@8g / 186mg@16g.  */
int32_t lis2dh12_int2_gen_threshold_set(stmdev_ctx_t *ctx, uint8_t val)
/* User-defined threshold value for xl interrupt event on generator 2. LSb = 16mg@2g / 32mg@4g / 62mg@8g / 186mg@16g.  */
int32_t lis2dh12_int2_gen_threshold_set(stmdev_ctx_t *ctx, uint8_t val)
{
  lis2dh12_int2_ths_t int2_ths;
  int32_t ret;
  ret = lis2dh12_read_reg(ctx, LIS2DH12_INT2_THS, (uint8_t *)&int2_ths, 1);
  if (ret == 0)
  {
    int2_ths.ths = val;
    ret = lis2dh12_write_reg(ctx, LIS2DH12_INT2_THS, (uint8_t *)&int2_ths, 1);
  }
  return ret;
}