Lines Matching +full:divide +full:- +full:10
5 * SPDX-License-Identifier: Apache-2.0
24 * enabled lm75 devicetree node has the int-gpios property.
71 const struct lm75_config *cfg = dev->config; in lm75_reg_read()
73 return i2c_burst_read_dt(&cfg->i2c, reg, buf, size); in lm75_reg_read()
79 const struct lm75_config *cfg = dev->config; in lm75_reg_write()
81 return i2c_burst_write_dt(&cfg->i2c, reg, buf, size); in lm75_reg_write()
92 return -EIO; in lm75_temp_read()
110 *temp = val->val1 * 10; in lm75_sensor_value_to_temp()
111 *temp += val->val2 / 100000U; in lm75_sensor_value_to_temp()
113 *temp = (*temp * 256) / 10; in lm75_sensor_value_to_temp()
118 /* shift right by 7, multiply by 10 to get 0.1° and divide by 2 to get °C */ in lm75_temp_to_sensor_value()
119 temp = (temp / 128) * 10 / 2; in lm75_temp_to_sensor_value()
122 val->val1 = temp / 10; in lm75_temp_to_sensor_value()
125 val->val2 = (temp - val->val1 * 10) * 100000U; in lm75_temp_to_sensor_value()
138 return -ENOTSUP; in lm75_attr_set()
149 return -ENOTSUP; in lm75_attr_set()
173 return -ENOTSUP; in lm75_attr_get()
184 return -ENOTSUP; in lm75_attr_get()
202 const struct lm75_config *config = dev->config; in lm75_trigger_set()
203 struct lm75_data *data = dev->data; in lm75_trigger_set()
209 if (trig->type != SENSOR_TRIG_THRESHOLD || trig->chan != SENSOR_CHAN_AMBIENT_TEMP || in lm75_trigger_set()
210 config->int_gpio.port == NULL) { in lm75_trigger_set()
211 return -ENOTSUP; in lm75_trigger_set()
220 err = gpio_pin_interrupt_configure_dt(&config->int_gpio, flags); in lm75_trigger_set()
226 data->trigger = trig; in lm75_trigger_set()
227 data->trigger_handler = handler; in lm75_trigger_set()
235 sensor_trigger_handler_t handler = data->trigger_handler; in lm75_trigger_work_handler()
238 handler(data->dev, (struct sensor_trigger *)data->trigger); in lm75_trigger_work_handler()
250 k_work_submit_to_queue(&data->workq, &data->work); in lm75_int_gpio_callback_handler()
256 struct lm75_data *data = dev->data; in lm75_fetch_temp()
263 return -EIO; in lm75_fetch_temp()
266 data->temp = temp; in lm75_fetch_temp()
278 ret = -EIO; in lm75_sample_fetch()
288 ret = -ENOTSUP; in lm75_sample_fetch()
298 struct lm75_data *data = dev->data; in lm75_channel_get()
302 lm75_temp_to_sensor_value(data->temp, val); in lm75_channel_get()
305 return -ENOTSUP; in lm75_channel_get()
321 const struct lm75_config *cfg = dev->config; in lm75_init()
324 struct lm75_data *data = dev->data; in lm75_init()
327 if (!device_is_ready(cfg->i2c.bus)) { in lm75_init()
329 return -ENODEV; in lm75_init()
336 if (ret < 0 && ret != -ENOTSUP) { in lm75_init()
342 ret = lm75_reg_write(dev, LM75_REG_CONFIG, &cfg->config_dt.reg, sizeof(cfg->config_dt.reg)); in lm75_init()
352 if (cfg->int_gpio.port != NULL) { in lm75_init()
354 data->dev = dev; in lm75_init()
355 k_work_queue_start(&data->workq, data->stack, K_THREAD_STACK_SIZEOF(data->stack), in lm75_init()
357 k_thread_name_set(&data->workq.thread, "lm75_trigger"); in lm75_init()
358 k_work_init(&data->work, lm75_trigger_work_handler); in lm75_init()
360 if (!device_is_ready(cfg->int_gpio.port)) { in lm75_init()
362 return -EINVAL; in lm75_init()
365 ret = gpio_pin_configure_dt(&cfg->int_gpio, GPIO_INPUT); in lm75_init()
371 gpio_init_callback(&data->int_gpio_cb, lm75_int_gpio_callback_handler, in lm75_init()
372 BIT(cfg->int_gpio.pin)); in lm75_init()
374 ret = gpio_add_callback(cfg->int_gpio.port, &data->int_gpio_cb); in lm75_init()
396 return -ENOTSUP; in lm75_pm_action()