1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/shtcx: integration of shtc3 sensor

This commit is contained in:
Vic 2022-02-25 17:17:11 +01:00
parent 07531cdecd
commit e18557f9c4
11 changed files with 191 additions and 139 deletions

View File

@ -128,7 +128,7 @@ rsource "seesaw_soil/Kconfig"
rsource "sht1x/Kconfig"
rsource "sht2x/Kconfig"
rsource "sht3x/Kconfig"
rsource "shtc1/Kconfig"
rsource "shtcx/Kconfig"
rsource "si70xx/Kconfig"
rsource "si114x/Kconfig"
rsource "si1133/Kconfig"

View File

@ -159,6 +159,10 @@ ifneq (,$(filter sht1%,$(USEMODULE)))
USEMODULE += sht1x
endif
ifneq (,$(filter shtc%,$(USEMODULE)))
USEMODULE += shtcx
endif
ifneq (,$(filter si114%,$(USEMODULE)))
USEMODULE += si114x
endif

View File

@ -7,20 +7,22 @@
*/
/**
* @defgroup drivers_shtc1 SHTC1 Temperature and humidity sensor
* @defgroup drivers_shtcx SHTCX Temperature and humidity sensor
* @ingroup drivers_sensors
* @ingroup drivers_saul
* @brief Driver for the Sensirion SHTC1 sensor.
* @brief Driver for the Sensirion SHTCX sensor.
*
* @{
*
* @file
* @brief Device driver interface for the SHTC1 Temperature and humidity sensor
* @brief Device driver interface for the SHTCX Temperature and humidity sensor
*
* @author Steffen Robertz <steffen.robertz@rwth-aachen.de>
* @author Josua Arndt <jarndt@ias.rwth-aachen.de>
*/
#ifndef SHTC1_H
#define SHTC1_H
#ifndef SHTCX_H
#define SHTCX_H
#include <stdint.h>
#include "saul.h"
@ -32,11 +34,11 @@ extern "C" {
#endif
/**
* @brief SHTC1 Default Address
* @brief SHTCX Default Address
*
*/
#ifndef SHTC1_I2C_ADDRESS
#define SHTC1_I2C_ADDRESS (0x70)
#ifndef SHTCX_I2C_ADDRESS
#define SHTCX_I2C_ADDRESS (0x70)
#endif
/**
@ -46,36 +48,36 @@ extern "C" {
typedef struct {
i2c_t i2c_dev; /**< I2C bus descriptor. */
uint8_t i2c_addr; /**< I2C address of the sensor. */
} shtc1_params_t;
} shtcx_params_t;
/** @} */
/**
* @brief device descriptor for the SHTC1
* @brief device descriptor for the SHTCX
* @{
*/
typedef struct {
shtc1_params_t params; /**< Parameters struct with all settings set. */
} shtc1_t;
shtcx_params_t params; /**< Parameters struct with all settings set. */
} shtcx_t;
/** @} */
enum {
SHTC1_OK, /**< Success, no error */
SHTC1_ERROR_BUS, /**< I2C bus error */
SHTC1_ERROR_CRC, /**< CRC error */
SHTC1_ERROR /**< General error */
SHTCX_OK, /**< Success, no error */
SHTCX_ERROR_BUS, /**< I2C bus error */
SHTCX_ERROR_CRC, /**< CRC error */
SHTCX_ERROR /**< General error */
};
/**
* @brief Initializes the sensor and I2C.
*
* @param[in] dev I2C device descriptor.
* @param[in] params SHTC1 parameters to be used.
* @param[in] params SHTCX parameters to be used.
*
* @return SHTC1_OK on a working initialization.
* @return SHTC1_ERROR_BUS Reading I2C failed.
* @return SHTC1_ERROR_CRC Wrong ID.
* @return SHTCX_OK on a working initialization.
* @return SHTCX_ERROR_BUS Reading I2C failed.
* @return SHTCX_ERROR_CRC Wrong ID.
*/
int8_t shtc1_init(shtc1_t* const dev, const shtc1_params_t* params);
int8_t shtcx_init(shtcx_t* const dev, const shtcx_params_t* params);
/**
* @brief Reads all register values from the device.
@ -85,24 +87,25 @@ int8_t shtc1_init(shtc1_t* const dev, const shtc1_params_t* params);
* @param[in] rel_humidity Humidity in centi %.
* @param[in] temperature Temperature in centi °C.
*
* @return SHTC1_OK if a measurement completed.
* @return SHTC1_ERROR_BUS reading I2C failed.
* @return SHTC1_ERROR_CRC on checksum error.
* @return SHTCX_OK if a measurement completed.
* @return SHTCX_ERROR_BUS reading I2C failed.
* @return SHTCX_ERROR_CRC on checksum error.
*/
int8_t shtc1_read(const shtc1_t *dev, uint16_t *rel_humidity, int16_t *temperature);
int8_t shtcx_read(const shtcx_t *dev, uint16_t *rel_humidity, int16_t *temperature);
/**
* @brief Reads the ID and saves it in the device descriptor
*
* @details When working correctly ID should equal xxxx'xxxx'xx00'0111 where x is unspecified.
* @details When working correctly ID should equal
* xxxx'xxxx'xx00'0111 where x is unspecified.
*
* @param[in] dev The I2C device descriptor.
* @param[in] id ID of the device.
*
* @return SHTC1_OK on everything done.
* @return SHTC1_ERROR_BUS on error.
* @return SHTCX_OK on everything done.
* @return SHTCX_ERROR_BUS on error.
*/
int8_t shtc1_id(const shtc1_t *dev, uint16_t *id);
int8_t shtcx_id(const shtcx_t *dev, uint16_t *id);
/**
* @brief Resets sensor
@ -111,14 +114,14 @@ int8_t shtc1_id(const shtc1_t *dev, uint16_t *id);
*
* @param[in] dev The I2C device descriptor.
*
* @return SHTC1_OK on everything done.
* @return SHTC1_ERROR_BUS on error.
* @return SHTCX_OK on everything done.
* @return SHTCX_ERROR_BUS on error.
*/
int8_t shtc1_reset(const shtc1_t *dev);
int8_t shtcx_reset(const shtcx_t *dev);
#ifdef __cplusplus
}
#endif
#endif /* SHTC1_H */
#endif /* SHTCX_H */
/** @} */

View File

@ -12,7 +12,7 @@
* @{
*
* @file
* @brief Auto initialization of shtc1 Digital Humidity Sensor
* @brief Auto initialization of shtcx Digital Humidity Sensor
*
* @author Michel Gerlach <michel.gerlach@haw-hamburg.de>
*
@ -23,55 +23,55 @@
#include "log.h"
#include "saul_reg.h"
#include "shtc1.h"
#include "shtc1_params.h"
#include "shtcx.h"
#include "shtcx_params.h"
/**
* @brief Define the number of configured sensors
*/
#define SHTC1_NUM ARRAY_SIZE(shtc1_params)
#define SHTCX_NUM ARRAY_SIZE(shtcx_params)
/**
* @brief Allocate memory for the device descriptors
*/
static shtc1_t shtc1_devs[SHTC1_NUM];
static shtcx_t shtcx_devs[SHTCX_NUM];
/**
* @brief Memory for the SAUL registry entries
*/
static saul_reg_t saul_entries[SHTC1_NUM * 2];
static saul_reg_t saul_entries[SHTCX_NUM * 2];
/**
* @brief Define the number of saul info
*/
#define SHTC1_INFO_NUM ARRAY_SIZE(shtc1_saul_info)
#define SHTCX_INFO_NUM ARRAY_SIZE(shtcx_saul_info)
/**
* @brief Reference the driver struct
*/
extern const saul_driver_t shtc1_temperature_saul_driver;
extern const saul_driver_t shtc1_relative_humidity_saul_driver;
extern const saul_driver_t shtcx_temperature_saul_driver;
extern const saul_driver_t shtcx_relative_humidity_saul_driver;
void auto_init_shtc1(void)
void auto_init_shtcx(void)
{
assert(SHTC1_NUM == SHTC1_INFO_NUM);
assert(SHTCX_NUM == SHTCX_INFO_NUM);
for (unsigned i = 0; i < SHTC1_NUM; i++) {
LOG_DEBUG("[auto_init_saul] initializing shtc1 #%u\n", i);
for (unsigned i = 0; i < SHTCX_NUM; i++) {
LOG_DEBUG("[auto_init_saul] initializing shtcx #%u\n", i);
if (shtc1_init(&shtc1_devs[i], &shtc1_params[i]) != SHTC1_OK) {
LOG_ERROR("[auto_init_saul] error initializing shtc1 #%u\n", i);
if (shtcx_init(&shtcx_devs[i], &shtcx_params[i]) != SHTCX_OK) {
LOG_ERROR("[auto_init_saul] error initializing shtcx #%u\n", i);
continue;
}
/* temperature */
saul_entries[(i * 2)].dev = &(shtc1_devs[i]);
saul_entries[(i * 2)].name = shtc1_saul_info[i].name;
saul_entries[(i * 2)].driver = &shtc1_temperature_saul_driver;
saul_entries[(i * 2)].dev = &(shtcx_devs[i]);
saul_entries[(i * 2)].name = shtcx_saul_info[i].name;
saul_entries[(i * 2)].driver = &shtcx_temperature_saul_driver;
/* Humidity */
saul_entries[(i * 2)+1].dev = &(shtc1_devs[i]);
saul_entries[(i * 2)+1].name = shtc1_saul_info[i].name;
saul_entries[(i * 2)+1].driver = &shtc1_relative_humidity_saul_driver;
saul_entries[(i * 2)+1].dev = &(shtcx_devs[i]);
saul_entries[(i * 2)+1].name = shtcx_saul_info[i].name;
saul_entries[(i * 2)+1].driver = &shtcx_relative_humidity_saul_driver;
saul_reg_add(&(saul_entries[(i * 2)]));
saul_reg_add(&(saul_entries[(i * 2)+1]));

View File

@ -139,7 +139,7 @@ void saul_init_devs(void)
extern void auto_init_ina2xx(void);
auto_init_ina2xx();
}
if (IS_USED(MODULE_INA3221)) {
if (IS_USED(MODUE_INA3221)) {
extern void auto_init_ina3221(void);
auto_init_ina3221();
}
@ -279,9 +279,9 @@ void saul_init_devs(void)
extern void auto_init_sht3x(void);
auto_init_sht3x();
}
if (IS_USED(MODULE_SHTC1)) {
extern void auto_init_shtc1(void);
auto_init_shtc1();
if (IS_USED(MODULE_SHTCX)) {
extern void auto_init_shtcx(void);
auto_init_shtcx();
}
if (IS_USED(MODULE_SI1133)) {
extern void auto_init_si1133(void);

View File

@ -5,15 +5,55 @@
# directory for more details.
#
config MODULE_SHTC1
bool "Sensirion SHTC1 Temperature and humidity sensor"
menuconfig MODULE_SHTCX
bool
prompt "SHTCX Temperature and humidity sensors" if !(MODULE_SAUL_DEFAULT && HAVE_SHTCX)
default y if (MODULE_SAUL_DEFAULT && HAVE_SHTCX)
depends on HAS_PERIPH_I2C
depends on TEST_KCONFIG
select MODULE_PERIPH_I2C
select MODULE_CHECKSUM
help
Device driver for the Sensirion SHTCX Temperature and Humidity sensor family
(SHTC1/SHTC3). Select a model.
if MODULE_SHTCX
choice
bool "sensor variant"
default MODULE_SHTC1 if HAVE_SHTC1
default MODULE_SHTC3 if HAVE_SHTC3
help
Device driver for the SHTCX pressure sensor family
(SHTC1/SHTC3). Select a model.
config MODULE_SHTC1
bool "SHTC1"
config MODULE_SHTC3
bool "SHTC3"
endchoice
endif # MODULE_SHTCX
menuconfig KCONFIG_USEMODULE_SHTCX
bool "Configure SHTCX driver"
depends on USEMODULE_SHTCX
help
Configure the SHTCX driver using Kconfig.
config HAVE_SHTCX
bool
config HAVE_SHTC1
bool
select MODULE_SHTC1 if MODULE_SAUL_DEFAULT
select HAVE_SHTCX
help
Indicates that a SHTC1 temperature and humidity sensor is present.
Indicates that an SHTC1 sensor is present.
config HAVE_SHTC3
bool
select HAVE_SHTCX
help
Indicates that an SHTC3 sensor is present.

View File

@ -1,2 +1,6 @@
USEMODULE_INCLUDES_shtc1 := $(LAST_MAKEFILEDIR)/include
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_shtc1)
# include variants of shtcx drivers as pseudo modules
PSEUDOMODULES += shtc1
PSEUDOMODULES += shtc3
USEMODULE_INCLUDES_shtcx := $(LAST_MAKEFILEDIR)/include
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_shtcx)

View File

@ -7,23 +7,23 @@
*/
/**
* @ingroup drivers_shtc1
* @ingroup drivers_shtcx
*
* @{
*
* @file
* @brief Default parameters for the SHTC1 Temperature and humidity sensor
* @brief Default parameters for the SHTCX Temperature and humidity sensor
*
* @author Steffen Robertz <steffen.robertz@rwth-aachen.de>
* @author Josua Arndt <jarndt@ias.rwth-aachen.de>
*/
#ifndef SHTC1_PARAMS_H
#define SHTC1_PARAMS_H
#ifndef SHTCX_PARAMS_H
#define SHTCX_PARAMS_H
#include "board.h"
#include "shtc1.h"
#include "shtc1_regs.h"
#include "shtcx.h"
#include "shtcx_regs.h"
#include "saul_reg.h"
#ifdef __cplusplus
@ -31,44 +31,45 @@ extern "C" {
#endif
/**
* @name Default configuration parameters for SHTC1 sensors
* @name Default configuration parameters for SHTCX sensors
* @{
*/
#ifndef SHTC1_PARAM_I2C_DEV
#define SHTC1_PARAM_I2C_DEV (I2C_DEV(0))
#ifndef SHTCX_PARAM_I2C_DEV
#define SHTCX_PARAM_I2C_DEV (I2C_DEV(0)) /**< Default I2C BUS used */
#endif
#ifndef SHTC1_PARAM_I2C_ADDR
#define SHTC1_PARAM_I2C_ADDR SHTC1_I2C_ADDRESS
#ifndef SHTCX_PARAM_I2C_ADDR
#define SHTCX_PARAM_I2C_ADDR SHTCX_I2C_ADDRESS /**< I2C Address */
#endif
#ifndef SHTC1_PARAMS
#define SHTC1_PARAMS { .i2c_dev = SHTC1_PARAM_I2C_DEV, \
.i2c_addr = SHTC1_PARAM_I2C_ADDR }
#ifndef SHTCX_PARAMS
#define SHTCX_PARAMS { .i2c_dev = SHTCX_PARAM_I2C_DEV, \
.i2c_addr = SHTCX_PARAM_I2C_ADDR }
#endif
#ifndef SHTC1_SAUL_INFO
#define SHTC1_SAUL_INFO { .name = "shtc1 temperature" }, \
{ .name = "shtc1 humidity" }
#ifndef SHTCX_SAUL_INFO
#define SHTCX_SAUL_INFO { .name = "shtcx temperature" }, \
{ .name = "shtcx humidity" }
#endif
/** @} */
/**
* @brief Allocation of SHTC1 configuration
* @brief Allocation of SHTCX configuration
*/
static const shtc1_params_t shtc1_params[] =
static const shtcx_params_t shtcx_params[] =
{
SHTC1_PARAMS
SHTCX_PARAMS
};
/**
* @brief Configure SAUL registry entries
*/
static const saul_reg_info_t shtc1_saul_info[] =
static const saul_reg_info_t shtcx_saul_info[] =
{
SHTC1_SAUL_INFO
SHTCX_SAUL_INFO
};
#ifdef __cplusplus
}
#endif
#endif /* SHTC1_PARAMS_H */
#endif /* SHTCX_PARAMS_H */
/** @} */

View File

@ -7,43 +7,43 @@
*/
/**
* @ingroup drivers_shtc1
* @ingroup drivers_shtcx
*
* @{
* @file
* @brief Register definitions for SHTC1 devices
* @brief Register definitions for SHTCX devices
*
* @author Steffen Robertz <steffen.robertz@rwth-aachen.de>
* @author Josua Arndt <jarndt@ias.rwth-aachen.de>
*/
#ifndef SHTC1_REGS_H
#define SHTC1_REGS_H
#ifndef SHTCX_REGS_H
#define SHTCX_REGS_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name SHTC1 registers
* @name SHTCX registers
* @{
*/
#define SHTC1_CRC (0x31) /**< crc polynomial */
#define SHTC1_MEASURE_CLOCK_STRETCHING_TEMP_HIGH (0x7C) /**< Clock stretching enable high*/
#define SHTC1_MEASURE_CLOCK_STRETCHING_TEMP_LOW (0xA2) /**< Clock stretching disable high*/
#define SHTC1_COMMAND_RESET_HIGH (0x80) /**< Reset command high*/
#define SHTC1_COMMAND_RESET_LOW (0x5D) /**< Reset command low*/
#define SHTC1_COMMAND_ID_HIGH (0xEF) /**< Get ID command low*/
#define SHTC1_COMMAND_ID_LOW (0xC8) /**< Get ID command low*/
#define SHTCX_CRC (0x31) /**< crc polynomial */
#define SHTCX_MEASURE_CLOCK_STRETCHING_TEMP_HIGH (0x7C) /**< Clock stretching enable high*/
#define SHTCX_MEASURE_CLOCK_STRETCHING_TEMP_LOW (0xA2) /**< Clock stretching disable high*/
#define SHTCX_COMMAND_RESET_HIGH (0x80) /**< Reset command high*/
#define SHTCX_COMMAND_RESET_LOW (0x5D) /**< Reset command low*/
#define SHTCX_COMMAND_ID_HIGH (0xEF) /**< Get ID command low*/
#define SHTCX_COMMAND_ID_LOW (0xC8) /**< Get ID command low*/
/** @} */
/**
* @brief SHTC1 default ID
* @brief SHTCX default ID
*/
#define SHTC1_ID (0x07) /* ID Mask */
#define SHTCX_ID (0x07) /* ID Mask */
#ifdef __cplusplus
}
#endif
#endif /* SHTC1_REGS_H */
#endif /* SHTCX_REGS_H */
/** @} */

View File

@ -7,11 +7,11 @@
*/
/**
* @ingroup drivers_shtc1
* @ingroup drivers_shtcx
* @{
*
* @file
* @brief Device driver implementation for the Sensirion SHTC1 temperature
* @brief Device driver implementation for the Sensirion SHTCX temperature
* and humidity sensor.
*
* @author Steffen Robertz <steffen.robertz@rwth-aachen.de>
@ -24,13 +24,13 @@
#include "log.h"
#include "assert.h"
#include "checksum/crc8.h"
#include "shtc1.h"
#include "shtc1_regs.h"
#include "shtcx.h"
#include "shtcx_regs.h"
#define ENABLE_DEBUG 0
#include "debug.h"
int8_t shtc1_init(shtc1_t *const dev, const shtc1_params_t *params)
int8_t shtcx_init(shtcx_t *const dev, const shtcx_params_t *params)
{
uint16_t id;
@ -38,31 +38,31 @@ int8_t shtc1_init(shtc1_t *const dev, const shtc1_params_t *params)
assert(dev && params);
/* copy settings into the device descriptor */
dev->params = *params;
/* Verify the connection by reading the SHTC1's ID and checking its value */
if (shtc1_id(dev, &id) != SHTC1_OK) {
return SHTC1_ERROR_BUS;
/* Verify the connection by reading the SHTCX's ID and checking its value */
if (shtcx_id(dev, &id) != SHTCX_OK) {
return SHTCX_ERROR_BUS;
}
else if ((id & 0x3F) != SHTC1_ID) {
return SHTC1_ERROR_CRC;
else if ((id & 0x3F) != SHTCX_ID) {
return SHTCX_ERROR_CRC;
}
else {
return SHTC1_OK;
return SHTCX_OK;
}
}
int8_t shtc1_read(const shtc1_t *dev, uint16_t *rel_humidity,
int8_t shtcx_read(const shtcx_t *dev, uint16_t *rel_humidity,
int16_t *temperature)
{
uint8_t received[6];
/* Build and issue the measurement command */
uint8_t cmd[] =
{ SHTC1_MEASURE_CLOCK_STRETCHING_TEMP_HIGH,
SHTC1_MEASURE_CLOCK_STRETCHING_TEMP_LOW };
{ SHTCX_MEASURE_CLOCK_STRETCHING_TEMP_HIGH,
SHTCX_MEASURE_CLOCK_STRETCHING_TEMP_LOW };
i2c_acquire(dev->params.i2c_dev);
if (i2c_write_bytes(dev->params.i2c_dev, dev->params.i2c_addr, cmd, 2, 0)) {
return SHTC1_ERROR_BUS;
return SHTCX_ERROR_BUS;
}
/* Receive the measurement */
/* 16 bit Temperature
@ -72,7 +72,7 @@ int8_t shtc1_read(const shtc1_t *dev, uint16_t *rel_humidity,
*/
if (i2c_read_bytes(dev->params.i2c_dev, dev->params.i2c_addr, received, 6,
0)) {
return SHTC1_ERROR_BUS;
return SHTCX_ERROR_BUS;
}
i2c_release(dev->params.i2c_dev);
@ -89,47 +89,47 @@ int8_t shtc1_read(const shtc1_t *dev, uint16_t *rel_humidity,
*temperature = ((17500 * (uint32_t)temp_f) >> 16) - 4500;
}
if (!((crc8(&received[0], 2, SHTC1_CRC, 0xFF) == received[2]) &&
(crc8(&received[3], 2, SHTC1_CRC, 0xFF) == received[5]))) {
if (!((crc8(&received[0], 2, SHTCX_CRC, 0xFF) == received[2]) &&
(crc8(&received[3], 2, SHTCX_CRC, 0xFF) == received[5]))) {
/* crc check failed */
DEBUG("CRC Error\n");
return SHTC1_ERROR_CRC;
return SHTCX_ERROR_CRC;
}
DEBUG("CRC Passed! \n");
return SHTC1_OK;
return SHTCX_OK;
}
int8_t shtc1_id(const shtc1_t *dev, uint16_t *id)
int8_t shtcx_id(const shtcx_t *dev, uint16_t *id)
{
/* Build and send measurement command */
uint8_t data[] = { SHTC1_COMMAND_ID_HIGH, SHTC1_COMMAND_ID_LOW };
uint8_t data[] = { SHTCX_COMMAND_ID_HIGH, SHTCX_COMMAND_ID_LOW };
i2c_acquire(dev->params.i2c_dev);
if (i2c_write_bytes(dev->params.i2c_dev, dev->params.i2c_addr, data, 2,
0)) {
return SHTC1_ERROR_BUS;
return SHTCX_ERROR_BUS;
}
/* receive ID and check if the send and receive commands were successful */
if (i2c_read_bytes(dev->params.i2c_dev, dev->params.i2c_addr, data, 2, 0)) {
return SHTC1_ERROR_BUS;
return SHTCX_ERROR_BUS;
}
i2c_release(dev->params.i2c_dev);
/* Save ID in device descriptor */
*id = (data[0] << 8) | data[1];
return SHTC1_OK;
return SHTCX_OK;
}
int8_t shtc1_reset(const shtc1_t *const dev)
int8_t shtcx_reset(const shtcx_t *const dev)
{
/* Build and issue the reset command */
uint8_t data[] = { SHTC1_COMMAND_RESET_HIGH, SHTC1_COMMAND_RESET_LOW };
uint8_t data[] = { SHTCX_COMMAND_RESET_HIGH, SHTCX_COMMAND_RESET_LOW };
i2c_acquire(dev->params.i2c_dev);
if (i2c_write_bytes(dev->params.i2c_dev, dev->params.i2c_addr, data, 2,
0)) {
return SHTC1_ERROR_BUS;
return SHTCX_ERROR_BUS;
}
i2c_release(dev->params.i2c_dev);
return SHTC1_OK;
return SHTCX_OK;
}

View File

@ -7,11 +7,11 @@
*/
/**
* @ingroup drivers_shtc1
* @ingroup drivers_shtcx
* @{
*
* @file
* @brief SHTC1 adaption to the RIOT actuator/sensor interface
* @brief SHTCX adaption to the RIOT actuator/sensor interface
*
* @author Michel Gerlach <michel.gerlach@haw-hamburg.de>
*
@ -19,11 +19,11 @@
*/
#include "saul.h"
#include "shtc1.h"
#include "shtcx.h"
static int read_temperature(const void *dev, phydat_t *res)
{
if (shtc1_read((shtc1_t *)dev, NULL, &res->val[0]) != SHTC1_OK) {
if (shtcx_read((shtcx_t *)dev, NULL, &res->val[0]) != SHTCX_OK) {
return -ECANCELED;
}
res->unit = UNIT_TEMP_C;
@ -34,7 +34,7 @@ static int read_temperature(const void *dev, phydat_t *res)
static int read_relative_humidity(const void *dev, phydat_t *res)
{
if (shtc1_read((shtc1_t *)dev, (uint16_t *)&res->val[0], NULL) != SHTC1_OK) {
if (shtcx_read((shtcx_t *)dev, (uint16_t *)&res->val[0], NULL) != SHTCX_OK) {
return -ECANCELED;
}
res->unit = UNIT_PERCENT;
@ -43,13 +43,13 @@ static int read_relative_humidity(const void *dev, phydat_t *res)
return 1;
}
const saul_driver_t shtc1_temperature_saul_driver = {
const saul_driver_t shtcx_temperature_saul_driver = {
.read = read_temperature,
.write = saul_notsup,
.type = SAUL_SENSE_TEMP,
};
const saul_driver_t shtc1_relative_humidity_saul_driver = {
const saul_driver_t shtcx_relative_humidity_saul_driver = {
.read = read_relative_humidity,
.write = saul_notsup,
.type = SAUL_SENSE_HUM,