diff --git a/drivers/Makefile.dep b/drivers/Makefile.dep
index a04ba5f491..28201b5140 100644
--- a/drivers/Makefile.dep
+++ b/drivers/Makefile.dep
@@ -512,9 +512,10 @@ ifneq (,$(filter tja1042,$(USEMODULE)))
FEATURES_REQUIRED += periph_gpio
endif
-ifneq (,$(filter tmp006,$(USEMODULE)))
+ifneq (,$(filter tmp00%,$(USEMODULE)))
FEATURES_REQUIRED += periph_i2c
USEMODULE += xtimer
+ USEMODULE += tmp00x
endif
ifneq (,$(filter tsl2561,$(USEMODULE)))
diff --git a/drivers/Makefile.include b/drivers/Makefile.include
index 6a6f9d5e45..0439b6520a 100644
--- a/drivers/Makefile.include
+++ b/drivers/Makefile.include
@@ -266,8 +266,8 @@ ifneq (,$(filter tcs37727,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/tcs37727/include
endif
-ifneq (,$(filter tmp006,$(USEMODULE)))
- USEMODULE_INCLUDES += $(RIOTBASE)/drivers/tmp006/include
+ifneq (,$(filter tmp00x,$(USEMODULE)))
+ USEMODULE_INCLUDES += $(RIOTBASE)/drivers/tmp00x/include
endif
ifneq (,$(filter tps6274x,$(USEMODULE)))
diff --git a/drivers/include/tmp006.h b/drivers/include/tmp00x.h
similarity index 64%
rename from drivers/include/tmp006.h
rename to drivers/include/tmp00x.h
index 82b4cd4c2f..edc3a06057 100644
--- a/drivers/include/tmp006.h
+++ b/drivers/include/tmp00x.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 PHYTEC Messtechnik GmbH
- * 2017 HAW Hamburg
+ * 2017 - 2019 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
@@ -8,12 +8,12 @@
*/
/**
- * @defgroup drivers_tmp006 TI TMP006 Infrared Thermopile Sensor
+ * @defgroup drivers_tmp00x TMP006/TMP007 Infrared Thermopile Sensor
* @ingroup drivers_sensors
* @ingroup drivers_saul
- * @brief Driver for the Texas Instruments TMP006 sensor.
+ * @brief Driver for the Texas Instruments TMP00X sensor.
*
- * The TI TMP006 (Infrared Thermopile Contactless Temperature Sensor) measures
+ * The TI TMP00X (Infrared Thermopile Contactless Temperature Sensor) measures
* the temperature of an object without need of direct contact with the object.
* After initialization the sensor can be set active for periodic measurements.
*
The conversion duration depends on oversample ratio. The oversample
@@ -64,20 +64,21 @@
* c_{\mathrm{2}} &=& 13.4
* \f}
*
- * The calculation and constants are wrapped from TI TMP006 User's Guide SBOU107.
+ * The calculation and constants are wrapped from TI TMP00X User's Guide SBOU107.
*
* This driver provides @ref drivers_saul capabilities.
* @{
*
* @file
- * @brief Interface definition for the TMP006 sensor driver.
+ * @brief Interface definition for the TMP00X sensor driver.
*
* @author Johann Fischer
* @author Sebastian Meiling
+ * @author Jannes Volkens
*/
-#ifndef TMP006_H
-#define TMP006_H
+#ifndef TMP00X_H
+#define TMP00X_H
#include
#include
@@ -88,18 +89,21 @@ extern "C"
{
#endif
+#define BUS (dev->p.i2c) /**< BUS */
+#define ADDR (dev->p.addr) /**< ADDR */
+
/**
- * @brief TMP006 Default Address
+ * @brief TMP00X Default Address
*/
-#ifndef TMP006_I2C_ADDRESS
-#define TMP006_I2C_ADDRESS (0x41)
+#ifndef TMP00X_I2C_ADDRESS
+#define TMP00X_I2C_ADDRESS (0x40)
#endif
/**
* @brief Default Conversion Time in us
*/
-#ifndef TMP006_CONVERSION_TIME
-#define TMP006_CONVERSION_TIME (1E6)
+#ifndef TMP00X_CONVERSION_TIME
+#define TMP00X_CONVERSION_TIME (1E6)
#endif
/**
@@ -107,11 +111,11 @@ extern "C"
*
* If set to 0, the device will be always-on
* If set to 1, the device will be put in low power mode between measurements.
- * This adds a @c TMP006_CONVERSION_TIME us delay to each measurement call
+ * This adds a @c TMP00X_CONVERSION_TIME us delay to each measurement call
* for bringing the device out of standby.
*/
-#ifndef TMP006_USE_LOW_POWER
-#define TMP006_USE_LOW_POWER (0)
+#ifndef TMP00X_USE_LOW_POWER
+#define TMP00X_USE_LOW_POWER (0)
#endif
/**
@@ -120,37 +124,36 @@ extern "C"
* If set to 0, measurements will be converted to Celsius.
* If set to 1, raw adc readings will be returned.
*/
-#ifndef TMP006_USE_RAW_VALUES
-#define TMP006_USE_RAW_VALUES (0)
+#ifndef TMP00X_USE_RAW_VALUES
+#define TMP00X_USE_RAW_VALUES (0)
#endif
/**
* @name Conversion rate and AVG sampling configuration
* @{
*/
-#define TMP006_CONFIG_CR_AS1 (0x00) /**< Conversion Time 0.25s, AVG Samples: 1 */
-#define TMP006_CONFIG_CR_AS2 (0x01) /**< Conversion Time 0.5s, AVG Samples: 2 */
-#define TMP006_CONFIG_CR_AS4 (0x02) /**< Conversion Time 1s, AVG Samples: 4 */
-#define TMP006_CONFIG_CR_AS8 (0x03) /**< Conversion Time 2s, AVG Samples: 8 */
-#define TMP006_CONFIG_CR_AS16 (0x04) /**< Conversion Time 4s, AVG Samples: 16 */
-#define TMP006_CONFIG_CR_DEF TMP006_CONFIG_CR_AS4 /**< Default for Testing */
-/** @} */
+#define TMP00X_CONFIG_CR_AS1 (0x00) /**< Conversion Time 0.25s, AVG Samples: 1 */
+#define TMP00X_CONFIG_CR_AS2 (0x01) /**< Conversion Time 0.5s, AVG Samples: 2 */
+#define TMP00X_CONFIG_CR_AS4 (0x02) /**< Conversion Time 1s, AVG Samples: 4 */
+#define TMP00X_CONFIG_CR_AS8 (0x03) /**< Conversion Time 2s, AVG Samples: 8 */
+#define TMP00X_CONFIG_CR_AS16 (0x04) /**< Conversion Time 4s, AVG Samples: 16 */
+#define TMP00X_CONFIG_CR_DEF TMP00X_CONFIG_CR_AS4 /**< Default for Testing */
/**
- * @name Constants for TMP006 calibration
+ * @name Constants for TMP00X calibration
* @{
*/
-#ifndef TMP006_CCONST_S0
-#define TMP006_CCONST_S0 (6.4E-14) /**< Calibration Factor */
+#ifndef TMP00X_CCONST_S0
+#define TMP00X_CCONST_S0 (6.4E-14) /**< Calibration Factor */
#endif
-#define TMP006_CCONST_A1 (1.75E-3) /**< Constant \f$a_{\mathrm{1}}\f$ */
-#define TMP006_CCONST_A2 (-1.678E-5) /**< Constant \f$a_{\mathrm{2}}\f$ */
-#define TMP006_CCONST_TREF (298.15) /**< Constant \f$T_{\mathrm{REF}}\f$ */
-#define TMP006_CCONST_B0 (-2.94E-5) /**< Constant \f$b_{\mathrm{0}}\f$ */
-#define TMP006_CCONST_B1 (-5.7E-7) /**< Constant \f$b_{\mathrm{1}}\f$ */
-#define TMP006_CCONST_B2 (4.63E-9) /**< Constant \f$b_{\mathrm{2}}\f$ */
-#define TMP006_CCONST_C2 (13.4) /**< Constant \f$c_{\mathrm{2}}\f$ */
-#define TMP006_CCONST_LSB_SIZE (156.25E-9) /**< Sensor Voltage Register LSB Size */
+#define TMP00X_CCONST_A1 (1.75E-3) /**< Constant \f$a_{\mathrm{1}}\f$ */
+#define TMP00X_CCONST_A2 (-1.678E-5) /**< Constant \f$a_{\mathrm{2}}\f$ */
+#define TMP00X_CCONST_TREF (298.15) /**< Constant \f$T_{\mathrm{REF}}\f$ */
+#define TMP00X_CCONST_B0 (-2.94E-5) /**< Constant \f$b_{\mathrm{0}}\f$ */
+#define TMP00X_CCONST_B1 (-5.7E-7) /**< Constant \f$b_{\mathrm{1}}\f$ */
+#define TMP00X_CCONST_B2 (4.63E-9) /**< Constant \f$b_{\mathrm{2}}\f$ */
+#define TMP00X_CCONST_C2 (13.4) /**< Constant \f$c_{\mathrm{2}}\f$ */
+#define TMP00X_CCONST_LSB_SIZE (156.25E-9) /**< Sensor Voltage Register LSB Size */
/** @} */
/**
@@ -160,48 +163,48 @@ typedef struct {
i2c_t i2c; /**< I2C device, the sensor is connected to */
uint8_t addr; /**< the sensor's slave address on the I2C bus */
uint8_t rate; /**< number of averaged samples */
-} tmp006_params_t;
+} tmp00x_params_t;
/**
- * @brief Device descriptor for TMP006 sensors.
+ * @brief Device descriptor for TMP00X sensors.
*/
typedef struct {
- tmp006_params_t p; /**< Configuration parameters */
-} tmp006_t;
+ tmp00x_params_t p; /**< Configuration parameters */
+} tmp00x_t;
/**
- * @brief TMP006 specific return values
+ * @brief TMP00X specific return values
*/
enum {
- TMP006_OK, /**< Success, no error */
- TMP006_ERROR_BUS, /**< I2C bus error */
- TMP006_ERROR_DEV, /**< internal device error */
- TMP006_ERROR_CONF, /**< invalid device configuration */
- TMP006_ERROR, /**< general error */
+ TMP00X_OK, /**< Success, no error */
+ TMP00X_ERROR_BUS, /**< I2C bus error */
+ TMP00X_ERROR_DEV, /**< internal device error */
+ TMP00X_ERROR_CONF, /**< invalid device configuration */
+ TMP00X_ERROR, /**< general error */
};
/**
- * @brief Initialize the TMP006 sensor driver.
+ * @brief Initialize the TMP00X sensor driver.
*
* @param[out] dev device descriptor of sensor to initialize
* @param[in] params configuration parameters
*
* @return 0 on success
- * @return -TMP006_ERROR_BUS on I2C bus error
- * @return -TMP006_ERROR_DEV if sensor test failed
- * @return -TMP006_ERROR_CONF if sensor configuration failed
+ * @return -TMP00X_ERROR_BUS on I2C bus error
+ * @return -TMP00X_ERROR_DEV if sensor test failed
+ * @return -TMP00X_ERROR_CONF if sensor configuration failed
*/
-int tmp006_init(tmp006_t *dev, const tmp006_params_t *params);
+int tmp00x_init(tmp00x_t *dev, const tmp00x_params_t *params);
/**
- * @brief Reset the TMP006 sensor, afterwards it should be reinitialized.
+ * @brief Reset the TMP00X sensor, afterwards it should be reinitialized.
*
* @param[out] dev device descriptor of sensor
*
* @return 0 on success
* @return -1 on error
*/
-int tmp006_reset(const tmp006_t *dev);
+int tmp00x_reset(const tmp00x_t *dev);
/**
* @brief Set active mode, this enables periodic measurements.
@@ -211,7 +214,7 @@ int tmp006_reset(const tmp006_t *dev);
* @return 0 on success
* @return -1 on error
*/
-int tmp006_set_active(const tmp006_t *dev);
+int tmp00x_set_active(const tmp00x_t *dev);
/**
* @brief Set standby mode.
@@ -221,7 +224,7 @@ int tmp006_set_active(const tmp006_t *dev);
* @return 0 on success
* @return -1 on error
*/
-int tmp006_set_standby(const tmp006_t *dev);
+int tmp00x_set_standby(const tmp00x_t *dev);
/**
* @brief Read sensor's data.
@@ -234,7 +237,7 @@ int tmp006_set_standby(const tmp006_t *dev);
* @return 0 on success
* @return -1 on error
*/
-int tmp006_read(const tmp006_t *dev, int16_t *rawv, int16_t *rawt, uint8_t *drdy);
+int tmp00x_read(const tmp00x_t *dev, int16_t *rawv, int16_t *rawt, uint16_t *drdy);
/**
* @brief Convert raw sensor values to temperature.
@@ -244,7 +247,7 @@ int tmp006_read(const tmp006_t *dev, int16_t *rawv, int16_t *rawt, uint8_t *drdy
* @param[out] tamb converted ambient temperature
* @param[out] tobj converted object temperature
*/
-void tmp006_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj);
+void tmp00x_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj);
/**
* @brief Convenience function to get ambient and object temperatures in [°C]
@@ -255,11 +258,11 @@ void tmp006_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj);
* @param[out] ta converted ambient temperature
* @param[out] to converted object temperature
*/
-int tmp006_read_temperature(const tmp006_t *dev, int16_t *ta, int16_t *to);
+int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to);
#ifdef __cplusplus
}
#endif
-#endif /* TMP006_H */
+#endif /* TMP00X_H */
/** @} */
diff --git a/drivers/tmp006/include/tmp006_params.h b/drivers/tmp006/include/tmp006_params.h
deleted file mode 100644
index b600a7606c..0000000000
--- a/drivers/tmp006/include/tmp006_params.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2017 HAW Hamburg
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License v2.1. See the file LICENSE in the top level
- * directory for more details.
- */
-
-/**
- * @ingroup drivers_tmp006
- *
- * @{
- * @file
- * @brief Default configuration for TMP006 devices
- *
- * @author Sebastian Meiling
- */
-
-#ifndef TMP006_PARAMS_H
-#define TMP006_PARAMS_H
-
-#include "board.h"
-#include "tmp006.h"
-#include "saul_reg.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @name Set default configuration parameters for the TMP006 driver
- * @{
- */
-#ifndef TMP006_PARAM_I2C
-#define TMP006_PARAM_I2C I2C_DEV(0)
-#endif
-#ifndef TMP006_PARAM_ADDR
-#define TMP006_PARAM_ADDR (TMP006_I2C_ADDRESS)
-#endif
-#ifndef TMP006_PARAM_RATE
-#define TMP006_PARAM_RATE TMP006_CONFIG_CR_DEF
-#endif
-
-#ifndef TMP006_PARAMS
-#define TMP006_PARAMS { .i2c = TMP006_PARAM_I2C, \
- .addr = TMP006_PARAM_ADDR, \
- .rate = TMP006_PARAM_RATE }
-#endif
-#ifndef TMP006_SAUL_INFO
-#define TMP006_SAUL_INFO { .name = "tmp006" }
-#endif
-/**@}*/
-
-/**
- * @brief HDC1000 configuration
- */
-static const tmp006_params_t tmp006_params[] =
-{
- TMP006_PARAMS
-};
-
-/**
- * @brief Additional meta information to keep in the SAUL registry
- */
-static const saul_reg_info_t tmp006_saul_info[] =
-{
- TMP006_SAUL_INFO
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* TMP006_PARAMS_H */
-/** @} */
diff --git a/drivers/tmp006/include/tmp006_regs.h b/drivers/tmp006/include/tmp006_regs.h
deleted file mode 100644
index 06a010ab8b..0000000000
--- a/drivers/tmp006/include/tmp006_regs.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2017 HAW Hamburg
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License v2.1. See the file LICENSE in the top level
- * directory for more details.
- */
-
-/**
- * @ingroup drivers_tmp006
- *
- * @{
- * @file
- * @brief Register definitions for TMP006 devices
- *
- * @author Sebastian Meiling
- */
-
-#ifndef TMP006_REGS_H
-#define TMP006_REGS_H
-
-#include "board.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @name Register Map
- * @{
- */
- #define TMP006_REGS_V_OBJECT 0x00 /**< Sensor Voltage Register */
- #define TMP006_REGS_T_AMBIENT 0x01 /**< Ambient Temperature Register */
- #define TMP006_REGS_CONFIG 0x02 /**< Configuration Register */
- #define TMP006_REGS_MANUFACTURER_ID 0xFE /**< Manufacturer ID Register */
- #define TMP006_REGS_DEVICE_ID 0xFF /**< Device ID Register */
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* TMP006_REGS_H */
-/** @} */
diff --git a/drivers/tmp006/tmp006.c b/drivers/tmp006/tmp006.c
deleted file mode 100644
index 350cd2c574..0000000000
--- a/drivers/tmp006/tmp006.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2014 PHYTEC Messtechnik GmbH
- * 2017 HAW Hamburg
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License v2.1. See the file LICENSE in the top level
- * directory for more details.
- *
- */
-
-/**
- * @ingroup drivers_tmp006
- * @{
- *
- * @file
- * @brief Driver for the TI TMP006 Infrared Thermopile Sensor.
- *
- * @author Johann Fischer
- * @author Peter Kietzmann
- * @author Sebastian Meiling
- *
- * @}
- */
-
-#include
-#include
-#include
-#include
-
-#include "log.h"
-#include "periph/i2c.h"
-#include "tmp006.h"
-#include "tmp006_regs.h"
-#if TMP006_USE_LOW_POWER
-#include "xtimer.h"
-#endif
-
-#define ENABLE_DEBUG (0)
-#include "debug.h"
-
-#define TMP006_CONFIG_RST (1 << 15)
-
-#define TMP006_CONFIG_MOD_SHIFT (12U)
-#define TMP006_CONFIG_MOD_MASK (0x7000)
-#define TMP006_CONFIG_MOD(x) (((uint16_t)(((uint16_t)(x)) << TMP006_CONFIG_MOD_SHIFT))\
- & TMP006_CONFIG_MOD_MASK)
-#define TMP006_CONFIG_MOD_CC (0x07)
-#define TMP006_CONFIG_MOD_OFF (0x00)
-
-#define TMP006_CONFIG_CR_SHIFT (9U)
-#define TMP006_CONFIG_CR_MASK (0x0E00)
-#define TMP006_CONFIG_CR(x) (((uint16_t)(((uint16_t)(x)) << TMP006_CONFIG_CR_SHIFT))\
- & TMP006_CONFIG_CR_MASK)
-
-#define TMP006_CONFIG_DRDY_PIN_EN (1 << 8)
-#define TMP006_CONFIG_DRDY (1 << 7)
-
-#define TMP006_MID_VALUE (0x5449) /**< Manufacturer ID */
-#define TMP006_DID_VALUE (0x0067) /**< Device ID */
-
-#define BUS (dev->p.i2c)
-#define ADDR (dev->p.addr)
-
-int tmp006_init(tmp006_t *dev, const tmp006_params_t *params)
-{
- /* check parameters */
- assert(dev && params);
-
- uint8_t reg[2];
- uint16_t tmp;
-
- /* initialize the device descriptor */
- dev->p = *params;
-
- if (dev->p.rate > TMP006_CONFIG_CR_AS16) {
- LOG_ERROR("tmp006_init: invalid conversion rate!\n");
- return -TMP006_ERROR_CONF;
- }
-
- /* test device id */
- i2c_acquire(BUS);
- if (i2c_read_regs(BUS, ADDR, TMP006_REGS_DEVICE_ID, reg, 2, 0) < 0) {
- i2c_release(BUS);
- LOG_ERROR("tmp006_init: error reading device ID!\n");
- return -TMP006_ERROR_BUS;
- }
- tmp = ((uint16_t)reg[0] << 8) | reg[1];
- if (tmp != TMP006_DID_VALUE) {
- return -TMP006_ERROR_DEV;
- }
- /* set conversion rate */
- tmp = TMP006_CONFIG_CR(dev->p.rate);
- reg[0] = (tmp >> 8);
- reg[1] = tmp;
- if (i2c_write_regs(BUS, ADDR, TMP006_REGS_CONFIG, reg, 2, 0) < 0) {
- i2c_release(BUS);
- LOG_ERROR("tmp006_init: error setting conversion rate!\n");
- return -TMP006_ERROR_BUS;
- }
- i2c_release(BUS);
-
- return TMP006_OK;
-}
-
-int tmp006_reset(const tmp006_t *dev)
-{
- uint8_t reg[2];
- uint16_t tmp = TMP006_CONFIG_RST;
- reg[0] = (tmp >> 8);
- reg[1] = tmp;
-
- /* Acquire exclusive access to the bus. */
- i2c_acquire(BUS);
- if (i2c_write_regs(BUS, ADDR, TMP006_REGS_CONFIG, reg, 2, 0) < 0) {
- i2c_release(BUS);
- return -TMP006_ERROR_BUS;
- }
- i2c_release(BUS);
- return TMP006_OK;
-}
-
-int tmp006_set_active(const tmp006_t *dev)
-{
- uint8_t reg[2];
-
- i2c_acquire(BUS);
- if (i2c_read_regs(BUS, ADDR, TMP006_REGS_CONFIG, reg, 2, 0) < 0) {
- i2c_release(BUS);
- return -TMP006_ERROR_BUS;
- }
-
- reg[0] |= (TMP006_CONFIG_MOD(TMP006_CONFIG_MOD_CC) >> 8);
- if (i2c_write_regs(BUS, ADDR, TMP006_REGS_CONFIG, reg, 2, 0) < 0) {
- i2c_release(BUS);
- return -TMP006_ERROR_BUS;
- }
- i2c_release(BUS);
- return TMP006_OK;
-}
-
-int tmp006_set_standby(const tmp006_t *dev)
-{
- uint8_t reg[2];
-
- i2c_acquire(BUS);
- if (i2c_read_regs(BUS, ADDR, TMP006_REGS_CONFIG, reg, 2, 0) < 0) {
- i2c_release(BUS);
- return -TMP006_ERROR_BUS;
- }
-
- reg[0] &= ~(TMP006_CONFIG_MOD(TMP006_CONFIG_MOD_CC) >> 8);
- if (i2c_write_regs(BUS, ADDR, TMP006_REGS_CONFIG, reg, 2, 0) < 0) {
- i2c_release(BUS);
- return -TMP006_ERROR_BUS;
- }
- i2c_release(BUS);
- return TMP006_OK;
-}
-
-int tmp006_read(const tmp006_t *dev, int16_t *rawv, int16_t *rawt, uint8_t *drdy)
-{
- uint8_t reg[2];
-
- i2c_acquire(BUS);
- /* Register bytes are sent MSB first. */
- if (i2c_read_regs(BUS, ADDR, TMP006_REGS_CONFIG, reg, 2, 0) < 0) {
- i2c_release(BUS);
- return -TMP006_ERROR_BUS;
- }
- i2c_release(BUS);
-
- *drdy = reg[1] & (TMP006_CONFIG_DRDY);
- if (!(*drdy)) {
- LOG_DEBUG("tmp006_read: conversion in progress!\n");
- return -TMP006_ERROR;
- }
-
- i2c_acquire(BUS);
- if (i2c_read_regs(BUS, ADDR, TMP006_REGS_V_OBJECT, reg, 2, 0) < 0) {
- i2c_release(BUS);
- return -TMP006_ERROR_BUS;
- }
- i2c_release(BUS);
-
- *rawv = ((uint16_t)reg[0] << 8) | reg[1];
-
- i2c_acquire(BUS);
- if (i2c_read_regs(BUS, ADDR, TMP006_REGS_T_AMBIENT, reg, 2, 0) < 0) {
- i2c_release(BUS);
- return -TMP006_ERROR_BUS;
- }
- i2c_release(BUS);
- *rawt = ((uint16_t)reg[0] << 8) | reg[1];
- return TMP006_OK;
-}
-
-void tmp006_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj)
-{
- /* calculate die temperature */
- *tamb = (double)rawt / 128.0;
- /* die temperature in Kelvin */
- double tdie_k = *tamb + 273.15;
-
- /* calculate sensor voltage */
- double sens_v = (double)rawv * TMP006_CCONST_LSB_SIZE;
-
- double tdiff = tdie_k - TMP006_CCONST_TREF;
- double tdiff_pow2 = pow(tdiff, 2);
-
- double s = TMP006_CCONST_S0 * (1 + TMP006_CCONST_A1 * tdiff
- + TMP006_CCONST_A2 * tdiff_pow2);
-
- double v_os = TMP006_CCONST_B0 + TMP006_CCONST_B1 * tdiff
- + TMP006_CCONST_B2 * tdiff_pow2;
-
- double f_obj = (sens_v - v_os) + TMP006_CCONST_C2 * pow((sens_v - v_os), 2);
-
- double t = pow(pow(tdie_k, 4) + (f_obj / s), 0.25);
- /* calculate object temperature in Celsius */
- *tobj = (t - 273.15);
-}
-
-int tmp006_read_temperature(const tmp006_t *dev, int16_t *ta, int16_t *to)
-{
-
- uint8_t drdy;
-#if (!TMP006_USE_RAW_VALUES)
- int16_t rawtemp, rawvolt;
- float tamb, tobj;
-#endif
-
-#if TMP006_USE_LOW_POWER
- if (tmp006_set_active(dev)) {
- return TMP006_ERROR;
- }
- xtimer_usleep(TMP006_CONVERSION_TIME);
-#endif
-
-#if TMP006_USE_RAW_VALUES
- tmp006_read(dev, to, ta, &drdy);
-
- if (!drdy) {
- return TMP006_ERROR;
- }
-#else
- tmp006_read(dev, &rawvolt, &rawtemp, &drdy);
-
- if (!drdy) {
- return TMP006_ERROR;
- }
- tmp006_convert(rawvolt, rawtemp, &tamb, &tobj);
- *ta = (int16_t)(tamb*100);
- *to = (int16_t)(tobj*100);
-#endif
-
-#if TMP006_USE_LOW_POWER
- if (tmp006_set_standby(dev)) {
- return TMP006_ERROR;
- }
-#endif
-
- return TMP006_OK;
-}
diff --git a/drivers/tmp006/Makefile b/drivers/tmp00x/Makefile
similarity index 100%
rename from drivers/tmp006/Makefile
rename to drivers/tmp00x/Makefile
diff --git a/drivers/tmp00x/include/tmp00x_params.h b/drivers/tmp00x/include/tmp00x_params.h
new file mode 100644
index 0000000000..506a404bc7
--- /dev/null
+++ b/drivers/tmp00x/include/tmp00x_params.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2017 - 2019 HAW Hamburg
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ */
+
+/**
+ * @ingroup drivers_tmp00x
+ *
+ * @{
+ * @file
+ * @brief Default configuration for TMP00X (TMP006 and TMP007) devices
+ *
+ * @author Sebastian Meiling
+ */
+
+#ifndef TMP00X_PARAMS_H
+#define TMP00X_PARAMS_H
+
+#include "board.h"
+#include "tmp00x.h"
+#include "saul_reg.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @name Set default configuration parameters for the TMP00X driver
+ * @ingroup config
+ * @{
+ */
+#ifndef TMP00X_PARAM_I2C
+#define TMP00X_PARAM_I2C I2C_DEV(0)
+#endif
+#ifndef TMP00X_PARAM_ADDR
+#define TMP00X_PARAM_ADDR (TMP00X_I2C_ADDRESS)
+#endif
+#ifndef TMP00X_PARAM_RATE
+#define TMP00X_PARAM_RATE TMP00X_CONFIG_CR_DEF
+#endif
+
+#ifndef TMP00X_PARAMS
+#define TMP00X_PARAMS { .i2c = TMP00X_PARAM_I2C, \
+ .addr = TMP00X_PARAM_ADDR, \
+ .rate = TMP00X_PARAM_RATE }
+#endif
+#ifndef TMP00X_SAUL_INFO
+#define TMP00X_SAUL_INFO { .name = "tmp00x" }
+#endif
+/**@}*/
+
+/**
+ * @brief TMP00X configuration
+ */
+static const tmp00x_params_t tmp00x_params[] =
+{
+ TMP00X_PARAMS
+};
+
+/**
+ * @brief Additional meta information to keep in the SAUL registry
+ */
+static const saul_reg_info_t tmp00x_saul_info[] =
+{
+ TMP00X_SAUL_INFO
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TMP00X_PARAMS_H */
+/** @} */
diff --git a/drivers/tmp00x/include/tmp00x_regs.h b/drivers/tmp00x/include/tmp00x_regs.h
new file mode 100644
index 0000000000..61d1e98aa0
--- /dev/null
+++ b/drivers/tmp00x/include/tmp00x_regs.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2017 - 2019 HAW Hamburg
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ */
+
+/**
+ * @ingroup drivers_tmp00x
+ *
+ * @{
+ * @file
+ * @brief Register definitions for TMP00X (TMP006 and TMP007) devices
+ *
+ * @author Sebastian Meiling
+ * @author Jannes Volkens
+ */
+
+#ifndef TMP00X_REGS_H
+#define TMP00X_REGS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @name TMP00x registers
+ * @{
+ */
+ #define TMP00X_REGS_V_OBJECT 0x00 /**< Sensor Voltage Register */
+ #define TMP00X_REGS_T_AMBIENT 0x01 /**< Ambient Temperature Register */
+ #define TMP00X_REGS_CONFIG 0x02 /**< Configuration Register */
+
+ #define TMP00X_CONFIG_RST (1 << 15) /**< Reset register */
+
+ #define TMP00X_CONFIG_MOD_SHIFT (12U) /**< Mode of operation shift */
+ #define TMP00X_CONFIG_MOD_MASK (0x7000) /**< Mode of operation mask */
+ #define TMP00X_CONFIG_MOD(x) (((uint16_t)(((uint16_t)(x)) \
+ << TMP00X_CONFIG_MOD_SHIFT)) \
+ & TMP00X_CONFIG_MOD_MASK) /**< Mode of operation */
+ #define TMP00X_CONFIG_MOD_CC (0x07) /**< Sensor and ambient continuous conversion */
+ #define TMP00X_CONFIG_MOD_OFF (0x00) /**< Power-down */
+
+ #define TMP00X_CONFIG_CR_SHIFT (9U) /**< ADC conversion rate shift */
+ #define TMP00X_CONFIG_CR_MASK (0x0E00) /**< ADC conversion rate mask */
+ #define TMP00X_CONFIG_CR(x) (((uint16_t)(((uint16_t)(x)) \
+ << TMP00X_CONFIG_CR_SHIFT)) \
+ & TMP00X_CONFIG_CR_MASK) /**< ADC conversion rate */
+
+ #define TMP00X_DRDY_PIN_EN (1 << 8) /**< EN: DRDY enable bit */
+/** @} */
+
+ /**
+ * @ingroup config
+ * @{
+ */
+ #ifdef MODULE_TMP006
+ #define TMP00X_REGS_DEVICE_ID 0xFF /**< Device ID Register */
+ #define TMP00X_REGS_READ_STATUS TMP00X_REGS_CONFIG
+ #define TMP00X_DRDY (1 << 7) /**< DRDY: Data ready bit */
+ #define TMP00X_DID_VALUE (0x0067) /**< Device ID */
+ #elif defined(MODULE_TMP007)
+ #define TMP00X_REGS_DEVICE_ID 0x1F /**< Device ID Register */
+ #define TMP00X_REGS_READ_STATUS TMP007_REGS_STATUS
+ #define TMP00X_DRDY (1 << 14) /**< DRDY: Data ready bit */
+ #define TMP00X_DID_VALUE (0x0078) /**< Device ID */
+ #else
+ #error "TMP00X DRIVER not selected or supported"
+ #endif
+/** @} */
+
+ /**
+ * @name TMP006 registers
+ * @{
+ */
+ #define TMP006_REGS_MANUFACTURER_ID 0xFE /**< Manufacturer ID Register */
+/** @} */
+
+ /**
+ * @name TMP007 registers
+ * @{
+ */
+ #define TMP007_REGS_OBJ_TEMP 0x03 /**< Object temperature result register */
+ #define TMP007_REGS_STATUS 0x04 /**< Status Register */
+ #define TMP007_REGS_STAT_MASK_EN 0x05 /**< Mask and enable register*/
+ #define TMP007_REGS_OBJ_HIGH_LIMIT_TEMP 0x06 /**< Object temperature high limit register */
+ #define TMP007_REGS_OBJ_LOW_LIMIT_TEMP 0x07 /**< Object temperature low limit register */
+ #define TMP007_REGS_LOCAL_HIGH_LIMIT_TEMP 0x08 /**< TDIE temperature high limit register */
+ #define TMP007_REGS_LOCAL_LOW_LIMIT_TEMP 0x09 /**< TDIE temperature low limit register */
+ #define TMP007_REGS_S0_COEFFCIENT 0x0A /**< S0 coefficient register */
+ #define TMP007_REGS_A0_COEFFCIENT 0x0B /**< A0 coefficient register */
+ #define TMP007_REGS_A1_COEFFCIENT 0x0C /**< A1 coefficient register */
+ #define TMP007_REGS_B0_COEFFCIENT 0x0D /**< B0 coefficient register */
+ #define TMP007_REGS_B1_COEFFCIENT 0x0E /**< B1 coefficient register */
+ #define TMP007_REGS_B2_COEFFCIENT 0x0F /**< B2 coefficient register */
+ #define TMP007_REGS_C_COEFFCIENT 0x10 /**< C coefficient register */
+ #define TMP007_REGS_TC0_COEFFCIENT 0x11 /**< TC0 coefficient register */
+ #define TMP007_REGS_TC1_COEFFCIENT 0x12 /**< TC1 coefficient register */
+ #define TMP007_REGS_MEM_ACCES 0x2A /**< Memory access register */
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TMP00X_REGS_H */
+/** @} */
diff --git a/drivers/tmp00x/tmp00x.c b/drivers/tmp00x/tmp00x.c
new file mode 100644
index 0000000000..6872f9e7af
--- /dev/null
+++ b/drivers/tmp00x/tmp00x.c
@@ -0,0 +1,241 @@
+/*
+ * Copyright (C) 2014 PHYTEC Messtechnik GmbH
+ * 2017 - 2019 HAW Hamburg
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ *
+ */
+
+/**
+ * @ingroup drivers_tmp00x
+ * @{
+ *
+ * @file
+ * @brief Driver for the TI TMP00X (TMP006 and TMP007) Infrared Thermopile Sensor.
+ *
+ * @author Johann Fischer
+ * @author Peter Kietzmann
+ * @author Sebastian Meiling
+ * @author Jannes Volkens
+ *
+ * @}
+ */
+
+#include
+#include
+#include
+#include
+
+#include "log.h"
+#include "periph/i2c.h"
+#include "tmp00x.h"
+#include "tmp00x_regs.h"
+#if TMP00X_USE_LOW_POWER
+#include "xtimer.h"
+#endif
+#include "byteorder.h"
+
+#define ENABLE_DEBUG (0)
+#include "debug.h"
+
+int tmp00x_init(tmp00x_t *dev, const tmp00x_params_t *params)
+{
+ /* check parameters */
+ assert(dev && params);
+
+ uint16_t reg;
+
+ /* initialize the device descriptor */
+ dev->p = *params;
+
+ if (dev->p.rate > TMP00X_CONFIG_CR_AS16) {
+ LOG_ERROR("tmp00x_init: invalid conversion rate!\n");
+ return -TMP00X_ERROR_CONF;
+ }
+
+ /* test device id */
+ i2c_acquire(BUS);
+ if (i2c_read_regs(BUS, ADDR, TMP00X_REGS_DEVICE_ID, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ LOG_ERROR("tmp00x_init: error reading device ID!\n");
+ return -TMP00X_ERROR_BUS;
+ }
+
+ reg = htons(reg);
+ if (reg != TMP00X_DID_VALUE) {
+ return -TMP00X_ERROR_DEV;
+ }
+
+ /* set conversion rate */
+ reg = TMP00X_CONFIG_CR(dev->p.rate);
+ if (i2c_write_regs(BUS, ADDR, TMP00X_REGS_CONFIG, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ LOG_ERROR("tmp00x_init: error setting conversion rate!\n");
+ return -TMP00X_ERROR_BUS;
+ }
+ i2c_release(BUS);
+
+ return TMP00X_OK;
+}
+
+int tmp00x_reset(const tmp00x_t *dev)
+{
+ uint16_t reg = TMP00X_CONFIG_RST;
+ reg = htons(reg);
+
+ /* Acquire exclusive access to the bus. */
+ i2c_acquire(BUS);
+ if (i2c_write_regs(BUS, ADDR, TMP00X_REGS_CONFIG, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ return -TMP00X_ERROR_BUS;
+ }
+ i2c_release(BUS);
+ return TMP00X_OK;
+}
+
+int tmp00x_set_active(const tmp00x_t *dev)
+{
+ uint16_t reg;
+
+ i2c_acquire(BUS);
+ if (i2c_read_regs(BUS, ADDR, TMP00X_REGS_CONFIG, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ return -TMP00X_ERROR_BUS;
+ }
+
+ reg |= (TMP00X_CONFIG_MOD(TMP00X_CONFIG_MOD_CC) >> 8);
+ if (i2c_write_regs(BUS, ADDR, TMP00X_REGS_CONFIG, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ return -TMP00X_ERROR_BUS;
+ }
+
+ i2c_release(BUS);
+ return TMP00X_OK;
+}
+
+int tmp00x_set_standby(const tmp00x_t *dev)
+{
+ uint16_t reg;
+
+ i2c_acquire(BUS);
+ if (i2c_read_regs(BUS, ADDR, TMP00X_REGS_CONFIG, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ return -TMP00X_ERROR_BUS;
+ }
+
+ reg &= ~(TMP00X_CONFIG_MOD(TMP00X_CONFIG_MOD_CC) >> 8);
+ if (i2c_write_regs(BUS, ADDR, TMP00X_REGS_CONFIG, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ return -TMP00X_ERROR_BUS;
+ }
+ i2c_release(BUS);
+ return TMP00X_OK;
+}
+
+int tmp00x_read(const tmp00x_t *dev, int16_t *rawv, int16_t *rawt, uint16_t *drdy)
+{
+ uint16_t reg;
+
+ i2c_acquire(BUS);
+ /* Register bytes are sent MSB first. */
+ if (i2c_read_regs(BUS, ADDR, TMP00X_REGS_READ_STATUS, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ return -TMP00X_ERROR_BUS;
+ }
+ i2c_release(BUS);
+
+ *drdy = htons(reg) & (TMP00X_DRDY);
+
+ if (!(*drdy)) {
+ LOG_DEBUG("tmp00x_read: conversion in progress!\n");
+ return -TMP00X_ERROR;
+ }
+
+ i2c_acquire(BUS);
+ if (i2c_read_regs(BUS, ADDR, TMP00X_REGS_V_OBJECT, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ return -TMP00X_ERROR_BUS;
+ }
+ i2c_release(BUS);
+
+ *rawv = htons(reg);
+
+ i2c_acquire(BUS);
+ if (i2c_read_regs(BUS, ADDR, TMP00X_REGS_T_AMBIENT, ®, 2, 0) < 0) {
+ i2c_release(BUS);
+ return -TMP00X_ERROR_BUS;
+ }
+ i2c_release(BUS);
+ *rawt = htons(reg);
+ return TMP00X_OK;
+}
+
+void tmp00x_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj)
+{
+ /* calculate die temperature */
+ *tamb = (float)rawt / 128.0;
+ /* die temperature in Kelvin */
+ float tdie_k = *tamb + 273.15;
+
+ /* calculate sensor voltage */
+ float sens_v = (float)rawv * TMP00X_CCONST_LSB_SIZE;
+
+ float tdiff = tdie_k - TMP00X_CCONST_TREF;
+ float tdiff_pow2 = pow(tdiff, 2);
+
+ float s = TMP00X_CCONST_S0 * (1 + TMP00X_CCONST_A1 * tdiff
+ + TMP00X_CCONST_A2 * tdiff_pow2);
+
+ float v_os = TMP00X_CCONST_B0 + TMP00X_CCONST_B1 * tdiff
+ + TMP00X_CCONST_B2 * tdiff_pow2;
+
+ float f_obj = (sens_v - v_os) + TMP00X_CCONST_C2 * pow((sens_v - v_os), 2);
+
+ float t = pow(pow(tdie_k, 4) + (f_obj / s), 0.25);
+ /* calculate object temperature in Celsius */
+ *tobj = (t - 273.15);
+}
+
+int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to)
+{
+
+ uint16_t drdy;
+#if (!TMP00X_USE_RAW_VALUES)
+ int16_t rawtemp, rawvolt;
+ float tamb, tobj;
+#endif
+
+#if TMP00X_USE_LOW_POWER
+ if (tmp00x_set_active(dev)) {
+ return TMP00X_ERROR;
+ }
+ xtimer_usleep(TMP00X_CONVERSION_TIME);
+#endif
+
+#if TMP00X_USE_RAW_VALUES
+ tmp00x_read(dev, to, ta, &drdy);
+
+ if (!drdy) {
+ return TMP00X_ERROR;
+ }
+#else
+ tmp00x_read(dev, &rawvolt, &rawtemp, &drdy);
+
+ if (!drdy) {
+ return TMP00X_ERROR;
+ }
+ tmp00x_convert(rawvolt, rawtemp, &tamb, &tobj);
+ *ta = (int16_t)(tamb*100);
+ *to = (int16_t)(tobj*100);
+#endif
+
+#if TMP00X_USE_LOW_POWER
+ if (tmp00x_set_standby(dev)) {
+ return TMP00X_ERROR;
+ }
+#endif
+
+ return TMP00X_OK;
+}
diff --git a/drivers/tmp006/tmp006_saul.c b/drivers/tmp00x/tmp00x_saul.c
similarity index 62%
rename from drivers/tmp006/tmp006_saul.c
rename to drivers/tmp00x/tmp00x_saul.c
index 03342b0392..ddf6bf4e82 100644
--- a/drivers/tmp006/tmp006_saul.c
+++ b/drivers/tmp00x/tmp00x_saul.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 HAW Hamburg
+ * Copyright (C) 2017 - 2019 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
@@ -7,11 +7,11 @@
*/
/**
- * @ingroup drivers_tmp006
+ * @ingroup drivers_tmp00x
* @{
*
* @file
- * @brief TMP006 adaption to the RIOT actuator/sensor interface
+ * @brief TMP00X (TMP006 and TMP007) adaption to the RIOT actuator/sensor interface
*
* @author Sebastian Meiling
*
@@ -21,16 +21,16 @@
#include
#include "saul.h"
-#include "tmp006.h"
+#include "tmp00x.h"
static int read_temp(const void *dev, phydat_t *res)
{
- if (tmp006_read_temperature((const tmp006_t *)dev, &res->val[0],
- &res->val[1]) != TMP006_OK) {
+ if (tmp00x_read_temperature((const tmp00x_t *)dev, &res->val[0],
+ &res->val[1]) != TMP00X_OK) {
return -ECANCELED;
}
res->val[2] = 0;
-#if TMP006_USE_RAW_VALUES
+#if TMP00X_USE_RAW_VALUES
res->unit = UNIT_NONE;
res->scale = 0;
#else
@@ -40,7 +40,7 @@ static int read_temp(const void *dev, phydat_t *res)
return 2;
}
-const saul_driver_t tmp006_saul_driver = {
+const saul_driver_t tmp00x_saul_driver = {
.read = read_temp,
.write = saul_notsup,
.type = SAUL_SENSE_OBJTEMP,
diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk
index 05d1eeff88..f9e0df7ce3 100644
--- a/makefiles/pseudomodules.inc.mk
+++ b/makefiles/pseudomodules.inc.mk
@@ -123,6 +123,10 @@ PSEUDOMODULES += si7013
PSEUDOMODULES += si7020
PSEUDOMODULES += si7021
+#include variants of tmp00x drivers as pseudo modules
+PSEUDOMODULES += tmp006
+PSEUDOMODULES += tmp007
+
# include variants of RN2XX3 drivers as pseudo modules
PSEUDOMODULES += rn2483
PSEUDOMODULES += rn2903
diff --git a/sys/auto_init/auto_init.c b/sys/auto_init/auto_init.c
index 9585445687..b31a9dd027 100644
--- a/sys/auto_init/auto_init.c
+++ b/sys/auto_init/auto_init.c
@@ -504,8 +504,8 @@ void auto_init(void)
auto_init_tcs37727();
#endif
#ifdef MODULE_TMP006
- extern void auto_init_tmp006(void);
- auto_init_tmp006();
+ extern void auto_init_tmp00x(void);
+ auto_init_tmp00x();
#endif
#ifdef MODULE_TSL2561
extern void auto_init_tsl2561(void);
diff --git a/sys/auto_init/saul/auto_init_tmp006.c b/sys/auto_init/saul/auto_init_tmp006.c
deleted file mode 100644
index 61261e8252..0000000000
--- a/sys/auto_init/saul/auto_init_tmp006.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2017 HAW Hamburg
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License v2.1. See the file LICENSE in the top level
- * directory for more details.
- *
- */
-
-/**
- * @ingroup sys_auto_init_saul
- * @{
- *
- * @file
- * @brief Auto initialization of TMP006 temperature sensor
- *
- * @author Sebastian Meiling
- *
- * @}
- */
-
-#ifdef MODULE_TMP006
-
-#include "assert.h"
-#include "log.h"
-#include "saul_reg.h"
-
-#include "tmp006.h"
-#include "tmp006_params.h"
-
-/**
- * @brief Define the number of configured sensors
- */
-#define TMP006_NUM ARRAY_SIZE(tmp006_params)
-
-/**
- * @brief Allocate memory for the device descriptors
- */
-static tmp006_t tmp006_devs[TMP006_NUM];
-
-/**
- * @brief Memory for the SAUL registry entries
- */
-static saul_reg_t saul_entries[TMP006_NUM];
-
-/**
- * @brief Define the number of saul info
- */
-#define TMP006_INFO_NUM ARRAY_SIZE(tmp006_saul_info)
-
-/**
- * @brief Reference the driver struct
- */
-extern const saul_driver_t tmp006_saul_driver;
-
-void auto_init_tmp006(void)
-{
- assert(TMP006_NUM == TMP006_INFO_NUM);
-
- for (unsigned i = 0; i < TMP006_NUM; i++) {
- LOG_DEBUG("[auto_init_saul] initializing tmp006 #%u\n", i);
-
- if (tmp006_init(&tmp006_devs[i], &tmp006_params[i]) != TMP006_OK) {
- LOG_ERROR("[auto_init_saul] error initializing tmp006 #%u\n", i);
- continue;
- }
- if (tmp006_set_active(&tmp006_devs[i]) != TMP006_OK) {
- LOG_ERROR("[auto_init_saul] error set active tmp006 #%u\n", i);
- continue;
- }
-#if TMP006_USE_LOW_POWER
- if (tmp006_set_standby(&tmp006_devs[i]) != TMP006_OK) {
- LOG_ERROR("[auto_init_saul] error set standby tmp006 #%u\n", i);
- continue;
- }
-#endif
- saul_entries[i].dev = &(tmp006_devs[i]);
- saul_entries[i].name = tmp006_saul_info[i].name;
- saul_entries[i].driver = &tmp006_saul_driver;
- saul_reg_add(&(saul_entries[i]));
- }
-}
-
-#else
-typedef int dont_be_pedantic;
-#endif /* MODULE_TMP006 */
diff --git a/sys/auto_init/saul/auto_init_tmp00x.c b/sys/auto_init/saul/auto_init_tmp00x.c
new file mode 100644
index 0000000000..780364fd51
--- /dev/null
+++ b/sys/auto_init/saul/auto_init_tmp00x.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2017 HAW Hamburg
+ * 2019 HAW Hamburg
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ *
+ */
+
+/**
+ * @ingroup sys_auto_init_saul
+ * @{
+ *
+ * @file
+ * @brief Auto initialization of TMP00X temperature sensor
+ *
+ * @author Sebastian Meiling
+ *
+ * @}
+ */
+
+#ifdef MODULE_TMP00X
+
+#include "assert.h"
+#include "log.h"
+#include "saul_reg.h"
+
+#include "tmp00x.h"
+#include "tmp00x_params.h"
+
+/**
+ * @brief Define the number of configured sensors
+ */
+#define TMP00X_NUM ARRAY_SIZE(tmp00x_params)
+
+/**
+ * @brief Allocate memory for the device descriptors
+ */
+static tmp00x_t tmp00x_devs[TMP00X_NUM];
+
+/**
+ * @brief Memory for the SAUL registry entries
+ */
+static saul_reg_t saul_entries[TMP00X_NUM];
+
+/**
+ * @brief Define the number of saul info
+ */
+#define TMP00X_INFO_NUM ARRAY_SIZE(tmp00x_saul_info)
+
+/**
+ * @brief Reference the driver struct
+ */
+extern const saul_driver_t tmp00x_saul_driver;
+
+void auto_init_tmp00x(void)
+{
+ assert(TMP00X_NUM == TMP00X_INFO_NUM);
+
+ for (unsigned i = 0; i < TMP00X_NUM; i++) {
+ LOG_DEBUG("[auto_init_saul] initializing tmp00x #%u\n", i);
+
+ if (tmp00x_init(&tmp00x_devs[i], &tmp00x_params[i]) != TMP00X_OK) {
+ LOG_ERROR("[auto_init_saul] error initializing tmp00x #%u\n", i);
+ continue;
+ }
+ if (tmp00x_set_active(&tmp00x_devs[i]) != TMP00X_OK) {
+ LOG_ERROR("[auto_init_saul] error set active tmp00x #%u\n", i);
+ continue;
+ }
+#if TMP00X_USE_LOW_POWER
+ if (tmp00x_set_standby(&tmp00x_devs[i]) != TMP00X_OK) {
+ LOG_ERROR("[auto_init_saul] error set standby tmp00x #%u\n", i);
+ continue;
+ }
+#endif
+ saul_entries[i].dev = &(tmp00x_devs[i]);
+ saul_entries[i].name = tmp00x_saul_info[i].name;
+ saul_entries[i].driver = &tmp00x_saul_driver;
+ saul_reg_add(&(saul_entries[i]));
+ }
+}
+
+#else
+typedef int dont_be_pedantic;
+#endif /* MODULE_TMP00X */
diff --git a/tests/driver_tmp006/README.md b/tests/driver_tmp006/README.md
deleted file mode 100644
index 061dcdcb7b..0000000000
--- a/tests/driver_tmp006/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# About
-This is a manual test application for the TMP006 driver.
-
-# Usage
-This test application will initialize the TMP006 sensor with the following parameters:
- - conversion rate 1 per second
-
-After initialization, the sensor reads the temperature values every 1s
-and prints them to STDOUT.
diff --git a/tests/driver_tmp006/Makefile b/tests/driver_tmp00x/Makefile
similarity index 69%
rename from tests/driver_tmp006/Makefile
rename to tests/driver_tmp00x/Makefile
index 62d9f950f6..c1863d62f6 100644
--- a/tests/driver_tmp006/Makefile
+++ b/tests/driver_tmp00x/Makefile
@@ -1,6 +1,8 @@
include ../Makefile.tests_common
-USEMODULE += tmp006
+DRIVER ?= tmp006
+
+USEMODULE += $(DRIVER)
USEMODULE += xtimer
include $(RIOTBASE)/Makefile.include
diff --git a/tests/driver_tmp00x/README.md b/tests/driver_tmp00x/README.md
new file mode 100644
index 0000000000..7b6d6e96ec
--- /dev/null
+++ b/tests/driver_tmp00x/README.md
@@ -0,0 +1,9 @@
+# About
+This is a manual test application for the TMP006 and TMP007 driver.
+
+# Usage
+This test application will initialize the TMP006 or the TMP007 sensor with the following parameters:
+ - conversion rate 1 per second
+
+After initialization, the sensor reads the temperature values every 1s
+and prints them to STDOUT.
diff --git a/tests/driver_tmp006/main.c b/tests/driver_tmp00x/main.c
similarity index 62%
rename from tests/driver_tmp006/main.c
rename to tests/driver_tmp00x/main.c
index 7b2ed5096a..5135c6c167 100644
--- a/tests/driver_tmp006/main.c
+++ b/tests/driver_tmp00x/main.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
* Copyright (C) 2014 PHYTEC Messtechnik GmbH
- * 2017 HAW Hamburg
+ * 2017 - 2019 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
@@ -13,7 +13,7 @@
* @{
*
* @file
- * @brief Test application for the TMP006 sensor driver.
+ * @brief Test application for the TMP00X (TMP006 and TMP007) sensor driver.
*
* @author Hauke Petersen
* @author Johann Fischer
@@ -25,42 +25,42 @@
#include
#include "xtimer.h"
-#include "tmp006.h"
-#include "tmp006_params.h"
+#include "tmp00x.h"
+#include "tmp00x_params.h"
int main(void)
{
- tmp006_t dev;
+ tmp00x_t dev;
int16_t rawtemp, rawvolt;
float tamb, tobj;
- uint8_t drdy;
+ uint16_t drdy;
- puts("TMP006 infrared thermopile sensor driver test application\n");
- printf("Initializing TMP006 sensor at I2C_%i ... ", tmp006_params[0].i2c);
- if (tmp006_init(&dev, &tmp006_params[0]) != TMP006_OK) {
+ puts("TMP00X infrared thermopile sensor driver test application\n");
+ printf("Initializing TMP00X sensor at I2C_%i ... ", tmp00x_params[0].i2c);
+ if (tmp00x_init(&dev, &tmp00x_params[0]) != TMP00X_OK) {
puts("init device [ERROR]");
return -1;
}
- if (tmp006_set_active(&dev)) {
+ if (tmp00x_set_active(&dev)) {
puts("start measurement [ERROR]");
return -1;
}
- xtimer_usleep(TMP006_CONVERSION_TIME);
+ xtimer_usleep(TMP00X_CONVERSION_TIME);
puts("[SUCCESS]\n");
while (1) {
- tmp006_read(&dev, &rawvolt, &rawtemp, &drdy);
+ tmp00x_read(&dev, &rawvolt, &rawtemp, &drdy);
if (drdy) {
printf("Raw data T: %5d V: %5d\n", rawtemp, rawvolt);
- tmp006_convert(rawvolt, rawtemp, &tamb, &tobj);
+ tmp00x_convert(rawvolt, rawtemp, &tamb, &tobj);
printf("Data Tabm: %d Tobj: %d\n", (int)(tamb*100), (int)(tobj*100));
}
else {
puts("conversion in progress ... ");
}
- xtimer_usleep(TMP006_CONVERSION_TIME);
+ xtimer_usleep(TMP00X_CONVERSION_TIME);
}
return 0;