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 
79 #ifndef TMP006_H
80 #define TMP006_H
81 
82 #include <stdint.h>
83 #include <stdbool.h>
84 #include "periph/i2c.h"
85 
86 #ifdef __cplusplus
87 extern "C"
88 {
89 #endif
90 
94 #ifndef TMP006_I2C_ADDRESS
95 #define TMP006_I2C_ADDRESS (0x41)
96 #endif
97 
101 #ifndef TMP006_CONVERSION_TIME
102 #define TMP006_CONVERSION_TIME (1E6)
103 #endif
104 
113 #ifndef TMP006_USE_LOW_POWER
114 #define TMP006_USE_LOW_POWER (0)
115 #endif
116 
123 #ifndef TMP006_USE_RAW_VALUES
124 #define TMP006_USE_RAW_VALUES (0)
125 #endif
126 
131 #define TMP006_CONFIG_CR_AS1 (0x00)
132 #define TMP006_CONFIG_CR_AS2 (0x01)
133 #define TMP006_CONFIG_CR_AS4 (0x02)
134 #define TMP006_CONFIG_CR_AS8 (0x03)
135 #define TMP006_CONFIG_CR_AS16 (0x04)
136 #define TMP006_CONFIG_CR_DEF TMP006_CONFIG_CR_AS4
143 #ifndef TMP006_CCONST_S0
144 #define TMP006_CCONST_S0 (6.4E-14)
145 #endif
146 #define TMP006_CCONST_A1 (1.75E-3)
147 #define TMP006_CCONST_A2 (-1.678E-5)
148 #define TMP006_CCONST_TREF (298.15)
149 #define TMP006_CCONST_B0 (-2.94E-5)
150 #define TMP006_CCONST_B1 (-5.7E-7)
151 #define TMP006_CCONST_B2 (4.63E-9)
152 #define TMP006_CCONST_C2 (13.4)
153 #define TMP006_CCONST_LSB_SIZE (156.25E-9)
159 typedef struct {
161  uint8_t addr;
162  uint8_t rate;
164 
168 typedef struct {
170 } tmp006_t;
171 
175 enum {
181 };
182 
194 int tmp006_init(tmp006_t *dev, const tmp006_params_t *params);
195 
204 int tmp006_reset(const tmp006_t *dev);
205 
214 int tmp006_set_active(const tmp006_t *dev);
215 
224 int tmp006_set_standby(const tmp006_t *dev);
225 
237 int tmp006_read(const tmp006_t *dev, int16_t *rawv, int16_t *rawt, uint8_t *drdy);
238 
247 void tmp006_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj);
248 
258 int tmp006_read_temperature(const tmp006_t *dev, int16_t *ta, int16_t *to);
259 
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif /* TMP006_H */
265 
Parameters needed for device initialization.
Definition: tmp006.h:159
i2c_t i2c
I2C device, the sensor is connected to.
Definition: tmp006.h:160
I2C bus error.
Definition: tmp006.h:177
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:161
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:178
tmp006_params_t p
Configuration parameters.
Definition: tmp006.h:169
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
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:162
int tmp006_reset(const tmp006_t *dev)
Reset the TMP006 sensor, afterwards it should be reinitialized.
general error
Definition: tmp006.h:180
invalid device configuration
Definition: tmp006.h:179
int tmp006_set_active(const tmp006_t *dev)
Set active mode, this enables periodic measurements.
Success, no error.
Definition: tmp006.h:176
Device descriptor for TMP006 sensors.
Definition: tmp006.h:168
int tmp006_init(tmp006_t *dev, const tmp006_params_t *params)
Initialize the TMP006 sensor driver.
Low-level I2C peripheral driver interface definition.