Lines Matching +full:reg +full:- +full:rc
1 /* mpr.c - Driver for Honeywell MPR pressure sensor series */
6 * SPDX-License-Identifier: Apache-2.0
26 const struct mpr_config *cfg = dev->config; in mpr_init()
28 if (!device_is_ready(cfg->i2c.bus)) { in mpr_init()
30 return -ENODEV; in mpr_init()
38 struct mpr_data *data = dev->data; in mpr_read_reg()
39 const struct mpr_config *cfg = dev->config; in mpr_read_reg()
44 int rc = i2c_write_dt(&cfg->i2c, write_buf, sizeof(write_buf)); in mpr_read_reg() local
46 if (rc < 0) { in mpr_read_reg()
47 return rc; in mpr_read_reg()
52 for (; retries > 0; retries--) { in mpr_read_reg()
55 rc = i2c_read_dt(&cfg->i2c, read_buf, sizeof(read_buf)); in mpr_read_reg()
56 if (rc < 0) { in mpr_read_reg()
57 return rc; in mpr_read_reg()
63 return -EIO; in mpr_read_reg()
72 return -EIO; in mpr_read_reg()
75 data->reg_val = (read_buf[1] << 16) in mpr_read_reg()
82 /* (reg_value - out_min) * (p_max - p_min)
83 * pressure = --------------------------------------- + p_min
84 * out_max - out_min
88 static inline void mpr_convert_reg(const uint32_t *reg, uint64_t *value) in mpr_convert_reg() argument
90 if (*reg > MPR_OUTPUT_MIN) { in mpr_convert_reg()
91 *value = (uint64_t)(*reg - MPR_OUTPUT_MIN) * (MPR_P_MAX - MPR_P_MIN); in mpr_convert_reg()
112 const struct mpr_data *data = dev->data; in mpr_channel_get()
117 return -ENOTSUP; in mpr_channel_get()
122 mpr_convert_reg(&data->reg_val, &value); in mpr_channel_get()
124 val->val1 = value / 1000000; in mpr_channel_get()
125 val->val2 = value % 1000000; in mpr_channel_get()