Loading...
Searching...
No Matches
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
9#pragma once
10
26
27#include <stdint.h>
28#include "periph/i2c.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
38#define AT30TSE75X_TEMP_ADDR (0x48)
39#define AT30TSE75X_EEPROM_ADDR (0x50)
41
46#define AT30TSE75X_REG__TEMPERATURE (0x00)
47#define AT30TSE75X_REG__CONFIG (0x01)
48#define AT30TSE75X_REG__LIMIT_LOW (0x02)
49#define AT30TSE75X_REG__LIMIT_HIGH (0x03)
50#define AT30TSE75X_REG__NV_CONFIG (0x11)
51#define AT30TSE75X_REG__NV_LIMIT_LOW (0x12)
52#define AT30TSE75X_REG__NV_LIMIR_HIGH (0x13)
54
59#define AT30TSE75X_INTEGER_MASK (0x00ff)
60#define AT30TSE75X_INTEGER_SHIFT (0)
61#define AT30TSE75X_FRACTIONAL_MASK (0xf000)
62#define AT30TSE75X_FRACTIONAL_SHIFT (12)
63#define AT30TSE75X_FRACTIONAL_BASE (0.0625f)
65
72#define AT30TSE75X_CONFIG__OS_BIT (1 << 7)
73#define AT30TSE75X_CONFIG__RESOLUTION_MASK (0x60)
74#define AT30TSE75X_CONFIG__RESOLUTION_SHIFT (5)
75#define AT30TSE75X_CONFIG__FTQ_MASK (0x18)
76#define AT30TSE75X_CONFIG__FTQ_SHIFT (3)
77#define AT30TSE75X_CONFIG__ALERT_POL_BIT (1 << 2)
78#define AT30TSE75X_CONFIG__ALARM_MODE_BIT (1 << 1)
79#define AT30TSE75X_CONFIG__SHUTDOWN_BIT (1 << 0)
81
87#define AT30TSE75X_CMD__SAVE_TO_NVRAM (0x48)
88#define AT30TSE75X_CMD__RESTORE_FROM_NVRAM (0xb8)
89#define AT30TSE75X_CMD__GENERAL_CALL_RESET (0x06)
90#define AT30TSE75X_CMD__GENERAL_CALL_RELATCH (0x04)
92
98#define AT30TSE75X_BUS_FREE_TIME_US (1U)
100
105
109typedef enum {
110 AT30TSE75X_RESOLUTION_9BIT = 0,
111 AT30TSE75X_RESOLUTION_10BIT = 1,
112 AT30TSE75X_RESOLUTION_11BIT = 2,
113 AT30TSE75X_RESOLUTION_12BIT = 3
115
124typedef enum {
125 AT30TSE75X_MODE_COMPARATOR,
126 AT30TSE75X_MODE_INTERRUPT,
127 AT30TSE75X_MODE_ONE_SHOT
129
133typedef enum {
134 AT30TSE75X_ALARM_AFTER_1 = 0,
135 AT30TSE75X_ALARM_AFTER_2 = 1,
136 AT30TSE75X_ALARM_AFTER_4 = 2,
137 AT30TSE75X_ALARM_AFTER_6 = 3
139
143typedef enum {
144 AT30TSE75X_ALARM_ACTIVE_LOW,
145 AT30TSE75X_ALARM_ACTIVE_HIGH
147 /* AT30TSE75x configuration types */
149
153typedef struct {
155 uint8_t addr;
157
172int at30tse75x_init(at30tse75x_t* dev, i2c_t i2c, uint8_t addr);
173
183
193
203int at30tse75x_get_config(const at30tse75x_t* dev, uint8_t* data);
204
214int at30tse75x_set_config(const at30tse75x_t* dev, uint8_t data);
215
227
239
251
263
274int at30tse75x_set_limit_low(const at30tse75x_t* dev, int8_t t_low);
275
285int at30tse75x_set_limit_high(const at30tse75x_t* dev, int8_t t_high);
286
296int at30tse75x_get_temperature(const at30tse75x_t* dev, float* temperature);
297
298#ifdef __cplusplus
299}
300#endif
301
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:143
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:133
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:124
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:109
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:144
Low-level I2C peripheral driver interface definition.
Device descriptor for a AT30TSE75x device.
Definition at30tse75x.h:153
i2c_t i2c
I2C device that sensor is connected to.
Definition at30tse75x.h:154
uint8_t addr
I2C address of this particular sensor.
Definition at30tse75x.h:155