/* FSM long counter status register. Long counter value is an unsigned integer value (16-bit format)..  */
int32_t lsm6dso_long_cnt_get(stmdev_ctx_t *ctx, uint16_t *val)
/* FSM long counter status register. Long counter value is an unsigned integer value (16-bit format)..  */
int32_t lsm6dso_long_cnt_get(stmdev_ctx_t *ctx, uint16_t *val)
{
  uint8_t buff[2];
  int32_t ret;
  ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK);
  if (ret == 0) {
    ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_L, buff, 2);
  }
  if (ret == 0) {
    ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
    *val = buff[1];
    *val = (*val * 256U) +  buff[0];
  }
  return ret;
}