AT30TSE75x temperature sensor with EEPROM

Detailed Description

The connection between the MCU and the AT30TSE75x is based on the I2C-interface. There are 3 versions of this IC, with either 2/4/8 Kb of EEPROM.

Files

file  at30tse75x.h
 Driver for the AT30TSE75x temperature sensor with serial EEPROM.
 

Data Structures

struct  at30tse75x_t
 Device descriptor for a AT30TSE75x device. More...
 

Functions

int at30tse75x_init (at30tse75x_t *dev, i2c_t i2c, uint8_t addr)
 Initialize a AT30TSE75x device. More...
 
int at30tse75x_save_config (const at30tse75x_t *dev)
 Save configuration register to non-volatile backup register. More...
 
int at30tse75x_restore_config (const at30tse75x_t *dev)
 Restore configuration register from non-volatile backup register. More...
 
int at30tse75x_get_config (const at30tse75x_t *dev, uint8_t *data)
 Get content of configuration register. More...
 
int at30tse75x_set_config (const at30tse75x_t *dev, uint8_t data)
 Set content of configuration register. More...
 
int at30tse75x_set_resolution (const at30tse75x_t *dev, at30tse75x_resolution_t resolution)
 Set temperature resolution. More...
 
int at30tse75x_set_mode (const at30tse75x_t *dev, at30tse75x_mode_t mode)
 Set operation mode. More...
 
int at30tse75x_set_alarm_polarity (const at30tse75x_t *dev, at30tse75x_alarm_polatity_t polarity)
 Set polarity of ALERT pin. More...
 
int at30tse75x_set_fault_tolerance (const at30tse75x_t *dev, at30tse75x_fault_tolerance_t tolerance)
 Set tolerance to outlying measurements. More...
 
int at30tse75x_set_limit_low (const at30tse75x_t *dev, int8_t t_low)
 Set T_Low limit. More...
 
int at30tse75x_set_limit_high (const at30tse75x_t *dev, int8_t t_high)
 Set T_High limit. More...
 
int at30tse75x_get_temperature (const at30tse75x_t *dev, float *temperature)
 Get measured temperature. More...
 

AT30TSE75x I2C addresses

#define AT30TSE75X_TEMP_ADDR   (0x48)
 
#define AT30TSE75X_EEPROM_ADDR   (0x50)
 

AT30TSE75x register addresses

#define AT30TSE75X_REG__TEMPERATURE   (0x00)
 
#define AT30TSE75X_REG__CONFIG   (0x01)
 
#define AT30TSE75X_REG__LIMIT_LOW   (0x02)
 
#define AT30TSE75X_REG__LIMIT_HIGH   (0x03)
 
#define AT30TSE75X_REG__NV_CONFIG   (0x11)
 
#define AT30TSE75X_REG__NV_LIMIT_LOW   (0x12)
 
#define AT30TSE75X_REG__NV_LIMIR_HIGH   (0x13)
 

AT30TSE75x number formatting

#define AT30TSE75X_INTEGER_MASK   (0x00ff)
 
#define AT30TSE75X_INTEGER_SHIFT   (0)
 
#define AT30TSE75X_FRACTIONAL_MASK   (0xf000)
 
#define AT30TSE75X_FRACTIONAL_SHIFT   (12)
 
#define AT30TSE75X_FRACTIONAL_BASE   (0.0625f)
 

AT30TSE75x configuration register

Only upper byte can be read/written, so treat as 8-bit register.

#define AT30TSE75X_CONFIG__OS_BIT   (1 << 7)
 
#define AT30TSE75X_CONFIG__RESOLUTION_MASK   (0x60)
 
#define AT30TSE75X_CONFIG__RESOLUTION_SHIFT   (5)
 
#define AT30TSE75X_CONFIG__FTQ_MASK   (0x18)
 
#define AT30TSE75X_CONFIG__FTQ_SHIFT   (3)
 
#define AT30TSE75X_CONFIG__ALERT_POL_BIT   (1 << 2)
 
#define AT30TSE75X_CONFIG__ALARM_MODE_BIT   (1 << 1)
 
#define AT30TSE75X_CONFIG__SHUTDOWN_BIT   (1 << 0)
 

AT30TSE75x commands

#define AT30TSE75X_CMD__SAVE_TO_NVRAM   (0x48)
 
#define AT30TSE75X_CMD__RESTORE_FROM_NVRAM   (0xb8)
 
#define AT30TSE75X_CMD__GENERAL_CALL_RESET   (0x06)
 
#define AT30TSE75X_CMD__GENERAL_CALL_RELATCH   (0x04)
 

AT30TSE75x constants

#define AT30TSE75X_BUS_FREE_TIME_US   (1U)
 

AT30TSE75x configuration types

enum  at30tse75x_resolution_t { AT30TSE75X_RESOLUTION_9BIT = 0, AT30TSE75X_RESOLUTION_10BIT = 1, AT30TSE75X_RESOLUTION_11BIT = 2, AT30TSE75X_RESOLUTION_12BIT = 3 }
 Temperature resolution.
 
enum  at30tse75x_mode_t { AT30TSE75X_MODE_COMPARATOR, AT30TSE75X_MODE_INTERRUPT, AT30TSE75X_MODE_ONE_SHOT }
 Operation mode. More...
 
enum  at30tse75x_fault_tolerance_t { AT30TSE75X_ALARM_AFTER_1 = 0, AT30TSE75X_ALARM_AFTER_2 = 1, AT30TSE75X_ALARM_AFTER_4 = 2, AT30TSE75X_ALARM_AFTER_6 = 3 }
 After how many limit exceeding measurements the ALERT pin is set.
 
enum  at30tse75x_alarm_polatity_t { AT30TSE75X_ALARM_ACTIVE_LOW, AT30TSE75X_ALARM_ACTIVE_HIGH }
 Polarity of the ALERT pin.
 

Enumeration Type Documentation

◆ at30tse75x_mode_t

Operation mode.

The device can run in continuous or one-shot mode. While in one-shot mode it is effectively shutdown and only wakes up to perform a single measurement. When in comparator or interrupt mode, the device samples contiously the temperature and sets the ALERT pin according to the chosen mode.

Definition at line 126 of file at30tse75x.h.

Function Documentation

◆ at30tse75x_get_config()

int at30tse75x_get_config ( const at30tse75x_t dev,
uint8_t *  data 
)

Get content of configuration register.

Parameters
[in]devdevice descriptor
[out]databuffer where config register will be written to
Returns
0 on success
-1 on error

◆ at30tse75x_get_temperature()

int at30tse75x_get_temperature ( const at30tse75x_t dev,
float *  temperature 
)

Get measured temperature.

Parameters
[in]devdevice descriptor
[out]temperaturefloat buffer where temperature will be written to
Returns
0 on success
-1 on error

◆ at30tse75x_init()

int at30tse75x_init ( at30tse75x_t dev,
i2c_t  i2c,
uint8_t  addr 
)

Initialize a AT30TSE75x device.

Parameters
[out]devdevice descriptor
[in]i2cI2C bus the device is connected to
[in]addrI2C address of the device

The valid address range is 0x48 - 0x4f depending on the configuration of the address pins A0-A2.

Returns
0 on success
-1 on error
-2 on invalid address

◆ at30tse75x_restore_config()

int at30tse75x_restore_config ( const at30tse75x_t dev)

Restore configuration register from non-volatile backup register.

Parameters
[in]devdevice descriptor
Returns
0 on success
-1 on error

◆ at30tse75x_save_config()

int at30tse75x_save_config ( const at30tse75x_t dev)

Save configuration register to non-volatile backup register.

Parameters
[in]devdevice descriptor
Returns
0 on success
-1 on error

◆ at30tse75x_set_alarm_polarity()

int at30tse75x_set_alarm_polarity ( const at30tse75x_t dev,
at30tse75x_alarm_polatity_t  polarity 
)

Set polarity of ALERT pin.

Parameters
[in]devdevice descriptor
[in]polaritypolarity of ALERT pin
Returns
0 on success
-1 on device error
-2 on bad user input

◆ at30tse75x_set_config()

int at30tse75x_set_config ( const at30tse75x_t dev,
uint8_t  data 
)

Set content of configuration register.

Parameters
[in]devdevice descriptor
[in]datanew value for configuration register
Returns
0 on success
-1 on error

◆ at30tse75x_set_fault_tolerance()

int at30tse75x_set_fault_tolerance ( const at30tse75x_t dev,
at30tse75x_fault_tolerance_t  tolerance 
)

Set tolerance to outlying measurements.

Parameters
[in]devdevice descriptor
[in]tolerancetolerance
Returns
0 on success
-1 on device error
-2 on bad user input

◆ at30tse75x_set_limit_high()

int at30tse75x_set_limit_high ( const at30tse75x_t dev,
int8_t  t_high 
)

Set T_High limit.

Parameters
[in]devdevice descriptor
[in]t_highupper temperature limit
Returns
0 on success
-1 on error

◆ at30tse75x_set_limit_low()

int at30tse75x_set_limit_low ( const at30tse75x_t dev,
int8_t  t_low 
)

Set T_Low limit.

Parameters
[in]devdevice descriptor
[in]t_lowlower temperature limit
Returns
0 on success
-1 on device error
-2 on bad user input

◆ at30tse75x_set_mode()

int at30tse75x_set_mode ( const at30tse75x_t dev,
at30tse75x_mode_t  mode 
)

Set operation mode.

Parameters
[in]devdevice descriptor
[in]modeoperation mode
Returns
0 on success
-1 on device error
-2 on bad user input

◆ at30tse75x_set_resolution()

int at30tse75x_set_resolution ( const at30tse75x_t dev,
at30tse75x_resolution_t  resolution 
)

Set temperature resolution.

Parameters
[in]devdevice descriptor
[in]resolutiontemperature resolution
Returns
0 on success
-1 on error
-2 on bad user input