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)
41 
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)
54 
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)
65 
74 #define AT30TSE75X_CONFIG__OS_BIT (1 << 7)
75 #define AT30TSE75X_CONFIG__RESOLUTION_MASK (0x60)
76 #define AT30TSE75X_CONFIG__RESOLUTION_SHIFT (5)
77 #define AT30TSE75X_CONFIG__FTQ_MASK (0x18)
78 #define AT30TSE75X_CONFIG__FTQ_SHIFT (3)
79 #define AT30TSE75X_CONFIG__ALERT_POL_BIT (1 << 2)
80 #define AT30TSE75X_CONFIG__ALARM_MODE_BIT (1 << 1)
81 #define AT30TSE75X_CONFIG__SHUTDOWN_BIT (1 << 0)
82 
89 #define AT30TSE75X_CMD__SAVE_TO_NVRAM (0x48)
90 #define AT30TSE75X_CMD__RESTORE_FROM_NVRAM (0xb8)
91 #define AT30TSE75X_CMD__GENERAL_CALL_RESET (0x06)
92 #define AT30TSE75X_CMD__GENERAL_CALL_RELATCH (0x04)
93 
100 #define AT30TSE75X_BUS_FREE_TIME_US (1U)
101 
111 typedef enum {
112  AT30TSE75X_RESOLUTION_9BIT = 0,
113  AT30TSE75X_RESOLUTION_10BIT = 1,
114  AT30TSE75X_RESOLUTION_11BIT = 2,
115  AT30TSE75X_RESOLUTION_12BIT = 3
117 
126 typedef enum {
127  AT30TSE75X_MODE_COMPARATOR,
128  AT30TSE75X_MODE_INTERRUPT,
129  AT30TSE75X_MODE_ONE_SHOT
131 
135 typedef enum {
136  AT30TSE75X_ALARM_AFTER_1 = 0,
137  AT30TSE75X_ALARM_AFTER_2 = 1,
138  AT30TSE75X_ALARM_AFTER_4 = 2,
139  AT30TSE75X_ALARM_AFTER_6 = 3
141 
145 typedef enum {
146  AT30TSE75X_ALARM_ACTIVE_LOW,
147  AT30TSE75X_ALARM_ACTIVE_HIGH
149  /* AT30TSE75x configuration types */
151 
155 typedef struct {
157  uint8_t addr;
158 } at30tse75x_t;
159 
174 int at30tse75x_init(at30tse75x_t* dev, i2c_t i2c, uint8_t addr);
175 
184 int at30tse75x_save_config(const at30tse75x_t* dev);
185 
195 
205 int at30tse75x_get_config(const at30tse75x_t* dev, uint8_t* data);
206 
216 int at30tse75x_set_config(const at30tse75x_t* dev, uint8_t data);
217 
229 
241 
253 
265 
276 int at30tse75x_set_limit_low(const at30tse75x_t* dev, int8_t t_low);
277 
287 int at30tse75x_set_limit_high(const at30tse75x_t* dev, int8_t t_high);
288 
298 int at30tse75x_get_temperature(const at30tse75x_t* dev, float* temperature);
299 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif /* AT30TSE75X_H */
305 
at30tse75x_set_limit_low
int at30tse75x_set_limit_low(const at30tse75x_t *dev, int8_t t_low)
Set T_Low limit.
at30tse75x_t
Device descriptor for a AT30TSE75x device.
Definition: at30tse75x.h:155
at30tse75x_get_config
int at30tse75x_get_config(const at30tse75x_t *dev, uint8_t *data)
Get content of configuration register.
at30tse75x_get_temperature
int at30tse75x_get_temperature(const at30tse75x_t *dev, float *temperature)
Get measured temperature.
at30tse75x_set_config
int at30tse75x_set_config(const at30tse75x_t *dev, uint8_t data)
Set content of configuration register.
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
at30tse75x_save_config
int at30tse75x_save_config(const at30tse75x_t *dev)
Save configuration register to non-volatile backup register.
at30tse75x_restore_config
int at30tse75x_restore_config(const at30tse75x_t *dev)
Restore configuration register from non-volatile backup register.
at30tse75x_set_alarm_polarity
int at30tse75x_set_alarm_polarity(const at30tse75x_t *dev, at30tse75x_alarm_polatity_t polarity)
Set polarity of ALERT pin.
at30tse75x_set_fault_tolerance
int at30tse75x_set_fault_tolerance(const at30tse75x_t *dev, at30tse75x_fault_tolerance_t tolerance)
Set tolerance to outlying measurements.
at30tse75x_init
int at30tse75x_init(at30tse75x_t *dev, i2c_t i2c, uint8_t addr)
Initialize a AT30TSE75x device.
at30tse75x_set_resolution
int at30tse75x_set_resolution(const at30tse75x_t *dev, at30tse75x_resolution_t resolution)
Set temperature resolution.
at30tse75x_set_mode
int at30tse75x_set_mode(const at30tse75x_t *dev, at30tse75x_mode_t mode)
Set operation mode.
at30tse75x_fault_tolerance_t
at30tse75x_fault_tolerance_t
After how many limit exceeding measurements the ALERT pin is set.
Definition: at30tse75x.h:135
at30tse75x_t::i2c
i2c_t i2c
I2C device that sensor is connected to.
Definition: at30tse75x.h:156
at30tse75x_t::addr
uint8_t addr
I2C address of this particular sensor.
Definition: at30tse75x.h:157
at30tse75x_set_limit_high
int at30tse75x_set_limit_high(const at30tse75x_t *dev, int8_t t_high)
Set T_High limit.
at30tse75x_resolution_t
at30tse75x_resolution_t
Temperature resolution.
Definition: at30tse75x.h:111
i2c.h
Low-level I2C peripheral driver interface definition.
at30tse75x_alarm_polatity_t
at30tse75x_alarm_polatity_t
Polarity of the ALERT pin.
Definition: at30tse75x.h:145
at30tse75x_mode_t
at30tse75x_mode_t
Operation mode.
Definition: at30tse75x.h:126