The friendly Operating System for the Internet of Things
tmp006.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 PHYTEC Messtechnik GmbH
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 
75 #ifndef TMP006_H
76 #define TMP006_H
77 
78 #include <stdint.h>
79 #include <stdbool.h>
80 #include "periph/i2c.h"
81 
82 #ifdef __cplusplus
83 extern "C"
84 {
85 #endif
86 
87 #ifndef TMP006_I2C_ADDRESS
88 #define TMP006_I2C_ADDRESS 0x41
89 #endif
90 
91 #ifndef TMP006_CONVERSION_TIME
92 #define TMP006_CONVERSION_TIME 1E6
93 #endif
94 
95 #define TMP006_CONFIG_CR_AS1 0x00
96 #define TMP006_CONFIG_CR_AS2 0x01
97 #define TMP006_CONFIG_CR_AS4 0x02
98 #define TMP006_CONFIG_CR_AS8 0x03
99 #define TMP006_CONFIG_CR_AS16 0x04
100 #define TMP006_CONFIG_CR_DEF TMP006_CONFIG_CR_AS4
102 #ifndef TMP006_CCONST_S0
103 #define TMP006_CCONST_S0 6.4E-14
104 #endif
105 
106 #define TMP006_CCONST_A1 1.75E-3
107 #define TMP006_CCONST_A2 -1.678E-5
108 #define TMP006_CCONST_TREF 298.15
109 #define TMP006_CCONST_B0 -2.94E-5
110 #define TMP006_CCONST_B1 -5.7E-7
111 #define TMP006_CCONST_B2 4.63E-9
112 #define TMP006_CCONST_C2 13.4
113 #define TMP006_CCONST_LSB_SIZE 156.25E-9
118 typedef struct {
120  uint8_t addr;
121  bool initialized;
122 } tmp006_t;
123 
133 int tmp006_test(tmp006_t *dev);
134 
149 int tmp006_init(tmp006_t *dev, i2c_t i2c, uint8_t address, uint8_t conv_rate);
150 
159 int tmp006_reset(tmp006_t *dev);
160 
169 int tmp006_set_active(tmp006_t *dev);
170 
179 int tmp006_set_standby(tmp006_t *dev);
180 
192 int tmp006_read(tmp006_t *dev, int16_t *rawv, int16_t *rawt, uint8_t *drdy);
193 
202 void tmp006_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj);
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif
209 
int tmp006_set_active(tmp006_t *dev)
Set active mode, this enables periodic measurements.
i2c_t i2c
I2C device, the sensor is connected to.
Definition: tmp006.h:119
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
int tmp006_reset(tmp006_t *dev)
Reset the TMP006 sensor.
void tmp006_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj)
Convert raw sensor values to temperature.
int tmp006_read(tmp006_t *dev, int16_t *rawv, int16_t *rawt, uint8_t *drdy)
Read sensor's data.
int tmp006_init(tmp006_t *dev, i2c_t i2c, uint8_t address, uint8_t conv_rate)
Initialize the TMP006 sensor driver.
int tmp006_set_standby(tmp006_t *dev)
Set standby mode.
Device descriptor for TMP006 sensors.
Definition: tmp006.h:118
uint8_t addr
the sensor's slave address on the I2C bus
Definition: tmp006.h:120
int tmp006_test(tmp006_t *dev)
TMP006 sensor test.
bool initialized
sensor status, true if sensor is initialized
Definition: tmp006.h:121
Low-level I2C peripheral driver interface definition.