Lines Matching +full:reg +full:- +full:rc
4 * SPDX-License-Identifier: Apache-2.0
13 #include <zephyr/dt-bindings/sensor/tmp116.h>
28 static int tmp116_reg_read(const struct device *dev, uint8_t reg, in tmp116_reg_read() argument
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()
43 static int tmp116_reg_write(const struct device *dev, uint8_t reg, in tmp116_reg_write() argument
46 const struct tmp116_dev_config *cfg = dev->config; in tmp116_reg_write()
47 uint8_t tx_buf[3] = {reg, val >> 8, val & 0xFF}; 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()
81 if (drv_data->id == TMP117_DEVICE_ID && in check_eeprom_bounds()
93 uint8_t reg; in tmp116_eeprom_write() local
98 return -EINVAL; in tmp116_eeprom_write()
106 for (reg = (offset / 2); reg < offset / 2 + len / 2; reg++) { in tmp116_eeprom_write()
109 res = tmp116_reg_write(dev, reg + TMP116_REG_EEPROM1, val); in tmp116_eeprom_write()
137 uint8_t reg; in tmp116_eeprom_read() local
142 return -EINVAL; in tmp116_eeprom_read()
145 for (reg = (offset / 2); reg < offset / 2 + len / 2; reg++) { in tmp116_eeprom_read()
146 res = tmp116_reg_read(dev, reg + TMP116_REG_EEPROM1, dst); 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()
189 int rc; in tmp116_sample_fetch() local
195 drv_data->sample = 0U; in tmp116_sample_fetch()
198 rc = tmp116_reg_read(dev, TMP116_REG_CFGR, &cfg_reg); in tmp116_sample_fetch()
199 if (rc < 0) { in tmp116_sample_fetch()
201 dev->name); in tmp116_sample_fetch()
202 return rc; in tmp116_sample_fetch()
206 LOG_DBG("%s: no data ready", dev->name); in tmp116_sample_fetch()
207 return -EBUSY; in tmp116_sample_fetch()
211 rc = tmp116_reg_read(dev, TMP116_REG_TEMP, &value); in tmp116_sample_fetch()
212 if (rc < 0) { in tmp116_sample_fetch()
214 dev->name); in tmp116_sample_fetch()
215 return rc; 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()
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()
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()
350 int rc; in tmp116_attr_get() local
353 return -ENOTSUP; in tmp116_attr_get()
358 rc = tmp116_reg_read(dev, TMP116_REG_CFGR, &data); in tmp116_attr_get()
359 if (rc < 0) { in tmp116_attr_get()
360 return rc; 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()
384 int rc; in tmp116_init() local
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()
393 rc = tmp116_device_id_check(dev, &id); in tmp116_init()
394 if (rc < 0) { in tmp116_init()
395 return rc; 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()
402 return rc; in tmp116_init()