/* Fetch current temperature from temperature sensor (in Celsius). 
If reading the temperature, when a measurement is completed inside the sensor device, the new measurement may not be stored. For this reason, the temperature should not be polled with a higher frequency than the measurement conversion time for a given resolution configuration. Please refer to sensor device datasheet. */
int TEMPSENS_TemperatureGet(I2C_TypeDef *i2c, uint8_t addr, TEMPSENS_Temp_TypeDef *temp)
/* Fetch current temperature from temperature sensor (in Celsius). 
If reading the temperature, when a measurement is completed inside the sensor device, the new measurement may not be stored. For this reason, the temperature should not be polled with a higher frequency than the measurement conversion time for a given resolution configuration. Please refer to sensor device datasheet. */
int TEMPSENS_TemperatureGet(I2C_TypeDef *i2c, uint8_t addr, TEMPSENS_Temp_TypeDef *temp)
{
  int      ret;
  uint32_t tmp;
  uint16_t val = 0;
  ret = TEMPSENS_RegisterGet(i2c, addr, tempsensRegTemp, &val);
  if (ret < 0)
  {
    return(ret);
  }
  tmp = (uint32_t)(val >> 4);
  if (tmp & 0x800)
  {
    tmp     = (~tmp + 1) & 0xfff;
    temp->i = -(int16_t)(tmp >> 4);
    temp->f = -(int16_t)((tmp & 0xf) * 625);
  }
  else
  {
    temp->i = (int16_t)(tmp >> 4);
    temp->f = (int16_t)((tmp & 0xf) * 625);
  }
  return(0);
}