Lines Matching +full:i2c +full:- +full:errors

4  * SPDX-License-Identifier: Apache-2.0
10 #include <zephyr/drivers/i2c.h>
35 const struct sgp40_config *cfg = dev->config; in sgp40_write_command()
40 return i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in sgp40_write_command()
45 const struct sgp40_config *cfg = dev->config; in sgp40_start_measurement()
46 struct sgp40_data *data = dev->data; in sgp40_start_measurement()
50 sys_put_be24(sys_get_be24(data->rh_param), &tx_buf[2]); in sgp40_start_measurement()
51 sys_put_be24(sys_get_be24(data->t_param), &tx_buf[5]); in sgp40_start_measurement()
53 return i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in sgp40_start_measurement()
61 struct sgp40_data *data = dev->data; in sgp40_attr_set()
65 * in section "I2C commands" in sgp40_attr_set()
74 tmp = (int16_t)CLAMP(val->val1, SGP40_COMP_MIN_T, SGP40_COMP_MAX_T); in sgp40_attr_set()
75 /* adding +87 to avoid most rounding errors through truncation */ in sgp40_attr_set()
77 sys_put_be16(t_ticks, data->t_param); in sgp40_attr_set()
78 data->t_param[2] = sgp40_compute_crc(t_ticks); in sgp40_attr_set()
86 tmp = (uint8_t)CLAMP(val->val1, SGP40_COMP_MIN_RH, SGP40_COMP_MAX_RH); in sgp40_attr_set()
87 /* adding +50 to eliminate rounding errors through truncation */ in sgp40_attr_set()
89 sys_put_be16(rh_ticks, data->rh_param); in sgp40_attr_set()
90 data->rh_param[2] = sgp40_compute_crc(rh_ticks); in sgp40_attr_set()
94 return -ENOTSUP; in sgp40_attr_set()
101 const struct sgp40_config *cfg = dev->config; in sgp40_selftest()
114 rc = i2c_read_dt(&cfg->bus, rx_buf, sizeof(rx_buf)); in sgp40_selftest()
123 return -EIO; in sgp40_selftest()
128 return -EIO; in sgp40_selftest()
137 struct sgp40_data *data = dev->data; in sgp40_sample_fetch()
138 const struct sgp40_config *cfg = dev->config; in sgp40_sample_fetch()
144 return -ENOTSUP; in sgp40_sample_fetch()
155 rc = i2c_read_dt(&cfg->bus, rx_buf, sizeof(rx_buf)); in sgp40_sample_fetch()
164 return -EIO; in sgp40_sample_fetch()
167 data->raw_sample = raw_sample; in sgp40_sample_fetch()
176 const struct sgp40_data *data = dev->data; in sgp40_channel_get()
179 return -ENOTSUP; in sgp40_channel_get()
182 val->val1 = data->raw_sample; in sgp40_channel_get()
183 val->val2 = 0; in sgp40_channel_get()
204 return -ENOTSUP; in sgp40_pm_action()
213 const struct sgp40_config *cfg = dev->config; in sgp40_init()
216 if (!device_is_ready(cfg->bus.bus)) { in sgp40_init()
218 return -ENODEV; in sgp40_init()
221 if (cfg->selftest) { in sgp40_init()