Lines Matching +full:conversion +full:- +full:rate

4  * SPDX-License-Identifier: Apache-2.0
24 if (i2c_burst_read_dt(&cfg->bus, reg, (uint8_t *)val, sizeof(*val)) < 0) { in tmp112_reg_read()
25 return -EIO; in tmp112_reg_read()
41 return i2c_write_dt(&cfg->bus, buf, sizeof(buf)); in tmp112_reg_write()
47 return (data->config_reg & ~mask) | (value & mask); in set_config_flags()
54 struct tmp112_data *data = dev->data; in tmp112_update_config()
57 rc = tmp112_reg_write(dev->config, TMP112_REG_CONFIG, new_val); in tmp112_update_config()
59 data->config_reg = new_val; in tmp112_update_config()
74 return -ENOTSUP; in tmp112_attr_set()
80 /* the sensor supports two ranges -55 to 128 and -55 to 150 */ in tmp112_attr_set()
82 if (val->val1 == 128) { in tmp112_attr_set()
84 } else if (val->val1 == 150) { in tmp112_attr_set()
87 return -ENOTSUP; in tmp112_attr_set()
92 return -EIO; in tmp112_attr_set()
98 /* conversion rate in mHz */ in tmp112_attr_set()
99 cr = val->val1 * 1000 + val->val2 / 1000; in tmp112_attr_set()
102 /* conversion rate */ in tmp112_attr_set()
121 return -ENOTSUP; in tmp112_attr_set()
126 return -EIO; in tmp112_attr_set()
133 return -ENOTSUP; in tmp112_attr_set()
142 struct tmp112_data *drv_data = dev->data; in tmp112_sample_fetch()
143 const struct tmp112_config *cfg = dev->config; in tmp112_sample_fetch()
149 return -EIO; in tmp112_sample_fetch()
153 drv_data->sample = arithmetic_shift_right((int16_t)val, in tmp112_sample_fetch()
156 drv_data->sample = arithmetic_shift_right((int16_t)val, in tmp112_sample_fetch()
167 struct tmp112_data *drv_data = dev->data; in tmp112_channel_get()
171 return -ENOTSUP; in tmp112_channel_get()
174 uval = (int32_t)drv_data->sample * TMP112_TEMP_SCALE; in tmp112_channel_get()
175 val->val1 = uval / 1000000; in tmp112_channel_get()
176 val->val2 = uval % 1000000; in tmp112_channel_get()
189 const struct tmp112_config *cfg = dev->config; in tmp112_init()
190 struct tmp112_data *data = dev->data; in tmp112_init()
192 if (!device_is_ready(cfg->bus.bus)) { in tmp112_init()
193 LOG_ERR("I2C dev %s not ready", cfg->bus.bus->name); in tmp112_init()
194 return -EINVAL; in tmp112_init()
197 data->config_reg = TMP112_CONV_RATE(cfg->cr) | TMP112_CONV_RES_MASK in tmp112_init()
198 | (cfg->extended_mode ? TMP112_CONFIG_EM : 0); in tmp112_init()