2020-08-07 22:29:52 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Laird Connectivity
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEPHYR_DRIVERS_SENSOR_SM351LT_SM351LT_H_
|
|
|
|
#define ZEPHYR_DRIVERS_SENSOR_SM351LT_SM351LT_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2022-05-06 16:25:46 +08:00
|
|
|
#include <zephyr/drivers/gpio.h>
|
|
|
|
#include <zephyr/drivers/sensor.h>
|
2022-10-04 22:34:24 +08:00
|
|
|
#include <zephyr/kernel.h>
|
2020-08-07 22:29:52 +08:00
|
|
|
|
|
|
|
#define SENSOR_ATTR_SM351LT_TRIGGER_TYPE SENSOR_ATTR_PRIV_START
|
|
|
|
|
|
|
|
struct sm351lt_config {
|
2022-06-27 12:44:57 +08:00
|
|
|
struct gpio_dt_spec int_gpio;
|
2020-08-07 22:29:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sm351lt_data {
|
|
|
|
bool sample_status;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SM351LT_TRIGGER
|
2020-07-09 15:13:48 +08:00
|
|
|
const struct device *dev;
|
2020-08-07 22:29:52 +08:00
|
|
|
struct gpio_callback gpio_cb;
|
|
|
|
|
|
|
|
uint32_t trigger_type;
|
|
|
|
sensor_trigger_handler_t changed_handler;
|
2023-04-08 04:44:36 +08:00
|
|
|
const struct sensor_trigger *changed_trigger;
|
2020-08-07 22:29:52 +08:00
|
|
|
|
|
|
|
#if defined(CONFIG_SM351LT_TRIGGER_OWN_THREAD)
|
2023-10-11 05:02:01 +08:00
|
|
|
K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_SM351LT_THREAD_STACK_SIZE);
|
2020-08-07 22:29:52 +08:00
|
|
|
struct k_thread thread;
|
|
|
|
struct k_sem gpio_sem;
|
|
|
|
#elif defined(CONFIG_SM351LT_TRIGGER_GLOBAL_THREAD)
|
|
|
|
struct k_work work;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* CONFIG_SM351LT_TRIGGER */
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* ZEPHYR_DRIVERS_SENSOR_SM351LT_SM351LT_H_ */
|