Lines Matching +full:reg +full:- +full:rc
4 * SPDX-License-Identifier: Apache-2.0
41 static int tmp114_reg_read(const struct device *dev, uint8_t reg, in tmp114_reg_read() argument
44 const struct tmp114_dev_config *cfg = dev->config; in tmp114_reg_read()
46 if (i2c_burst_read_dt(&cfg->bus, reg, (uint8_t *)val, 2) in tmp114_reg_read()
48 return -EIO; in tmp114_reg_read()
56 static int tmp114_reg_write(const struct device *dev, uint8_t reg, in tmp114_reg_write() argument
59 const struct tmp114_dev_config *cfg = dev->config; in tmp114_reg_write()
60 uint8_t tx_buf[3] = {reg, val >> 8, val & 0xFF}; in tmp114_reg_write()
62 return i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in tmp114_reg_write()
68 LOG_ERR("%s: Failed to get Device ID register!", dev->name); in tmp114_device_id_check()
69 return -EIO; in tmp114_device_id_check()
73 LOG_ERR("%s: Failed to match the device ID!", dev->name); in tmp114_device_id_check()
74 return -EINVAL; in tmp114_device_id_check()
83 struct tmp114_data *drv_data = dev->data; in tmp114_sample_fetch()
86 int rc; in tmp114_sample_fetch() local
92 drv_data->sample = 0U; in tmp114_sample_fetch()
95 rc = tmp114_reg_read(dev, TMP114_REG_ALERT, &cfg_reg); in tmp114_sample_fetch()
96 if (rc < 0) { in tmp114_sample_fetch()
97 LOG_ERR("%s, Failed to read from CFGR register", dev->name); in tmp114_sample_fetch()
98 return rc; in tmp114_sample_fetch()
102 LOG_DBG("%s: no data ready", dev->name); in tmp114_sample_fetch()
103 return -EBUSY; in tmp114_sample_fetch()
107 rc = tmp114_reg_read(dev, TMP114_REG_TEMP, &value); in tmp114_sample_fetch()
108 if (rc < 0) { in tmp114_sample_fetch()
109 LOG_ERR("%s: Failed to read from TEMP register!", dev->name); in tmp114_sample_fetch()
110 return rc; in tmp114_sample_fetch()
114 drv_data->sample = (int16_t)value; in tmp114_sample_fetch()
123 struct tmp114_data *drv_data = dev->data; in tmp114_channel_get()
127 return -ENOTSUP; in tmp114_channel_get()
134 tmp = ((int16_t)drv_data->sample * (int32_t)TMP114_RESOLUTION) / 10; in tmp114_channel_get()
135 val->val1 = tmp / 1000000; /* uCelsius */ in tmp114_channel_get()
136 val->val2 = tmp % 1000000; in tmp114_channel_get()
145 int rc; in tmp114_attr_get() local
148 return -ENOTSUP; in tmp114_attr_get()
153 rc = tmp114_reg_read(dev, TMP114_REG_CFGR, &data); in tmp114_attr_get()
154 if (rc < 0) { in tmp114_attr_get()
155 return rc; in tmp114_attr_get()
159 return -ENOTSUP; in tmp114_attr_get()
162 val->val1 = data; in tmp114_attr_get()
163 val->val2 = 0; in tmp114_attr_get()
174 int rc; in tmp114_attr_set() local
177 return -ENOTSUP; in tmp114_attr_set()
185 rc = tmp114_reg_read(dev, TMP114_REG_CFGR, &value); in tmp114_attr_set()
186 if (rc < 0) { in tmp114_attr_set()
187 return rc; in tmp114_attr_set()
190 if (val->val1) { in tmp114_attr_set()
196 return -ENOTSUP; in tmp114_attr_set()
209 struct tmp114_data *drv_data = dev->data; in tmp114_init()
210 const struct tmp114_dev_config *cfg = dev->config; in tmp114_init()
211 int rc; in tmp114_init() local
214 if (!i2c_is_ready_dt(&cfg->bus)) { in tmp114_init()
215 LOG_ERR("I2C dev %s not ready", cfg->bus.bus->name); in tmp114_init()
216 return -EINVAL; in tmp114_init()
220 rc = tmp114_device_id_check(dev, &id); in tmp114_init()
221 if (rc < 0) { in tmp114_init()
222 return rc; in tmp114_init()
225 drv_data->id = id; in tmp114_init()