1 /* ST Microelectronics STTS751 temperature sensor 2 * 3 * Copyright (c) 2019 STMicroelectronics 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 * 7 * Datasheet: 8 * https://www.st.com/resource/en/datasheet/stts751.pdf 9 */ 10 11 #ifndef ZEPHYR_DRIVERS_SENSOR_STTS751_STTS751_H_ 12 #define ZEPHYR_DRIVERS_SENSOR_STTS751_STTS751_H_ 13 14 #include <stdint.h> 15 #include <zephyr/drivers/i2c.h> 16 #include <zephyr/drivers/gpio.h> 17 #include <zephyr/drivers/sensor.h> 18 #include <zephyr/kernel.h> 19 #include <zephyr/types.h> 20 #include <zephyr/sys/util.h> 21 #include <stmemsc.h> 22 #include "stts751_reg.h" 23 24 struct stts751_config { 25 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) 26 struct i2c_dt_spec i2c; 27 #endif 28 int (*bus_init)(const struct device *dev); 29 #ifdef CONFIG_STTS751_TRIGGER 30 struct gpio_dt_spec int_gpio; 31 #endif 32 }; 33 34 struct stts751_data { 35 const struct device *dev; 36 int16_t sample_temp; 37 38 stmdev_ctx_t *ctx; 39 40 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) 41 stmdev_ctx_t ctx_i2c; 42 #endif 43 44 #ifdef CONFIG_STTS751_TRIGGER 45 struct gpio_callback gpio_cb; 46 47 const struct sensor_trigger *thsld_trigger; 48 sensor_trigger_handler_t thsld_handler; 49 50 #if defined(CONFIG_STTS751_TRIGGER_OWN_THREAD) 51 K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_STTS751_THREAD_STACK_SIZE); 52 struct k_thread thread; 53 struct k_sem gpio_sem; 54 #elif defined(CONFIG_STTS751_TRIGGER_GLOBAL_THREAD) 55 struct k_work work; 56 #endif 57 58 #endif /* CONFIG_STTS751_TRIGGER */ 59 }; 60 61 int stts751_i2c_init(const struct device *dev); 62 63 #ifdef CONFIG_STTS751_TRIGGER 64 int stts751_trigger_set(const struct device *dev, 65 const struct sensor_trigger *trig, 66 sensor_trigger_handler_t handler); 67 68 int stts751_init_interrupt(const struct device *dev); 69 #endif 70 71 #endif /* ZEPHYR_DRIVERS_SENSOR_STTS751_STTS751_H_ */ 72