Lines Matching +full:in +full:- +full:trig +full:- +full:gpios
4 * SPDX-License-Identifier: Apache-2.0
20 * Only compile in trigger support if enabled in Kconfig and at least one
21 * enabled lm77 devicetree node has the int-gpios property.
71 const struct lm77_config *config = dev->config; in lm77_write_config()
74 return i2c_write_dt(&config->i2c, buf, sizeof(buf)); in lm77_write_config()
79 const struct lm77_config *config = dev->config; in lm77_read_temp()
83 err = i2c_write_read_dt(&config->i2c, ®, sizeof(reg), &buf, sizeof(buf)); in lm77_read_temp()
96 const struct lm77_config *config = dev->config; in lm77_write_temp()
99 return i2c_write_dt(&config->i2c, buf, sizeof(buf)); in lm77_write_temp()
104 /* Integer part in degrees Celsius (LSB = 0.5 degrees Celsius) */ in lm77_sensor_value_to_temp()
105 *temp = val->val1 << 1; in lm77_sensor_value_to_temp()
107 /* Fractional part in micro degrees Celsius */ in lm77_sensor_value_to_temp()
108 *temp += (val->val2 * 2) / 1000000; in lm77_sensor_value_to_temp()
119 /* Integer part in degrees Celsius */ in lm77_temp_to_sensor_value()
120 val->val1 = temp / 10; in lm77_temp_to_sensor_value()
122 /* Fractional part in micro degrees Celsius */ in lm77_temp_to_sensor_value()
123 val->val2 = temp % 10; in lm77_temp_to_sensor_value()
124 val->val2 *= 100000; in lm77_temp_to_sensor_value()
137 return -ENOTSUP; in lm77_attr_set()
154 return -ENOTSUP; in lm77_attr_set()
178 return -ENOTSUP; in lm77_attr_get()
195 return -ENOTSUP; in lm77_attr_get()
210 static int lm77_trigger_set(const struct device *dev, const struct sensor_trigger *trig, in lm77_trigger_set() argument
213 const struct lm77_config *config = dev->config; in lm77_trigger_set()
214 struct lm77_data *data = dev->data; in lm77_trigger_set()
218 __ASSERT_NO_MSG(trig != NULL); in lm77_trigger_set()
220 if (trig->type != SENSOR_TRIG_THRESHOLD || trig->chan != SENSOR_CHAN_AMBIENT_TEMP || in lm77_trigger_set()
221 config->int_gpio.port == NULL) { in lm77_trigger_set()
222 return -ENOTSUP; in lm77_trigger_set()
231 err = gpio_pin_interrupt_configure_dt(&config->int_gpio, flags); in lm77_trigger_set()
237 data->trigger = trig; in lm77_trigger_set()
238 data->trigger_handler = handler; in lm77_trigger_set()
246 sensor_trigger_handler_t handler = data->trigger_handler; in lm77_trigger_work_handler()
249 handler(data->dev, (struct sensor_trigger *)data->trigger); in lm77_trigger_work_handler()
262 k_work_submit_to_queue(&data->workq, &data->work); in lm77_int_gpio_callback_handler()
268 struct lm77_data *data = dev->data; in lm77_sample_fetch()
273 return -ENOTSUP; in lm77_sample_fetch()
282 data->temp = temp; in lm77_sample_fetch()
290 struct lm77_data *data = dev->data; in lm77_channel_get()
293 return -ENOTSUP; in lm77_channel_get()
296 lm77_temp_to_sensor_value(data->temp, val); in lm77_channel_get()
313 const struct lm77_config *config = dev->config; in lm77_init()
316 struct lm77_data *data = dev->data; in lm77_init()
319 if (!device_is_ready(config->i2c.bus)) { in lm77_init()
321 return -EINVAL; in lm77_init()
324 err = lm77_write_config(dev, config->config_dt.reg); in lm77_init()
331 data->dev = dev; in lm77_init()
332 k_work_queue_start(&data->workq, data->stack, K_THREAD_STACK_SIZEOF(data->stack), in lm77_init()
334 k_thread_name_set(&data->workq.thread, "lm77_trigger"); in lm77_init()
335 k_work_init(&data->work, lm77_trigger_work_handler); in lm77_init()
337 if (config->int_gpio.port != NULL) { in lm77_init()
338 if (!gpio_is_ready_dt(&config->int_gpio)) { in lm77_init()
340 return -EINVAL; in lm77_init()
343 err = gpio_pin_configure_dt(&config->int_gpio, GPIO_INPUT); in lm77_init()
349 gpio_init_callback(&data->int_gpio_cb, lm77_int_gpio_callback_handler, in lm77_init()
350 BIT(config->int_gpio.pin)); in lm77_init()
352 err = gpio_add_callback(config->int_gpio.port, &data->int_gpio_cb); in lm77_init()
367 const struct lm77_config *config = dev->config; in lm77_pm_action()
368 union lm77_reg_config creg = config->config_dt; in lm77_pm_action()
379 return -ENOTSUP; in lm77_pm_action()