tmp006.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 PHYTEC Messtechnik GmbH
3  * 2017 HAW Hamburg
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
77 #ifndef TMP006_H
78 #define TMP006_H
79 
80 #include <stdint.h>
81 #include <stdbool.h>
82 #include "periph/i2c.h"
83 
84 #ifdef __cplusplus
85 extern "C"
86 {
87 #endif
88 
92 #ifndef TMP006_I2C_ADDRESS
93 #define TMP006_I2C_ADDRESS (0x41)
94 #endif
95 
99 #ifndef TMP006_CONVERSION_TIME
100 #define TMP006_CONVERSION_TIME (1E6)
101 #endif
102 
111 #ifndef TMP006_USE_LOW_POWER
112 #define TMP006_USE_LOW_POWER (0)
113 #endif
114 
121 #ifndef TMP006_USE_RAW_VALUES
122 #define TMP006_USE_RAW_VALUES (0)
123 #endif
124 
129 #define TMP006_CONFIG_CR_AS1 (0x00)
130 #define TMP006_CONFIG_CR_AS2 (0x01)
131 #define TMP006_CONFIG_CR_AS4 (0x02)
132 #define TMP006_CONFIG_CR_AS8 (0x03)
133 #define TMP006_CONFIG_CR_AS16 (0x04)
134 #define TMP006_CONFIG_CR_DEF TMP006_CONFIG_CR_AS4
141 #ifndef TMP006_CCONST_S0
142 #define TMP006_CCONST_S0 (6.4E-14)
143 #endif
144 #define TMP006_CCONST_A1 (1.75E-3)
145 #define TMP006_CCONST_A2 (-1.678E-5)
146 #define TMP006_CCONST_TREF (298.15)
147 #define TMP006_CCONST_B0 (-2.94E-5)
148 #define TMP006_CCONST_B1 (-5.7E-7)
149 #define TMP006_CCONST_B2 (4.63E-9)
150 #define TMP006_CCONST_C2 (13.4)
151 #define TMP006_CCONST_LSB_SIZE (156.25E-9)
157 typedef struct {
159  uint8_t addr;
160  uint8_t rate;
162 
166 typedef struct {
168 } tmp006_t;
169 
173 enum {
179 };
180 
192 int tmp006_init(tmp006_t *dev, const tmp006_params_t *params);
193 
202 int tmp006_reset(const tmp006_t *dev);
203 
212 int tmp006_set_active(const tmp006_t *dev);
213 
222 int tmp006_set_standby(const tmp006_t *dev);
223 
235 int tmp006_read(const tmp006_t *dev, int16_t *rawv, int16_t *rawt, uint8_t *drdy);
236 
245 void tmp006_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj);
246 
256 int tmp006_read_temperature(const tmp006_t *dev, int16_t *ta, int16_t *to);
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 
262 #endif /* TMP006_H */
263 
Parameters needed for device initialization.
Definition: tmp006.h:157
i2c_t i2c
I2C device, the sensor is connected to.
Definition: tmp006.h:158
int tmp006_set_standby(const tmp006_t *dev)
Set standby mode.
uint8_t addr
the sensor&#39;s slave address on the I2C bus
Definition: tmp006.h:159
int tmp006_read(const tmp006_t *dev, int16_t *rawv, int16_t *rawt, uint8_t *drdy)
Read sensor&#39;s data.
internal device error
Definition: tmp006.h:176
Success, no error.
Definition: tmp006.h:174
tmp006_params_t p
Configuration parameters.
Definition: tmp006.h:167
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:108
int tmp006_read_temperature(const tmp006_t *dev, int16_t *ta, int16_t *to)
Convenience function to get ambient and object temperatures in [°C].
void tmp006_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj)
Convert raw sensor values to temperature.
uint8_t rate
number of averaged samples
Definition: tmp006.h:160
int tmp006_reset(const tmp006_t *dev)
Reset the TMP006 sensor, afterwards it should be reinitialized.
I2C bus error.
Definition: tmp006.h:175
int tmp006_set_active(const tmp006_t *dev)
Set active mode, this enables periodic measurements.
Device descriptor for TMP006 sensors.
Definition: tmp006.h:166
int tmp006_init(tmp006_t *dev, const tmp006_params_t *params)
Initialize the TMP006 sensor driver.
general error
Definition: tmp006.h:178
invalid device configuration
Definition: tmp006.h:177
Low-level I2C peripheral driver interface definition.