/* Slave 0 write operation is performed only at the first sensor hub cycle..  */
int32_t lsm6dso_sh_write_mode_get(stmdev_ctx_t *ctx, lsm6dso_write_once_t *val)
/* Slave 0 write operation is performed only at the first sensor hub cycle..  */
int32_t lsm6dso_sh_write_mode_get(stmdev_ctx_t *ctx, lsm6dso_write_once_t *val)
{
  lsm6dso_master_config_t reg;
  int32_t ret;
  ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK);
  if (ret == 0) {
    ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)&reg,
                           1);
  }
  if (ret == 0) {
    switch (reg.write_once) {
      case LSM6DSO_EACH_SH_CYCLE:
        *val = LSM6DSO_EACH_SH_CYCLE;
        break;
      case LSM6DSO_ONLY_FIRST_CYCLE:
        *val = LSM6DSO_ONLY_FIRST_CYCLE;
        break;
      default:
        *val = LSM6DSO_EACH_SH_CYCLE;
        break;
    }
    ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
  }
  return ret;
}