/* Software reset. Restore the default values in user registers..  */
int32_t lis2mdl_reset_set(stmdev_ctx_t *ctx, uint8_t val)
/* Software reset. Restore the default values in user registers..  */
int32_t lis2mdl_reset_set(stmdev_ctx_t *ctx, uint8_t val)
{
  lis2mdl_cfg_reg_a_t reg;
  int32_t ret;
  ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_A, (uint8_t*)&reg, 1);
  if(ret == 0){
    reg.soft_rst = val;
    ret = lis2mdl_write_reg(ctx, LIS2MDL_CFG_REG_A, (uint8_t*)&reg, 1);
  }
  return ret;
}