Lines Matching +full:temperature +full:- +full:format
4 * SPDX-License-Identifier: Apache-2.0
13 #include <zephyr/dt-bindings/sensor/tmp116.h>
31 const struct tmp116_dev_config *cfg = dev->config; in tmp116_reg_read()
33 if (i2c_burst_read_dt(&cfg->bus, reg, (uint8_t *)val, 2) in tmp116_reg_read()
35 return -EIO; in tmp116_reg_read()
46 const struct tmp116_dev_config *cfg = dev->config; in tmp116_reg_write()
49 return i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in tmp116_reg_write()
72 struct tmp116_data *drv_data = dev->data; in check_eeprom_bounds()
80 /* TMP117 uses EEPROM[2] as temperature offset register */ in check_eeprom_bounds()
81 if (drv_data->id == TMP117_DEVICE_ID && in check_eeprom_bounds()
98 return -EINVAL; in tmp116_eeprom_write()
142 return -EINVAL; in tmp116_eeprom_read()
164 * @retval -EIO Otherwise
170 dev->name); in tmp116_device_id_check()
171 return -EIO; in tmp116_device_id_check()
176 dev->name); in tmp116_device_id_check()
177 return -EINVAL; in tmp116_device_id_check()
186 struct tmp116_data *drv_data = dev->data; in tmp116_sample_fetch()
195 drv_data->sample = 0U; in tmp116_sample_fetch()
201 dev->name); in tmp116_sample_fetch()
206 LOG_DBG("%s: no data ready", dev->name); in tmp116_sample_fetch()
207 return -EBUSY; in tmp116_sample_fetch()
210 /* Get the most recent temperature measurement */ in tmp116_sample_fetch()
214 dev->name); in tmp116_sample_fetch()
219 drv_data->sample = (int16_t)value; in tmp116_sample_fetch()
228 struct tmp116_data *drv_data = dev->data; in tmp116_channel_get()
232 return -ENOTSUP; in tmp116_channel_get()
236 * See datasheet "Temperature Results and Limits" section for more in tmp116_channel_get()
239 tmp = ((int16_t)drv_data->sample * (int32_t)TMP116_RESOLUTION) / 10; in tmp116_channel_get()
240 val->val1 = tmp / 1000000; /* uCelsius */ in tmp116_channel_get()
241 val->val2 = tmp % 1000000; in tmp116_channel_get()
269 return -EINVAL; in tmp116_conv_value()
278 struct tmp116_data *drv_data = dev->data; in tmp116_attr_set()
283 return -ENOTSUP; in tmp116_attr_set()
296 if (drv_data->id != TMP117_DEVICE_ID) { in tmp116_attr_set()
298 dev->name); in tmp116_attr_set()
299 return -EINVAL; in tmp116_attr_set()
302 * The offset is encoded into the temperature register format. in tmp116_attr_set()
304 value = (((val->val1) * 10000000) + ((val->val2) * 10)) in tmp116_attr_set()
311 switch (val->val1) { in tmp116_attr_set()
329 return -EINVAL; in tmp116_attr_set()
342 return -ENOTSUP; in tmp116_attr_set()
353 return -ENOTSUP; in tmp116_attr_get()
364 return -ENOTSUP; in tmp116_attr_get()
367 val->val1 = data; in tmp116_attr_get()
368 val->val2 = 0; in tmp116_attr_get()
382 struct tmp116_data *drv_data = dev->data; in tmp116_init()
383 const struct tmp116_dev_config *cfg = dev->config; in tmp116_init()
387 if (!device_is_ready(cfg->bus.bus)) { in tmp116_init()
388 LOG_ERR("I2C dev %s not ready", cfg->bus.bus->name); in tmp116_init()
389 return -EINVAL; in tmp116_init()
398 drv_data->id = id; in tmp116_init()
400 rc = tmp116_write_config(dev, TMP116_CFGR_CONV, cfg->odr); in tmp116_init()