/* Duration to go in sleep mode. 1 LSb = 512 / ODR.  */
int32_t lsm6dso_act_sleep_dur_set(lsm6dso_ctx_t *ctx, uint8_t val)
/* Duration to go in sleep mode. 1 LSb = 512 / ODR.  */
int32_t lsm6dso_act_sleep_dur_set(lsm6dso_ctx_t *ctx, uint8_t val)
{
  lsm6dso_wake_up_dur_t reg;
  int32_t ret;
  ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)&reg, 1);
  if (ret == 0) {
    reg.sleep_dur = val;
    ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)&reg, 1);
  }
  return ret;
}