tmp00x.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 PHYTEC Messtechnik GmbH
3  * 2017 - 2019 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 
80 #ifndef TMP00X_H
81 #define TMP00X_H
82 
83 #include <stdint.h>
84 #include <stdbool.h>
85 #include "periph/i2c.h"
86 #include "kernel_defines.h"
87 
88 #ifdef __cplusplus
89 extern "C"
90 {
91 #endif
92 
93 #define BUS (dev->p.i2c)
94 #define ADDR (dev->p.addr)
109 #ifndef CONFIG_TMP00X_I2C_ADDRESS
110 #define CONFIG_TMP00X_I2C_ADDRESS (0x40)
111 #endif
112 
120 #if IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_0_25S)
121 #define CONFIG_TMP00X_CONVERSION_TIME (25E4)
122 #elif IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_0_5S)
123 #define CONFIG_TMP00X_CONVERSION_TIME (5E5)
124 #elif IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_1S)
125 #define CONFIG_TMP00X_CONVERSION_TIME (1E6)
126 #elif IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_2S)
127 #define CONFIG_TMP00X_CONVERSION_TIME (2E6)
128 #elif IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_4S)
129 #define CONFIG_TMP00X_CONVERSION_TIME (4E6)
130 #endif
131 
132 #ifndef CONFIG_TMP00X_CONVERSION_TIME
133 #define CONFIG_TMP00X_CONVERSION_TIME (1E6)
134 #endif
135 
144 #ifdef DOXYGEN
145 #define CONFIG_TMP00X_USE_LOW_POWER
146 #endif
147 
154 #ifdef DOXYGEN
155 #define CONFIG_TMP00X_USE_RAW_VALUES
156 #endif
157 
163 #define TMP00X_CONFIG_CR_AS1 (0x00)
164 #define TMP00X_CONFIG_CR_AS2 (0x01)
165 #define TMP00X_CONFIG_CR_AS4 (0x02)
166 #define TMP00X_CONFIG_CR_AS8 (0x03)
167 #define TMP00X_CONFIG_CR_AS16 (0x04)
168 #define TMP00X_CONFIG_CR_DEF TMP00X_CONFIG_CR_AS4
174 #ifndef TMP00X_CCONST_S0
175 #define TMP00X_CCONST_S0 (6.4E-14)
176 #endif
177 #define TMP00X_CCONST_A1 (1.75E-3)
178 #define TMP00X_CCONST_A2 (-1.678E-5)
179 #define TMP00X_CCONST_TREF (298.15)
180 #define TMP00X_CCONST_B0 (-2.94E-5)
181 #define TMP00X_CCONST_B1 (-5.7E-7)
182 #define TMP00X_CCONST_B2 (4.63E-9)
183 #define TMP00X_CCONST_C2 (13.4)
184 #define TMP00X_CCONST_LSB_SIZE (156.25E-9)
190 typedef struct {
192  uint8_t addr;
193  uint8_t rate;
195 
199 typedef struct {
201 } tmp00x_t;
202 
206 enum {
212 };
213 
225 int tmp00x_init(tmp00x_t *dev, const tmp00x_params_t *params);
226 
235 int tmp00x_reset(const tmp00x_t *dev);
236 
245 int tmp00x_set_active(const tmp00x_t *dev);
246 
255 int tmp00x_set_standby(const tmp00x_t *dev);
256 
268 int tmp00x_read(const tmp00x_t *dev, int16_t *rawv, int16_t *rawt, uint16_t *drdy);
269 
278 void tmp00x_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj);
279 
293 int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to);
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 #endif /* TMP00X_H */
300 
int tmp00x_reset(const tmp00x_t *dev)
Reset the TMP00X sensor, afterwards it should be reinitialized.
int tmp00x_set_active(const tmp00x_t *dev)
Set active mode, this enables periodic measurements.
Success, no error.
Definition: tmp00x.h:207
int tmp00x_set_standby(const tmp00x_t *dev)
Set standby mode.
general error
Definition: tmp00x.h:211
Device descriptor for TMP00X sensors.
Definition: tmp00x.h:199
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
i2c_t i2c
I2C device, the sensor is connected to.
Definition: tmp00x.h:191
int tmp00x_read(const tmp00x_t *dev, int16_t *rawv, int16_t *rawt, uint16_t *drdy)
Read sensor&#39;s data.
internal device error
Definition: tmp00x.h:209
tmp00x_params_t p
Configuration parameters.
Definition: tmp00x.h:200
void tmp00x_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj)
Convert raw sensor values to temperature.
uint8_t addr
the sensor&#39;s slave address on the I2C bus
Definition: tmp00x.h:192
invalid device configuration
Definition: tmp00x.h:210
I2C bus error.
Definition: tmp00x.h:208
Parameters needed for device initialization.
Definition: tmp00x.h:190
Common macros and compiler attributes/pragmas configuration.
int tmp00x_init(tmp00x_t *dev, const tmp00x_params_t *params)
Initialize the TMP00X sensor driver.
uint8_t rate
number of averaged samples
Definition: tmp00x.h:193
int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to)
Convenience function to get ambient and object temperatures in [°C].
Low-level I2C peripheral driver interface definition.