The friendly Operating System for the Internet of Things
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 
110 typedef enum {
111  AT30TSE75X_RESOLUTION_9BIT = 0,
112  AT30TSE75X_RESOLUTION_10BIT = 1,
113  AT30TSE75X_RESOLUTION_11BIT = 2,
114  AT30TSE75X_RESOLUTION_12BIT = 3
115 } at30tse75x_resolution_t;
127 typedef enum {
128  AT30TSE75X_MODE_COMPARATOR,
129  AT30TSE75X_MODE_INTERRUPT,
130  AT30TSE75X_MODE_ONE_SHOT
138 typedef enum {
139  AT30TSE75X_ALARM_AFTER_1 = 0,
140  AT30TSE75X_ALARM_AFTER_2 = 1,
141  AT30TSE75X_ALARM_AFTER_4 = 2,
142  AT30TSE75X_ALARM_AFTER_6 = 3
150 typedef enum {
151  AT30TSE75X_ALARM_ACTIVE_LOW,
152  AT30TSE75X_ALARM_ACTIVE_HIGH
160 typedef struct {
162  uint8_t addr;
163 } at30tse75x_t;
181 int at30tse75x_init(at30tse75x_t* dev, i2c_t i2c, i2c_speed_t speed, uint8_t addr);
182 
192 
202 
212 int at30tse75x_get_config(at30tse75x_t* dev, uint8_t* data);
213 
223 int at30tse75x_set_config(at30tse75x_t* dev, uint8_t data);
224 
235 int at30tse75x_set_resolution(at30tse75x_t* dev, at30tse75x_resolution_t resolution);
236 
248 
260 
272 
283 int at30tse75x_set_limit_low(at30tse75x_t* dev, int8_t t_low);
284 
294 int at30tse75x_set_limit_high(at30tse75x_t* dev, int8_t t_high);
295 
305 int at30tse75x_get_temperature(at30tse75x_t* dev, float* temperature);
306 
307 #ifdef __cplusplus
308 }
309 #endif
310 
312 #endif /* AT30TSE75X_H */
int at30tse75x_restore_config(at30tse75x_t *dev)
Restore configuration register from non-volatile backup register.
Device descriptor for a AT30TSE75x device.
Definition: at30tse75x.h:160
int at30tse75x_set_mode(at30tse75x_t *dev, at30tse75x_mode_t mode)
Set operation mode.
int at30tse75x_get_temperature(at30tse75x_t *dev, float *temperature)
Get measured temperature.
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
at30tse75x_alarm_polatity_t
Polarity of the ALERT pin.
Definition: at30tse75x.h:150
int at30tse75x_save_config(at30tse75x_t *dev)
Save configuration register to non-volatile backup register.
int at30tse75x_set_fault_tolerance(at30tse75x_t *dev, at30tse75x_fault_tolerance_t tolerance)
Set tolerance to outlying measurements.
int at30tse75x_set_resolution(at30tse75x_t *dev, at30tse75x_resolution_t resolution)
Set temperature resolution.
int at30tse75x_set_config(at30tse75x_t *dev, uint8_t data)
Set content of configuration register.
int at30tse75x_init(at30tse75x_t *dev, i2c_t i2c, i2c_speed_t speed, uint8_t addr)
Initialize a AT30TSE75x device.
int at30tse75x_set_alarm_polarity(at30tse75x_t *dev, at30tse75x_alarm_polatity_t polarity)
Set polarity of ALERT pin.
at30tse75x_mode_t
Operation mode.
Definition: at30tse75x.h:127
int at30tse75x_get_config(at30tse75x_t *dev, uint8_t *data)
Get content of configuration register.
uint8_t addr
I2C address of this particular sensor.
Definition: at30tse75x.h:162
i2c_t i2c
I2C device that sensor is connected to.
Definition: at30tse75x.h:161
at30tse75x_fault_tolerance_t
After how many limit exceeding measurements the ALERT pin is set.
Definition: at30tse75x.h:138
int at30tse75x_set_limit_low(at30tse75x_t *dev, int8_t t_low)
Set T_Low limit.
Low-level I2C peripheral driver interface definition.
int at30tse75x_set_limit_high(at30tse75x_t *dev, int8_t t_high)
Set T_High limit.