EFM32 Gecko Software Documentation  efm32g-doc-5.1.2
TempSensor

Detailed Description

Data Structures

struct  TEMPSENS_Temp_TypeDef
 

Macros

#define TEMPSENS_DK_ADDR   0x90
 

Enumerations

enum  TEMPSENS_Register_TypeDef {
  tempsensRegTemp = 0,
  tempsensRegConfig = 1,
  tempsensRegHysteresis = 2,
  tempsensRegShutdown = 3
}
 

Functions

void TEMPSENS_Celsius2Fahrenheit (TEMPSENS_Temp_TypeDef *temp)
 Convert temperature from Celsius to Fahrenheit. More...
 
int TEMPSENS_RegisterGet (I2C_TypeDef *i2c, uint8_t addr, TEMPSENS_Register_TypeDef reg, uint16_t *val)
 Read sensor register content. More...
 
int TEMPSENS_RegisterSet (I2C_TypeDef *i2c, uint8_t addr, TEMPSENS_Register_TypeDef reg, uint16_t val)
 Write to sensor register. More...
 
int TEMPSENS_TemperatureGet (I2C_TypeDef *i2c, uint8_t addr, TEMPSENS_Temp_TypeDef *temp)
 Fetch current temperature from temperature sensor (in Celsius). More...
 

Macro Definition Documentation

#define TEMPSENS_DK_ADDR   0x90

I2C device address for temperature sensor on DK

Definition at line 42 of file tempsens.h.

Enumeration Type Documentation

Available registers in DS75 sensor device

Enumerator
tempsensRegTemp 

Temperature register (read-only)

tempsensRegConfig 

Configuration register

tempsensRegHysteresis 

Hysteresis register

tempsensRegShutdown 

Overtemperature shutdown register

Definition at line 50 of file tempsens.h.

Function Documentation

void TEMPSENS_Celsius2Fahrenheit ( TEMPSENS_Temp_TypeDef temp)

Convert temperature from Celsius to Fahrenheit.

Parameters
[in,out]tempReference to structure to holding temperature in Celsius to convert. Upon return, it has been changed to Fahrenheit.

Definition at line 32 of file tempsens.c.

References TEMPSENS_Temp_TypeDef::f, and TEMPSENS_Temp_TypeDef::i.

int TEMPSENS_RegisterGet ( I2C_TypeDef i2c,
uint8_t  addr,
TEMPSENS_Register_TypeDef  reg,
uint16_t *  val 
)

Read sensor register content.

If reading the temperature register, 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.

Parameters
[in]i2cPointer to I2C peripheral register block.
[in]addrI2C address for temperature sensor, in 8 bit format, where LSB is reserved for R/W bit.
[in]regRegister to read.
[out]valReference to place register read.
Returns
Returns 0 if register read, <0 if unable to read register.

Definition at line 74 of file tempsens.c.

References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE_READ, I2CSPM_Transfer(), i2cTransferDone, I2C_TransferSeq_TypeDef::len, and tempsensRegConfig.

Referenced by TEMPSENS_TemperatureGet().

int TEMPSENS_RegisterSet ( I2C_TypeDef i2c,
uint8_t  addr,
TEMPSENS_Register_TypeDef  reg,
uint16_t  val 
)

Write to sensor register.

Parameters
[in]i2cPointer to I2C peripheral register block.
[in]addrI2C address for temperature sensor, in 8 bit format, where LSB is reserved for R/W bit.
[in]regRegister to write (temperature register cannot be written).
[in]valValue used when writing to register.
Returns
Returns 0 if register written, <0 if unable to write to register.

Definition at line 136 of file tempsens.c.

References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE, I2CSPM_Transfer(), i2cTransferDone, I2C_TransferSeq_TypeDef::len, tempsensRegConfig, and tempsensRegTemp.

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.

Note
The sensor on the the DK, STDS75, does not seem to have any check on max temperature limit, ie when exceeding specified max 125 C limit, it will keep increasing 9 bit counter to max representable 9 bit value of 127.5 C and then flip over to negative numbers. There is no limit check in this implementation on such issues.
Parameters
[in]i2cPointer to I2C peripheral register block.
[in]addrI2C address for temperature sensor, in 8 bit format, where LSB is reserved for R/W bit.
[out]tempReference to structure to place temperature (in Celsius).
Returns
Returns 0 if temperature read, <0 if unable to read temperature.

Definition at line 209 of file tempsens.c.

References TEMPSENS_Temp_TypeDef::f, TEMPSENS_Temp_TypeDef::i, TEMPSENS_RegisterGet(), and tempsensRegTemp.