Loading...
Searching...
No Matches
tmp00x.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 PHYTEC Messtechnik GmbH
3 * SPDX-FileCopyrightText: 2017-2019 HAW Hamburg
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#pragma once
8
78
79#include <stdint.h>
80#include <stdbool.h>
81#include "periph/i2c.h"
82#include "kernel_defines.h"
83
84#ifdef __cplusplus
85extern "C"
86{
87#endif
88
89#define BUS (dev->p.i2c)
90#define ADDR (dev->p.addr)
91
105#ifndef CONFIG_TMP00X_I2C_ADDRESS
106#define CONFIG_TMP00X_I2C_ADDRESS (0x40)
107#endif
108
116#if IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_0_25S)
117#define CONFIG_TMP00X_CONVERSION_TIME (25E4)
118#elif IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_0_5S)
119#define CONFIG_TMP00X_CONVERSION_TIME (5E5)
120#elif IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_1S)
121#define CONFIG_TMP00X_CONVERSION_TIME (1E6)
122#elif IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_2S)
123#define CONFIG_TMP00X_CONVERSION_TIME (2E6)
124#elif IS_ACTIVE(CONFIG_TMP00X_CONVERSION_TIME_4S)
125#define CONFIG_TMP00X_CONVERSION_TIME (4E6)
126#endif
127
128#ifndef CONFIG_TMP00X_CONVERSION_TIME
129#define CONFIG_TMP00X_CONVERSION_TIME (1E6)
130#endif
131
140#ifdef DOXYGEN
141#define CONFIG_TMP00X_USE_LOW_POWER
142#endif
143
150#ifdef DOXYGEN
151#define CONFIG_TMP00X_USE_RAW_VALUES
152#endif
154
159#define TMP00X_CONFIG_CR_AS1 (0x00)
160#define TMP00X_CONFIG_CR_AS2 (0x01)
161#define TMP00X_CONFIG_CR_AS4 (0x02)
162#define TMP00X_CONFIG_CR_AS8 (0x03)
163#define TMP00X_CONFIG_CR_AS16 (0x04)
164#define TMP00X_CONFIG_CR_DEF TMP00X_CONFIG_CR_AS4
166
171#ifndef TMP00X_CCONST_S0
172#define TMP00X_CCONST_S0 (6.4E-14)
173#endif
174#define TMP00X_CCONST_A1 (1.75E-3)
175#define TMP00X_CCONST_A2 (-1.678E-5)
176#define TMP00X_CCONST_TREF (298.15)
177#define TMP00X_CCONST_B0 (-2.94E-5)
178#define TMP00X_CCONST_B1 (-5.7E-7)
179#define TMP00X_CCONST_B2 (4.63E-9)
180#define TMP00X_CCONST_C2 (13.4)
181#define TMP00X_CCONST_LSB_SIZE (156.25E-9)
183
187typedef struct {
189 uint8_t addr;
190 uint8_t rate;
192
196typedef struct {
198} tmp00x_t;
199
203enum {
209};
210
222int tmp00x_init(tmp00x_t *dev, const tmp00x_params_t *params);
223
232int tmp00x_reset(const tmp00x_t *dev);
233
243
253
265int tmp00x_read(const tmp00x_t *dev, int16_t *rawv, int16_t *rawt, uint16_t *drdy);
266
275void tmp00x_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj);
276
290int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to);
291
292#ifdef __cplusplus
293}
294#endif
295
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
int tmp00x_read(const tmp00x_t *dev, int16_t *rawv, int16_t *rawt, uint16_t *drdy)
Read sensor's data.
int tmp00x_set_standby(const tmp00x_t *dev)
Set standby mode.
int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to)
Convenience function to get ambient and object temperatures in [°C].
void tmp00x_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj)
Convert raw sensor values to temperature.
int tmp00x_init(tmp00x_t *dev, const tmp00x_params_t *params)
Initialize the TMP00X sensor driver.
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.
@ TMP00X_ERROR_DEV
internal device error
Definition tmp00x.h:206
@ TMP00X_ERROR_CONF
invalid device configuration
Definition tmp00x.h:207
@ TMP00X_ERROR
general error
Definition tmp00x.h:208
@ TMP00X_OK
Success, no error.
Definition tmp00x.h:204
@ TMP00X_ERROR_BUS
I2C bus error.
Definition tmp00x.h:205
Low-level I2C peripheral driver interface definition.
Common macros and compiler attributes/pragmas configuration.
Parameters needed for device initialization.
Definition tmp00x.h:187
i2c_t i2c
I2C device, the sensor is connected to.
Definition tmp00x.h:188
uint8_t rate
number of averaged samples
Definition tmp00x.h:190
uint8_t addr
the sensor's slave address on the I2C bus
Definition tmp00x.h:189
Device descriptor for TMP00X sensors.
Definition tmp00x.h:196
tmp00x_params_t p
Configuration parameters.
Definition tmp00x.h:197