drivers/sensor: add support to STTS22H temperature sensor
The STTS22H is an ultralow-power, high-accuracy, digital temperature sensor offering high performance over the entire operating temperature range. This driver is based on stmemsc HAL i/f v2.3 https://www.st.com/resource/en/datasheet/stts22h.pdf Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
parent
93d005fc87
commit
8d83b76f84
13 changed files with 572 additions and 0 deletions
|
@ -139,6 +139,7 @@ add_subdirectory_ifdef(CONFIG_SM351LT sm351lt)
|
|||
add_subdirectory_ifdef(CONFIG_STM32_TEMP stm32_temp)
|
||||
add_subdirectory_ifdef(CONFIG_STM32_VBAT stm32_vbat)
|
||||
add_subdirectory_ifdef(CONFIG_STM32_VREF stm32_vref)
|
||||
add_subdirectory_ifdef(CONFIG_STTS22H stts22h)
|
||||
add_subdirectory_ifdef(CONFIG_STTS751 stts751)
|
||||
add_subdirectory_ifdef(CONFIG_SX9500 sx9500)
|
||||
add_subdirectory_ifdef(CONFIG_TACH_IT8XXX2 ite_tach_it8xxx2)
|
||||
|
|
|
@ -224,6 +224,7 @@ source "drivers/sensor/sm351lt/Kconfig"
|
|||
source "drivers/sensor/stm32_temp/Kconfig"
|
||||
source "drivers/sensor/stm32_vbat/Kconfig"
|
||||
source "drivers/sensor/stm32_vref/Kconfig"
|
||||
source "drivers/sensor/stts22h/Kconfig"
|
||||
source "drivers/sensor/stts751/Kconfig"
|
||||
source "drivers/sensor/sx9500/Kconfig"
|
||||
source "drivers/sensor/tcn75a/Kconfig"
|
||||
|
|
12
drivers/sensor/stts22h/CMakeLists.txt
Normal file
12
drivers/sensor/stts22h/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
# ST Microelectronics STTS22H temperature sensor
|
||||
#
|
||||
# Copyright (c) 2024 STMicroelectronics
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
zephyr_library()
|
||||
|
||||
zephyr_library_sources(stts22h.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_STTS22H_TRIGGER stts22h_trigger.c)
|
||||
|
||||
zephyr_library_include_directories(../stmemsc)
|
24
drivers/sensor/stts22h/Kconfig
Normal file
24
drivers/sensor/stts22h/Kconfig
Normal file
|
@ -0,0 +1,24 @@
|
|||
# ST Microelectronics STTS22H temperature sensor
|
||||
|
||||
# Copyright (c) 2024 STMicroelectronics
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig STTS22H
|
||||
bool "STTS22H temperature sensor"
|
||||
default y
|
||||
depends on DT_HAS_ST_STTS22H_ENABLED
|
||||
depends on ZEPHYR_HAL_ST_MODULE
|
||||
select I2C
|
||||
select HAS_STMEMSC
|
||||
select USE_STDC_STTS22H
|
||||
help
|
||||
Enable driver for STTS22H I2C-based temperature sensor.
|
||||
|
||||
if STTS22H
|
||||
|
||||
module = STTS22H
|
||||
thread_priority = 10
|
||||
thread_stack_size = 1024
|
||||
source "drivers/sensor/Kconfig.trigger_template"
|
||||
|
||||
endif # STTS22H
|
212
drivers/sensor/stts22h/stts22h.c
Normal file
212
drivers/sensor/stts22h/stts22h.c
Normal file
|
@ -0,0 +1,212 @@
|
|||
/* ST Microelectronics STTS22H temperature sensor
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Datasheet:
|
||||
* https://www.st.com/resource/en/datasheet/stts22h.pdf
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT st_stts22h
|
||||
|
||||
#include <zephyr/drivers/sensor.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/init.h>
|
||||
#include <zephyr/sys/byteorder.h>
|
||||
#include <zephyr/sys/__assert.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
#include "stts22h.h"
|
||||
|
||||
LOG_MODULE_REGISTER(STTS22H, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
static inline int stts22h_set_odr_raw(const struct device *dev, stts22h_odr_temp_t odr)
|
||||
{
|
||||
const struct stts22h_config *cfg = dev->config;
|
||||
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
|
||||
|
||||
return stts22h_temp_data_rate_set(ctx, odr);
|
||||
}
|
||||
|
||||
static int stts22h_sample_fetch(const struct device *dev, enum sensor_channel chan)
|
||||
{
|
||||
struct stts22h_data *data = dev->data;
|
||||
const struct stts22h_config *cfg = dev->config;
|
||||
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
|
||||
int16_t raw_temp;
|
||||
|
||||
if (chan != SENSOR_CHAN_ALL && chan != SENSOR_CHAN_AMBIENT_TEMP) {
|
||||
LOG_ERR("Invalid channel: %d", chan);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (stts22h_temperature_raw_get(ctx, &raw_temp) < 0) {
|
||||
LOG_ERR("Failed to read sample");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
data->sample_temp = raw_temp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void stts22h_temp_convert(struct sensor_value *val, int16_t raw_val)
|
||||
{
|
||||
val->val1 = raw_val / 100;
|
||||
val->val2 = ((int32_t)raw_val % 100) * 10000;
|
||||
}
|
||||
|
||||
static int stts22h_channel_get(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
struct sensor_value *val)
|
||||
{
|
||||
struct stts22h_data *data = dev->data;
|
||||
|
||||
if (chan != SENSOR_CHAN_AMBIENT_TEMP) {
|
||||
LOG_ERR("Invalid channel: %d", chan);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
stts22h_temp_convert(val, data->sample_temp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const uint8_t stts22h_map[6] = {0, 1, 25, 50, 100, 200};
|
||||
|
||||
static int stts22h_odr_set(const struct device *dev,
|
||||
const struct sensor_value *val)
|
||||
{
|
||||
int odr;
|
||||
|
||||
for (odr = 0; odr < ARRAY_SIZE(stts22h_map); odr++) {
|
||||
if (val->val1 <= stts22h_map[odr]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (odr) {
|
||||
case 0:
|
||||
return stts22h_set_odr_raw(dev, STTS22H_POWER_DOWN);
|
||||
case 1:
|
||||
return stts22h_set_odr_raw(dev, STTS22H_1Hz);
|
||||
case 2:
|
||||
return stts22h_set_odr_raw(dev, STTS22H_25Hz);
|
||||
case 3:
|
||||
return stts22h_set_odr_raw(dev, STTS22H_50Hz);
|
||||
case 4:
|
||||
return stts22h_set_odr_raw(dev, STTS22H_100Hz);
|
||||
case 5:
|
||||
return stts22h_set_odr_raw(dev, STTS22H_200Hz);
|
||||
default:
|
||||
LOG_ERR("bad frequency: %d (odr = %d)", val->val1, odr);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static int stts22h_attr_set(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val)
|
||||
{
|
||||
if (chan != SENSOR_CHAN_ALL && chan != SENSOR_CHAN_AMBIENT_TEMP) {
|
||||
LOG_ERR("Invalid channel: %d", chan);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
switch (attr) {
|
||||
case SENSOR_ATTR_SAMPLING_FREQUENCY:
|
||||
return stts22h_odr_set(dev, val);
|
||||
default:
|
||||
LOG_ERR("Attribute %d not supported.", attr);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct sensor_driver_api stts22h_api_funcs = {
|
||||
.attr_set = stts22h_attr_set,
|
||||
.sample_fetch = stts22h_sample_fetch,
|
||||
.channel_get = stts22h_channel_get,
|
||||
#if CONFIG_STTS22H_TRIGGER
|
||||
.trigger_set = stts22h_trigger_set,
|
||||
#endif
|
||||
};
|
||||
|
||||
static int stts22h_init_chip(const struct device *dev)
|
||||
{
|
||||
const struct stts22h_config *cfg = dev->config;
|
||||
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
|
||||
uint8_t chip_id, odr;
|
||||
|
||||
if (stts22h_dev_id_get(ctx, &chip_id) < 0) {
|
||||
LOG_ERR("Failed reading chip id");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
LOG_INF("chip id 0x%02x", chip_id);
|
||||
|
||||
if (stts22h_auto_increment_set(ctx, 1) < 0) {
|
||||
LOG_ERR("Failed to set autoincr");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* set odr from DT */
|
||||
odr = cfg->odr;
|
||||
LOG_INF("sensor odr is %d", odr);
|
||||
if (stts22h_set_odr_raw(dev, odr) < 0) {
|
||||
LOG_ERR("Failed to set sampling rate");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stts22h_init(const struct device *dev)
|
||||
{
|
||||
struct stts22h_data *data = dev->data;
|
||||
#ifdef CONFIG_STTS22H_TRIGGER
|
||||
const struct stts22h_config *cfg = dev->config;
|
||||
#endif
|
||||
|
||||
LOG_INF("Initialize device %s", dev->name);
|
||||
data->dev = dev;
|
||||
|
||||
if (stts22h_init_chip(dev) < 0) {
|
||||
LOG_ERR("Failed to initialize chip");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STTS22H_TRIGGER
|
||||
if (cfg->int_gpio.port) {
|
||||
if (stts22h_init_interrupt(dev) < 0) {
|
||||
LOG_ERR("Failed to initialize interrupt.");
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define STTS22H_DEFINE(inst) \
|
||||
static struct stts22h_data stts22h_data_##inst; \
|
||||
\
|
||||
static const struct stts22h_config stts22h_config_##inst = { \
|
||||
STMEMSC_CTX_I2C(&stts22h_config_##inst.i2c), \
|
||||
.i2c = I2C_DT_SPEC_INST_GET(inst), \
|
||||
.temp_hi = DT_INST_PROP(inst, temperature_hi_threshold), \
|
||||
.temp_lo = DT_INST_PROP(inst, temperature_lo_threshold), \
|
||||
.odr = DT_INST_PROP(inst, sampling_rate), \
|
||||
IF_ENABLED(CONFIG_STTS22H_TRIGGER, \
|
||||
(.int_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, int_gpios, { 0 }),)) \
|
||||
}; \
|
||||
\
|
||||
SENSOR_DEVICE_DT_INST_DEFINE(inst, stts22h_init, NULL, \
|
||||
&stts22h_data_##inst, &stts22h_config_##inst, POST_KERNEL, \
|
||||
CONFIG_SENSOR_INIT_PRIORITY, &stts22h_api_funcs); \
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(STTS22H_DEFINE)
|
63
drivers/sensor/stts22h/stts22h.h
Normal file
63
drivers/sensor/stts22h/stts22h.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* ST Microelectronics STTS22H temperature sensor
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Datasheet:
|
||||
* https://www.st.com/resource/en/datasheet/stts22h.pdf
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_DRIVERS_SENSOR_STTS22H_STTS22H_H_
|
||||
#define ZEPHYR_DRIVERS_SENSOR_STTS22H_STTS22H_H_
|
||||
|
||||
#include <zephyr/drivers/sensor.h>
|
||||
#include <zephyr/types.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/sys/util.h>
|
||||
#include <stmemsc.h>
|
||||
#include "stts22h_reg.h"
|
||||
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
|
||||
struct stts22h_config {
|
||||
stmdev_ctx_t ctx;
|
||||
const struct i2c_dt_spec i2c;
|
||||
#ifdef CONFIG_STTS22H_TRIGGER
|
||||
const struct gpio_dt_spec int_gpio;
|
||||
#endif
|
||||
uint8_t temp_hi;
|
||||
uint8_t temp_lo;
|
||||
uint8_t odr;
|
||||
};
|
||||
|
||||
struct stts22h_data {
|
||||
const struct device *dev;
|
||||
int16_t sample_temp;
|
||||
|
||||
#ifdef CONFIG_STTS22H_TRIGGER
|
||||
struct gpio_callback gpio_cb;
|
||||
|
||||
const struct sensor_trigger *thsld_trigger;
|
||||
sensor_trigger_handler_t thsld_handler;
|
||||
|
||||
#if defined(CONFIG_STTS22H_TRIGGER_OWN_THREAD)
|
||||
K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_STTS22H_THREAD_STACK_SIZE);
|
||||
struct k_thread thread;
|
||||
struct k_sem gpio_sem;
|
||||
#elif defined(CONFIG_STTS22H_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_STTS22H_TRIGGER */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_STTS22H_TRIGGER
|
||||
int stts22h_trigger_set(const struct device *dev,
|
||||
const struct sensor_trigger *trig,
|
||||
sensor_trigger_handler_t handler);
|
||||
|
||||
int stts22h_init_interrupt(const struct device *dev);
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_DRIVERS_SENSOR_STTS22H_STTS22H_H_ */
|
162
drivers/sensor/stts22h/stts22h_trigger.c
Normal file
162
drivers/sensor/stts22h/stts22h_trigger.c
Normal file
|
@ -0,0 +1,162 @@
|
|||
/* ST Microelectronics STTS22H temperature sensor
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Datasheet:
|
||||
* https://www.st.com/resource/en/datasheet/stts22h.pdf
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT st_stts22h
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/drivers/sensor.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
#include "stts22h.h"
|
||||
|
||||
LOG_MODULE_DECLARE(STTS22H, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
/**
|
||||
* stts22h_trigger_set - link external trigger to event data ready
|
||||
*/
|
||||
int stts22h_trigger_set(const struct device *dev,
|
||||
const struct sensor_trigger *trig,
|
||||
sensor_trigger_handler_t handler)
|
||||
{
|
||||
struct stts22h_data *stts22h = dev->data;
|
||||
const struct stts22h_config *config = dev->config;
|
||||
|
||||
if (!config->int_gpio.port) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (trig->chan != SENSOR_CHAN_ALL &&
|
||||
trig->chan != SENSOR_CHAN_AMBIENT_TEMP) {
|
||||
LOG_ERR("Unsupported sensor trigger %d", trig->chan);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
stts22h->thsld_handler = handler;
|
||||
stts22h->thsld_trigger = trig;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* stts22h_handle_interrupt - handle the thsld event
|
||||
* read data and call handler if registered any
|
||||
*/
|
||||
static void stts22h_handle_interrupt(const struct device *dev)
|
||||
{
|
||||
struct stts22h_data *stts22h = dev->data;
|
||||
const struct stts22h_config *cfg = dev->config;
|
||||
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
|
||||
stts22h_temp_trlhd_src_t status;
|
||||
|
||||
stts22h_temp_trshld_src_get(ctx, &status);
|
||||
|
||||
if (stts22h->thsld_handler != NULL &&
|
||||
(status.under_thl || status.over_thh)) {
|
||||
stts22h->thsld_handler(dev, stts22h->thsld_trigger);
|
||||
}
|
||||
|
||||
gpio_pin_interrupt_configure_dt(&cfg->int_gpio, GPIO_INT_EDGE_TO_ACTIVE);
|
||||
}
|
||||
|
||||
static void stts22h_gpio_callback(const struct device *dev,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
{
|
||||
struct stts22h_data *stts22h =
|
||||
CONTAINER_OF(cb, struct stts22h_data, gpio_cb);
|
||||
const struct stts22h_config *cfg = stts22h->dev->config;
|
||||
|
||||
ARG_UNUSED(pins);
|
||||
|
||||
gpio_pin_interrupt_configure_dt(&cfg->int_gpio, GPIO_INT_DISABLE);
|
||||
|
||||
#if defined(CONFIG_STTS22H_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&stts22h->gpio_sem);
|
||||
#elif defined(CONFIG_STTS22H_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&stts22h->work);
|
||||
#endif /* CONFIG_STTS22H_TRIGGER_OWN_THREAD */
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STTS22H_TRIGGER_OWN_THREAD
|
||||
static void stts22h_thread(void *p1, void *p2, void *p3)
|
||||
{
|
||||
ARG_UNUSED(p2);
|
||||
ARG_UNUSED(p3);
|
||||
|
||||
struct stts22h_data *stts22h = p1;
|
||||
|
||||
while (1) {
|
||||
k_sem_take(&stts22h->gpio_sem, K_FOREVER);
|
||||
stts22h_handle_interrupt(stts22h->dev);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_STTS22H_TRIGGER_OWN_THREAD */
|
||||
|
||||
#ifdef CONFIG_STTS22H_TRIGGER_GLOBAL_THREAD
|
||||
static void stts22h_work_cb(struct k_work *work)
|
||||
{
|
||||
struct stts22h_data *stts22h =
|
||||
CONTAINER_OF(work, struct stts22h_data, work);
|
||||
|
||||
stts22h_handle_interrupt(stts22h->dev);
|
||||
}
|
||||
#endif /* CONFIG_STTS22H_TRIGGER_GLOBAL_THREAD */
|
||||
|
||||
int stts22h_init_interrupt(const struct device *dev)
|
||||
{
|
||||
struct stts22h_data *stts22h = dev->data;
|
||||
const struct stts22h_config *cfg = dev->config;
|
||||
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx;
|
||||
int ret;
|
||||
|
||||
if (!gpio_is_ready_dt(&cfg->int_gpio)) {
|
||||
LOG_ERR("GPIO device not ready");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_STTS22H_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&stts22h->gpio_sem, 0, K_SEM_MAX_LIMIT);
|
||||
|
||||
k_thread_create(&stts22h->thread, stts22h->thread_stack,
|
||||
CONFIG_STTS22H_THREAD_STACK_SIZE,
|
||||
stts22h_thread, stts22h,
|
||||
NULL, NULL, K_PRIO_COOP(CONFIG_STTS22H_THREAD_PRIORITY),
|
||||
0, K_NO_WAIT);
|
||||
k_thread_name_set(&stts22h->thread, dev->name);
|
||||
#elif defined(CONFIG_STTS22H_TRIGGER_GLOBAL_THREAD)
|
||||
stts22h->work.handler = stts22h_work_cb;
|
||||
#endif /* CONFIG_STTS22H_TRIGGER_OWN_THREAD */
|
||||
|
||||
ret = gpio_pin_configure_dt(&cfg->int_gpio, GPIO_INPUT);
|
||||
if (ret < 0) {
|
||||
LOG_DBG("Could not configure gpio");
|
||||
return ret;
|
||||
}
|
||||
|
||||
gpio_init_callback(&stts22h->gpio_cb, stts22h_gpio_callback, BIT(cfg->int_gpio.pin));
|
||||
|
||||
if (gpio_add_callback(cfg->int_gpio.port, &stts22h->gpio_cb) < 0) {
|
||||
LOG_DBG("Could not set gpio callback");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Enable interrupt on high/low temperature threshold */
|
||||
if (stts22h_temp_trshld_high_set(ctx, cfg->temp_hi) < 0) {
|
||||
LOG_DBG("Could not set gpio callback");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (stts22h_temp_trshld_low_set(ctx, cfg->temp_lo) < 0) {
|
||||
LOG_DBG("Could not set gpio callback");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return gpio_pin_interrupt_configure_dt(&cfg->int_gpio, GPIO_INT_EDGE_TO_ACTIVE);
|
||||
}
|
68
dts/bindings/sensor/st,stts22h-i2c.yaml
Normal file
68
dts/bindings/sensor/st,stts22h-i2c.yaml
Normal file
|
@ -0,0 +1,68 @@
|
|||
# Copyright (c) 2024 STMicroelectronics
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: |
|
||||
STMicroelectronics STTS22H temperature sensor connected to I2C bus
|
||||
When setting the sampling-rate property in a .dts or .dtsi file you
|
||||
may include stts22h.h and use the macros defined there.
|
||||
|
||||
Example:
|
||||
#include <zephyr/dt-bindings/sensor/stts22h.h>
|
||||
|
||||
stts22h: stts22h@0 {
|
||||
...
|
||||
|
||||
sampling-rate = <STTS22H_100Hz>;
|
||||
};
|
||||
|
||||
compatible: "st,stts22h"
|
||||
|
||||
include: [sensor-device.yaml, i2c-device.yaml]
|
||||
|
||||
properties:
|
||||
int-gpios:
|
||||
type: phandle-array
|
||||
description: interrupt pin
|
||||
|
||||
This pin defaults to active high when produced by the sensor.
|
||||
The property value should ensure the flags properly describe
|
||||
the signal that is presented to the driver.
|
||||
|
||||
temperature-hi-threshold:
|
||||
type: int
|
||||
default: 0
|
||||
description: |
|
||||
HIGH temperature threshold above which an alarm is triggered.
|
||||
Valid range is 0 to 255. It defaults to 0 (alarm off) which is
|
||||
the configuration at power-up. This threshold must be calculated
|
||||
from a temperature T in Celsius using the formula
|
||||
temperature-hi-threshold = 63 + T/0.64 C.
|
||||
|
||||
|
||||
temperature-lo-threshold:
|
||||
type: int
|
||||
default: 0
|
||||
description: |
|
||||
LOW temperature threshold below which an alarm is triggered.
|
||||
Valid range is 0 to 255. It defaults to 0 (alarm off) which is
|
||||
the configuration at power-up. This threshold must be calculated
|
||||
from a temperature T in Celsius using the formula
|
||||
temperature-lo-threshold = 63 + T/0.64 C.
|
||||
|
||||
sampling-rate:
|
||||
type: int
|
||||
default: 0x0
|
||||
description: |
|
||||
Specify the default output data rate expressed in samples per second (Hz).
|
||||
The values are taken in accordance to stts22h_odr_temp_t enumerative in hal/st
|
||||
module. Default 0x0 (power down) matches the power-up configuration.
|
||||
|
||||
- 0x00 # STTS22H_POWER_DOWN
|
||||
- 0x01 # STTS22H_ONE_SHOT
|
||||
- 0x04 # STTS22H_1Hz
|
||||
- 0x02 # STTS22H_25Hz
|
||||
- 0x12 # STTS22H_50Hz
|
||||
- 0x22 # STTS22H_100Hz
|
||||
- 0x32 # STTS22H_200Hz
|
||||
|
||||
enum: [0x00, 0x01, 0x02, 0x04, 0x12, 0x22, 0x32]
|
18
include/zephyr/dt-bindings/sensor/stts22h.h
Normal file
18
include/zephyr/dt-bindings/sensor/stts22h.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2024 STMicroelectronics
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_ST_STTS22H_H_
|
||||
#define ZEPHYR_INCLUDE_DT_BINDINGS_ST_STTS22H_H_
|
||||
|
||||
/* Output Data Rates */
|
||||
#define STTS22H_POWER_DOWN 0x00
|
||||
#define STTS22H_ONE_SHOT 0x01
|
||||
#define STTS22H_1Hz 0x04
|
||||
#define STTS22H_25Hz 0x02
|
||||
#define STTS22H_50Hz 0x12
|
||||
#define STTS22H_100Hz 0x22
|
||||
#define STTS22H_200Hz 0x32
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_ST_STTS22H_H_ */
|
|
@ -20,6 +20,7 @@
|
|||
#include <zephyr/dt-bindings/sensor/lis2du12.h>
|
||||
#include <zephyr/dt-bindings/sensor/lis2de12.h>
|
||||
#include <zephyr/dt-bindings/sensor/tmag5273.h>
|
||||
#include <zephyr/dt-bindings/sensor/stts22h.h>
|
||||
|
||||
/****************************************
|
||||
* PLEASE KEEP REG ADDRESSES SEQUENTIAL *
|
||||
|
@ -985,3 +986,10 @@ test_i2c_max31790: max31790@85 {
|
|||
channel = <6>;
|
||||
};
|
||||
};
|
||||
|
||||
test_i2c_stts22h: stts22h@86 {
|
||||
compatible = "st,stts22h";
|
||||
reg = <0x86>;
|
||||
int-gpios = <&test_gpio 0 0>;
|
||||
sampling-rate = <STTS22H_100Hz>;
|
||||
};
|
||||
|
|
|
@ -50,6 +50,7 @@ CONFIG_MPU6050_TRIGGER_GLOBAL_THREAD=y
|
|||
CONFIG_MPU9250_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_SHT3XD_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_SM351LT_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_STTS22H_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_STTS751_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_SX9500_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_TCN75A_TRIGGER_GLOBAL_THREAD=y
|
||||
|
|
|
@ -50,6 +50,7 @@ CONFIG_MPU6050_TRIGGER_NONE=y
|
|||
CONFIG_MPU9250_TRIGGER_NONE=y
|
||||
CONFIG_SHT3XD_TRIGGER_NONE=y
|
||||
CONFIG_SM351LT_TRIGGER_NONE=y
|
||||
CONFIG_STTS22H_TRIGGER_NONE=y
|
||||
CONFIG_STTS751_TRIGGER_NONE=y
|
||||
CONFIG_SX9500_TRIGGER_NONE=y
|
||||
CONFIG_TCN75A_TRIGGER_NONE=y
|
||||
|
|
|
@ -49,6 +49,7 @@ CONFIG_MPU6050_TRIGGER_OWN_THREAD=y
|
|||
CONFIG_MPU9250_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_SHT3XD_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_SM351LT_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_STTS22H_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_STTS751_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_SX9500_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_TCN75A_TRIGGER_OWN_THREAD=y
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue