Loading...
Searching...
No Matches
AT30TSE75x temperature sensor with EEPROM

The connection between the MCU and the AT30TSE75x is based on the I2C-interface. More...

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.
 
int at30tse75x_save_config (const at30tse75x_t *dev)
 Save configuration register to non-volatile backup register.
 
int at30tse75x_restore_config (const at30tse75x_t *dev)
 Restore configuration register from non-volatile backup register.
 
int at30tse75x_get_config (const at30tse75x_t *dev, uint8_t *data)
 Get content of configuration register.
 
int at30tse75x_set_config (const at30tse75x_t *dev, uint8_t data)
 Set content of configuration register.
 
int at30tse75x_set_resolution (const at30tse75x_t *dev, at30tse75x_resolution_t resolution)
 Set temperature resolution.
 
int at30tse75x_set_mode (const at30tse75x_t *dev, at30tse75x_mode_t mode)
 Set operation mode.
 
int at30tse75x_set_alarm_polarity (const at30tse75x_t *dev, at30tse75x_alarm_polatity_t polarity)
 Set polarity of ALERT pin.
 
int at30tse75x_set_fault_tolerance (const at30tse75x_t *dev, at30tse75x_fault_tolerance_t tolerance)
 Set tolerance to outlying measurements.
 
int at30tse75x_set_limit_low (const at30tse75x_t *dev, int8_t t_low)
 Set T_Low limit.
 
int at30tse75x_set_limit_high (const at30tse75x_t *dev, int8_t t_high)
 Set T_High limit.
 
int at30tse75x_get_temperature (const at30tse75x_t *dev, float *temperature)
 Get measured temperature.
 

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. More...
 
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. More...
 
enum  at30tse75x_alarm_polatity_t { AT30TSE75X_ALARM_ACTIVE_LOW , AT30TSE75X_ALARM_ACTIVE_HIGH }
 Polarity of the ALERT pin. 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)
 

Macro Definition Documentation

◆ AT30TSE75X_BUS_FREE_TIME_US

#define AT30TSE75X_BUS_FREE_TIME_US   (1U)

Definition at line 99 of file at30tse75x.h.

◆ AT30TSE75X_CMD__GENERAL_CALL_RELATCH

#define AT30TSE75X_CMD__GENERAL_CALL_RELATCH   (0x04)

Definition at line 91 of file at30tse75x.h.

◆ AT30TSE75X_CMD__GENERAL_CALL_RESET

#define AT30TSE75X_CMD__GENERAL_CALL_RESET   (0x06)

Definition at line 90 of file at30tse75x.h.

◆ AT30TSE75X_CMD__RESTORE_FROM_NVRAM

#define AT30TSE75X_CMD__RESTORE_FROM_NVRAM   (0xb8)

Definition at line 89 of file at30tse75x.h.

◆ AT30TSE75X_CMD__SAVE_TO_NVRAM

#define AT30TSE75X_CMD__SAVE_TO_NVRAM   (0x48)

Definition at line 88 of file at30tse75x.h.

◆ AT30TSE75X_CONFIG__ALARM_MODE_BIT

#define AT30TSE75X_CONFIG__ALARM_MODE_BIT   (1 << 1)

Definition at line 79 of file at30tse75x.h.

◆ AT30TSE75X_CONFIG__ALERT_POL_BIT

#define AT30TSE75X_CONFIG__ALERT_POL_BIT   (1 << 2)

Definition at line 78 of file at30tse75x.h.

◆ AT30TSE75X_CONFIG__FTQ_MASK

#define AT30TSE75X_CONFIG__FTQ_MASK   (0x18)

Definition at line 76 of file at30tse75x.h.

◆ AT30TSE75X_CONFIG__FTQ_SHIFT

#define AT30TSE75X_CONFIG__FTQ_SHIFT   (3)

Definition at line 77 of file at30tse75x.h.

◆ AT30TSE75X_CONFIG__OS_BIT

#define AT30TSE75X_CONFIG__OS_BIT   (1 << 7)

Definition at line 73 of file at30tse75x.h.

◆ AT30TSE75X_CONFIG__RESOLUTION_MASK

#define AT30TSE75X_CONFIG__RESOLUTION_MASK   (0x60)

Definition at line 74 of file at30tse75x.h.

◆ AT30TSE75X_CONFIG__RESOLUTION_SHIFT

#define AT30TSE75X_CONFIG__RESOLUTION_SHIFT   (5)

Definition at line 75 of file at30tse75x.h.

◆ AT30TSE75X_CONFIG__SHUTDOWN_BIT

#define AT30TSE75X_CONFIG__SHUTDOWN_BIT   (1 << 0)

Definition at line 80 of file at30tse75x.h.

◆ AT30TSE75X_EEPROM_ADDR

#define AT30TSE75X_EEPROM_ADDR   (0x50)

Definition at line 40 of file at30tse75x.h.

◆ AT30TSE75X_FRACTIONAL_BASE

#define AT30TSE75X_FRACTIONAL_BASE   (0.0625f)

Definition at line 64 of file at30tse75x.h.

◆ AT30TSE75X_FRACTIONAL_MASK

#define AT30TSE75X_FRACTIONAL_MASK   (0xf000)

Definition at line 62 of file at30tse75x.h.

◆ AT30TSE75X_FRACTIONAL_SHIFT

#define AT30TSE75X_FRACTIONAL_SHIFT   (12)

Definition at line 63 of file at30tse75x.h.

◆ AT30TSE75X_INTEGER_MASK

#define AT30TSE75X_INTEGER_MASK   (0x00ff)

Definition at line 60 of file at30tse75x.h.

◆ AT30TSE75X_INTEGER_SHIFT

#define AT30TSE75X_INTEGER_SHIFT   (0)

Definition at line 61 of file at30tse75x.h.

◆ AT30TSE75X_REG__CONFIG

#define AT30TSE75X_REG__CONFIG   (0x01)

Definition at line 48 of file at30tse75x.h.

◆ AT30TSE75X_REG__LIMIT_HIGH

#define AT30TSE75X_REG__LIMIT_HIGH   (0x03)

Definition at line 50 of file at30tse75x.h.

◆ AT30TSE75X_REG__LIMIT_LOW

#define AT30TSE75X_REG__LIMIT_LOW   (0x02)

Definition at line 49 of file at30tse75x.h.

◆ AT30TSE75X_REG__NV_CONFIG

#define AT30TSE75X_REG__NV_CONFIG   (0x11)

Definition at line 51 of file at30tse75x.h.

◆ AT30TSE75X_REG__NV_LIMIR_HIGH

#define AT30TSE75X_REG__NV_LIMIR_HIGH   (0x13)

Definition at line 53 of file at30tse75x.h.

◆ AT30TSE75X_REG__NV_LIMIT_LOW

#define AT30TSE75X_REG__NV_LIMIT_LOW   (0x12)

Definition at line 52 of file at30tse75x.h.

◆ AT30TSE75X_REG__TEMPERATURE

#define AT30TSE75X_REG__TEMPERATURE   (0x00)

Definition at line 47 of file at30tse75x.h.

◆ AT30TSE75X_TEMP_ADDR

#define AT30TSE75X_TEMP_ADDR   (0x48)

Definition at line 39 of file at30tse75x.h.

Enumeration Type Documentation

◆ at30tse75x_alarm_polatity_t

Polarity of the ALERT pin.

Definition at line 144 of file at30tse75x.h.

◆ at30tse75x_fault_tolerance_t

After how many limit exceeding measurements the ALERT pin is set.

Definition at line 134 of file at30tse75x.h.

◆ 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 continuously the temperature and sets the ALERT pin according to the chosen mode.

Definition at line 125 of file at30tse75x.h.

◆ at30tse75x_resolution_t

Temperature resolution.

Definition at line 110 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