1 /*
2  * Copyright (c) 2023 Andriy Gelman
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_DRIVERS_SENSOR_ADT7310_H_
8 #define ZEPHYR_DRIVERS_SENSOR_ADT7310_H_
9 
10 #include <zephyr/types.h>
11 #include <zephyr/device.h>
12 #include <zephyr/drivers/gpio.h>
13 #include <zephyr/drivers/sensor.h>
14 
15 int adt7310_init_interrupt(const struct device *dev);
16 
17 int adt7310_trigger_set(const struct device *dev, const struct sensor_trigger *trig,
18 			sensor_trigger_handler_t handler);
19 
20 struct adt7310_data {
21 	int16_t sample;
22 
23 #ifdef CONFIG_ADT7310_TRIGGER
24 	struct gpio_callback gpio_cb;
25 
26 	sensor_trigger_handler_t th_handler;
27 	const struct sensor_trigger *th_trigger;
28 
29 	const struct device *dev;
30 
31 #ifdef CONFIG_ADT7310_TRIGGER_OWN_THREAD
32 	K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_ADT7310_THREAD_STACK_SIZE);
33 	struct k_sem gpio_sem;
34 	struct k_thread thread;
35 #elif CONFIG_ADT7310_TRIGGER_GLOBAL_THREAD
36 	struct k_work work;
37 #endif
38 #endif /* CONFIG_ADT7310_TRIGGER */
39 };
40 
41 struct adt7310_dev_config {
42 	struct spi_dt_spec bus;
43 #ifdef CONFIG_ADT7310_TRIGGER
44 	struct gpio_dt_spec int_gpio;
45 #endif
46 };
47 
48 #endif /* ZEPHYR_DRIVERS_SENSOR_ADT7310_H_ */
49