mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
90c4ef04ef
Rename TMP006 to TMP00x Add TMP007 sensor support to TMP00X Change uint8_t reg to uint16_t Add to doxygen documentation group Expose compile time configurations Move defines from .c to .h Change double to float, because double is not needed Add TMP007 register information
88 lines
2.1 KiB
C
88 lines
2.1 KiB
C
/*
|
|
* 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 <s@mlng.net>
|
|
*
|
|
* @}
|
|
*/
|
|
|
|
#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 */
|