/* These registers comprise a 3 group of 16-bit number and represent hard-iron offset in order to compensate environmental effects. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG. These values act on the magnetic output data value in order to delete the environmental offset..  */
int32_t iis2mdc_mag_user_offset_set(stmdev_ctx_t *ctx, int16_t *val)
/* These registers comprise a 3 group of 16-bit number and represent hard-iron offset in order to compensate environmental effects. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG. These values act on the magnetic output data value in order to delete the environmental offset..  */
int32_t iis2mdc_mag_user_offset_set(stmdev_ctx_t *ctx, int16_t *val)
{
  uint8_t buff[6];
  int32_t ret;
  buff[1] = (uint8_t) ((uint16_t)val[0] / 256U);
  buff[0] = (uint8_t) ((uint16_t)val[0] - (buff[1] * 256U));
  buff[3] = (uint8_t) ((uint16_t)val[1] / 256U);
  buff[2] = (uint8_t) ((uint16_t)val[1] - (buff[3] * 256U));
  buff[5] = (uint8_t) ((uint16_t)val[2] / 256U);
  buff[4] = (uint8_t) ((uint16_t)val[2] - (buff[5] * 256U));
  ret =  iis2mdc_write_reg(ctx, IIS2MDC_OFFSET_X_REG_L, buff, 6);
  return ret;
}