at30tse75x.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Daniel Krebs
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
25 #ifndef AT30TSE75X_H
26 #define AT30TSE75X_H
27 
28 #include <stdint.h>
29 #include "periph/i2c.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
39 #define AT30TSE75X_TEMP_ADDR (0x48)
40 #define AT30TSE75X_EEPROM_ADDR (0x50)
47 #define AT30TSE75X_REG__TEMPERATURE (0x00)
48 #define AT30TSE75X_REG__CONFIG (0x01)
49 #define AT30TSE75X_REG__LIMIT_LOW (0x02)
50 #define AT30TSE75X_REG__LIMIT_HIGH (0x03)
51 #define AT30TSE75X_REG__NV_CONFIG (0x11)
52 #define AT30TSE75X_REG__NV_LIMIT_LOW (0x12)
53 #define AT30TSE75X_REG__NV_LIMIR_HIGH (0x13)
60 #define AT30TSE75X_INTEGER_MASK (0x00ff)
61 #define AT30TSE75X_INTEGER_SHIFT (0)
62 #define AT30TSE75X_FRACTIONAL_MASK (0xf000)
63 #define AT30TSE75X_FRACTIONAL_SHIFT (12)
64 #define AT30TSE75X_FRACTIONAL_BASE (0.0625f)
73 #define AT30TSE75X_CONFIG__OS_BIT (1 << 7)
74 #define AT30TSE75X_CONFIG__RESOLUTION_MASK (0x60)
75 #define AT30TSE75X_CONFIG__RESOLUTION_SHIFT (5)
76 #define AT30TSE75X_CONFIG__FTQ_MASK (0x18)
77 #define AT30TSE75X_CONFIG__FTQ_SHIFT (3)
78 #define AT30TSE75X_CONFIG__ALERT_POL_BIT (1 << 2)
79 #define AT30TSE75X_CONFIG__ALARM_MODE_BIT (1 << 1)
80 #define AT30TSE75X_CONFIG__SHUTDOWN_BIT (1 << 0)
88 #define AT30TSE75X_CMD__SAVE_TO_NVRAM (0x48)
89 #define AT30TSE75X_CMD__RESTORE_FROM_NVRAM (0xb8)
90 #define AT30TSE75X_CMD__GENERAL_CALL_RESET (0x06)
91 #define AT30TSE75X_CMD__GENERAL_CALL_RELATCH (0x04)
99 #define AT30TSE75X_BUS_FREE_TIME_US (1U)
110 typedef enum {
111  AT30TSE75X_RESOLUTION_9BIT = 0,
112  AT30TSE75X_RESOLUTION_10BIT = 1,
113  AT30TSE75X_RESOLUTION_11BIT = 2,
114  AT30TSE75X_RESOLUTION_12BIT = 3
116 
125 typedef enum {
126  AT30TSE75X_MODE_COMPARATOR,
127  AT30TSE75X_MODE_INTERRUPT,
128  AT30TSE75X_MODE_ONE_SHOT
130 
134 typedef enum {
135  AT30TSE75X_ALARM_AFTER_1 = 0,
136  AT30TSE75X_ALARM_AFTER_2 = 1,
137  AT30TSE75X_ALARM_AFTER_4 = 2,
138  AT30TSE75X_ALARM_AFTER_6 = 3
140 
144 typedef enum {
145  AT30TSE75X_ALARM_ACTIVE_LOW,
146  AT30TSE75X_ALARM_ACTIVE_HIGH
148  /* AT30TSE75x configuration types */
150 
154 typedef struct {
156  uint8_t addr;
157 } at30tse75x_t;
158 
173 int at30tse75x_init(at30tse75x_t* dev, i2c_t i2c, uint8_t addr);
174 
184 
194 
204 int at30tse75x_get_config(const at30tse75x_t* dev, uint8_t* data);
205 
215 int at30tse75x_set_config(const at30tse75x_t* dev, uint8_t data);
216 
228 
240 
252 
264 
275 int at30tse75x_set_limit_low(const at30tse75x_t* dev, int8_t t_low);
276 
286 int at30tse75x_set_limit_high(const at30tse75x_t* dev, int8_t t_high);
287 
297 int at30tse75x_get_temperature(const at30tse75x_t* dev, float* temperature);
298 
299 #ifdef __cplusplus
300 }
301 #endif
302 
303 #endif /* AT30TSE75X_H */
int at30tse75x_set_limit_low(const at30tse75x_t *dev, int8_t t_low)
Set T_Low limit.
int at30tse75x_get_temperature(const at30tse75x_t *dev, float *temperature)
Get measured temperature.
at30tse75x_alarm_polatity_t
Polarity of the ALERT pin.
Definition: at30tse75x.h:144
int at30tse75x_set_config(const at30tse75x_t *dev, uint8_t data)
Set content of configuration register.
int at30tse75x_save_config(const at30tse75x_t *dev)
Save configuration register to non-volatile backup register.
int at30tse75x_set_mode(const at30tse75x_t *dev, at30tse75x_mode_t mode)
Set operation mode.
at30tse75x_fault_tolerance_t
After how many limit exceeding measurements the ALERT pin is set.
Definition: at30tse75x.h:134
int at30tse75x_get_config(const at30tse75x_t *dev, uint8_t *data)
Get content of configuration register.
int at30tse75x_set_resolution(const at30tse75x_t *dev, at30tse75x_resolution_t resolution)
Set temperature resolution.
int at30tse75x_set_fault_tolerance(const at30tse75x_t *dev, at30tse75x_fault_tolerance_t tolerance)
Set tolerance to outlying measurements.
int at30tse75x_set_alarm_polarity(const at30tse75x_t *dev, at30tse75x_alarm_polatity_t polarity)
Set polarity of ALERT pin.
int at30tse75x_init(at30tse75x_t *dev, i2c_t i2c, uint8_t addr)
Initialize a AT30TSE75x device.
int at30tse75x_restore_config(const at30tse75x_t *dev)
Restore configuration register from non-volatile backup register.
at30tse75x_mode_t
Operation mode.
Definition: at30tse75x.h:125
int at30tse75x_set_limit_high(const at30tse75x_t *dev, int8_t t_high)
Set T_High limit.
at30tse75x_resolution_t
Temperature resolution.
Definition: at30tse75x.h:110
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition: i2c.h:145
Low-level I2C peripheral driver interface definition.
Device descriptor for a AT30TSE75x device.
Definition: at30tse75x.h:154
i2c_t i2c
I2C device that sensor is connected to.
Definition: at30tse75x.h:155
uint8_t addr
I2C address of this particular sensor.
Definition: at30tse75x.h:156