Lines Matching +full:in +full:- +full:trig +full:- +full:gpios

4  * SPDX-License-Identifier: Apache-2.0
24 const struct sensor_trigger *trig, in sm351lt_trigger_set() argument
27 const struct sm351lt_config *const config = dev->config; in sm351lt_trigger_set()
28 struct sm351lt_data *data = dev->data; in sm351lt_trigger_set()
29 int ret = -ENOTSUP; in sm351lt_trigger_set()
31 if (trig->chan == SENSOR_CHAN_PROX) { in sm351lt_trigger_set()
32 data->changed_handler = handler; in sm351lt_trigger_set()
33 data->changed_trigger = trig; in sm351lt_trigger_set()
34 ret = gpio_pin_interrupt_configure_dt(&config->int_gpio, in sm351lt_trigger_set()
35 (handler ? data->trigger_type in sm351lt_trigger_set()
43 ret = gpio_add_callback(config->int_gpio.port, in sm351lt_trigger_set()
44 &data->gpio_cb); in sm351lt_trigger_set()
46 ret = gpio_remove_callback(config->int_gpio.port, in sm351lt_trigger_set()
47 &data->gpio_cb); in sm351lt_trigger_set()
61 k_sem_give(&data->gpio_sem); in sm351lt_gpio_callback()
63 k_work_submit(&data->work); in sm351lt_gpio_callback()
69 struct sm351lt_data *data = dev->data; in sm351lt_thread_cb()
71 if (likely(data->changed_handler != NULL)) { in sm351lt_thread_cb()
72 data->changed_handler(dev, data->changed_trigger); in sm351lt_thread_cb()
87 k_sem_take(&data->gpio_sem, K_FOREVER); in sm351lt_thread()
88 sm351lt_thread_cb(data->dev); in sm351lt_thread()
99 sm351lt_thread_cb(data->dev); in sm351lt_work_cb()
107 const struct sm351lt_config *config = dev->config; in sm351lt_sample_fetch()
108 struct sm351lt_data *data = dev->data; in sm351lt_sample_fetch()
111 return -ENOTSUP; in sm351lt_sample_fetch()
114 data->sample_status = gpio_pin_get_dt(&config->int_gpio); in sm351lt_sample_fetch()
123 struct sm351lt_data *data = dev->data; in sm351lt_channel_get()
126 val->val1 = data->sample_status; in sm351lt_channel_get()
127 val->val2 = 0; in sm351lt_channel_get()
129 return -ENOTSUP; in sm351lt_channel_get()
141 struct sm351lt_data *data = dev->data; in sm351lt_attr_set()
146 data->trigger_type = val->val1; in sm351lt_attr_set()
148 return -ENOTSUP; in sm351lt_attr_set()
151 return -ENOTSUP; in sm351lt_attr_set()
162 struct sm351lt_data *data = dev->data; in sm351lt_attr_get()
167 val->val1 = data->trigger_type; in sm351lt_attr_get()
168 val->val2 = 0; in sm351lt_attr_get()
170 return -ENOTSUP; in sm351lt_attr_get()
173 return -ENOTSUP; in sm351lt_attr_get()
192 const struct sm351lt_config *const config = dev->config; in sm351lt_init()
195 if (!gpio_is_ready_dt(&config->int_gpio)) { in sm351lt_init()
197 return -ENODEV; in sm351lt_init()
200 ret = gpio_pin_configure_dt(&config->int_gpio, GPIO_INPUT); in sm351lt_init()
207 struct sm351lt_data *data = dev->data; in sm351lt_init()
208 data->dev = dev; in sm351lt_init()
211 k_sem_init(&data->gpio_sem, 0, K_SEM_MAX_LIMIT); in sm351lt_init()
213 k_thread_create(&data->thread, data->thread_stack, in sm351lt_init()
221 k_thread_name_set(&data->thread, dev->name); in sm351lt_init()
225 data->work.handler = sm351lt_work_cb; in sm351lt_init()
228 data->trigger_type = GPIO_INT_DISABLE; in sm351lt_init()
230 ret = gpio_pin_interrupt_configure_dt(&config->int_gpio, in sm351lt_init()
238 gpio_init_callback(&data->gpio_cb, sm351lt_gpio_callback, in sm351lt_init()
239 BIT(config->int_gpio.pin)); in sm351lt_init()
249 .int_gpio = GPIO_DT_SPEC_INST_GET(inst, gpios), \
262 /* Main instantiation macro for every configured device in DTS. */