TempSensor
[Drivers]

Collaboration diagram for TempSensor:

Data Structures

struct  TEMPSENS_Temp_TypeDef
 Structure used to fetch temperature using integer numbers. More...

Defines

#define TEMPSENS_DK_ADDR   0x90
 I2C device address for temperature sensor on DK.

Enumerations

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

Available registers in DS75 sensor device.

More...

Functions

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

Define 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] temp Reference 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] i2c Pointer to I2C peripheral register block.
[in] addr I2C address for temperature sensor, in 8 bit format, where LSB is reserved for R/W bit.
[in] reg Register to read.
[out] val Reference 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 I2CSPM_Transfer(), and tempsensRegConfig.

Referenced by TEMPSENS_TemperatureGet().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Write to sensor register.

Parameters:
[in] i2c Pointer to I2C peripheral register block.
[in] addr I2C address for temperature sensor, in 8 bit format, where LSB is reserved for R/W bit.
[in] reg Register to write (temperature register cannot be written).
[in] val Value 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 I2CSPM_Transfer(), tempsensRegConfig, and tempsensRegTemp.

Here is the call graph for this function:

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] i2c Pointer to I2C peripheral register block.
[in] addr I2C address for temperature sensor, in 8 bit format, where LSB is reserved for R/W bit.
[out] temp Reference 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.

Here is the call graph for this function: