2017-06-09 23:03:54 +02:00
|
|
|
/*
|
2019-08-16 14:18:12 +02:00
|
|
|
* Copyright (C) 2017 - 2019 HAW Hamburg
|
2017-06-09 23:03:54 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2019-08-16 14:18:12 +02:00
|
|
|
* @ingroup drivers_tmp00x
|
2017-06-09 23:03:54 +02:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
2019-08-16 14:18:12 +02:00
|
|
|
* @brief TMP00X (TMP006 and TMP007) adaption to the RIOT actuator/sensor interface
|
2017-06-09 23:03:54 +02:00
|
|
|
*
|
|
|
|
* @author Sebastian Meiling <s@mlng.net>
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "saul.h"
|
2019-08-16 14:18:12 +02:00
|
|
|
#include "tmp00x.h"
|
2020-04-30 11:31:30 +02:00
|
|
|
#include "kernel_defines.h"
|
2017-06-09 23:03:54 +02:00
|
|
|
|
2017-06-26 16:00:34 +02:00
|
|
|
static int read_temp(const void *dev, phydat_t *res)
|
2017-06-09 23:03:54 +02:00
|
|
|
{
|
2019-08-16 14:18:12 +02:00
|
|
|
if (tmp00x_read_temperature((const tmp00x_t *)dev, &res->val[0],
|
|
|
|
&res->val[1]) != TMP00X_OK) {
|
2017-06-09 23:03:54 +02:00
|
|
|
return -ECANCELED;
|
|
|
|
}
|
|
|
|
res->val[2] = 0;
|
2020-04-30 11:31:30 +02:00
|
|
|
if (IS_ACTIVE(CONFIG_TMP00X_USE_RAW_VALUES)) {
|
|
|
|
res->unit = UNIT_NONE;
|
|
|
|
res->scale = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
res->unit = UNIT_TEMP_C;
|
|
|
|
res->scale = -2;
|
|
|
|
}
|
2017-06-09 23:03:54 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2019-08-16 14:18:12 +02:00
|
|
|
const saul_driver_t tmp00x_saul_driver = {
|
2017-06-09 23:03:54 +02:00
|
|
|
.read = read_temp,
|
2022-05-02 21:31:03 +02:00
|
|
|
.write = saul_write_notsup,
|
2017-11-06 09:04:50 +01:00
|
|
|
.type = SAUL_SENSE_OBJTEMP,
|
2017-06-09 23:03:54 +02:00
|
|
|
};
|