Lines Matching +full:reg +full:- +full:rc

5  * SPDX-License-Identifier: Apache-2.0
25 static int bq27z746_read16(const struct device *dev, uint8_t reg, uint16_t *value) in bq27z746_read16() argument
28 const struct bq27z746_config *cfg = dev->config; in bq27z746_read16()
29 const int status = i2c_burst_read_dt(&cfg->i2c, reg, i2c_data, sizeof(i2c_data)); in bq27z746_read16()
40 static int bq27z746_write16(const struct device *dev, uint8_t reg, uint16_t value) in bq27z746_write16() argument
43 const struct bq27z746_config *cfg = dev->config; in bq27z746_write16()
45 buf[0] = reg; in bq27z746_write16()
48 return i2c_write_dt(&cfg->i2c, buf, sizeof(buf)); in bq27z746_write16()
54 return -EINVAL; in bq27z746_read_mac()
58 const struct bq27z746_config *cfg = dev->config; in bq27z746_read_mac()
71 * 34: Checksum calculated as (uint8_t)(0xFF - (sum of all command and data bytes)) in bq27z746_read_mac()
75 ret = i2c_burst_read_dt(&cfg->i2c, BQ27Z746_ALTMANUFACTURERACCESS, buf, in bq27z746_read_mac()
86 return -EIO; in bq27z746_read_mac()
92 for (int i = 0; i < BQ27Z746_MAC_COMPLETE_LEN - 2; i++) { in bq27z746_read_mac()
96 const uint8_t checksum_expected = 0xFF - sum; in bq27z746_read_mac()
100 return -EIO; in bq27z746_read_mac()
104 data[0] = buf[35] - BQ27Z746_MAC_OVERHEAD_LEN; in bq27z746_read_mac()
115 int rc = 0; in bq27z746_get_prop() local
125 rc = bq27z746_read16(dev, BQ27Z746_AVERAGECURRENT, &tmp_val); in bq27z746_get_prop()
126 val->avg_current = (int16_t)tmp_val * 1000; in bq27z746_get_prop()
129 rc = bq27z746_read16(dev, BQ27Z746_CYCLECOUNT, &tmp_val); in bq27z746_get_prop()
130 val->cycle_count = tmp_val * 100; in bq27z746_get_prop()
133 rc = bq27z746_read16(dev, BQ27Z746_CURRENT, &tmp_val); in bq27z746_get_prop()
134 val->current = (int16_t)tmp_val * 1000; in bq27z746_get_prop()
137 rc = bq27z746_read16(dev, BQ27Z746_FULLCHARGECAPACITY, &tmp_val); in bq27z746_get_prop()
138 val->full_charge_capacity = tmp_val * 1000; in bq27z746_get_prop()
141 rc = bq27z746_read16(dev, BQ27Z746_REMAININGCAPACITY, &tmp_val); in bq27z746_get_prop()
142 val->remaining_capacity = tmp_val * 1000; in bq27z746_get_prop()
145 rc = bq27z746_read16(dev, BQ27Z746_AVERAGETIMETOEMPTY, &tmp_val); in bq27z746_get_prop()
146 val->runtime_to_empty = tmp_val; in bq27z746_get_prop()
149 rc = bq27z746_read16(dev, BQ27Z746_AVERAGETIMETOFULL, &tmp_val); in bq27z746_get_prop()
150 val->runtime_to_full = tmp_val; in bq27z746_get_prop()
153 rc = bq27z746_read16(dev, BQ27Z746_MANUFACTURERACCESS, &tmp_val); in bq27z746_get_prop()
154 val->sbs_mfr_access_word = tmp_val; in bq27z746_get_prop()
157 rc = bq27z746_read16(dev, BQ27Z746_RELATIVESTATEOFCHARGE, &tmp_val); in bq27z746_get_prop()
158 val->relative_state_of_charge = tmp_val; in bq27z746_get_prop()
161 rc = bq27z746_read16(dev, BQ27Z746_TEMPERATURE, &tmp_val); in bq27z746_get_prop()
162 val->temperature = tmp_val; in bq27z746_get_prop()
165 rc = bq27z746_read16(dev, BQ27Z746_VOLTAGE, &tmp_val); in bq27z746_get_prop()
166 val->voltage = tmp_val * 1000; in bq27z746_get_prop()
169 rc = bq27z746_read16(dev, BQ27Z746_ATRATE, &tmp_val); in bq27z746_get_prop()
170 val->sbs_at_rate = (int16_t)tmp_val; in bq27z746_get_prop()
173 rc = bq27z746_read16(dev, BQ27Z746_ATRATETIMETOEMPTY, &tmp_val); in bq27z746_get_prop()
174 val->sbs_at_rate_time_to_empty = tmp_val; in bq27z746_get_prop()
177 rc = bq27z746_read16(dev, BQ27Z746_CHARGINGVOLTAGE, &tmp_val); in bq27z746_get_prop()
178 val->chg_voltage = tmp_val * 1000; in bq27z746_get_prop()
181 rc = bq27z746_read16(dev, BQ27Z746_CHARGINGCURRENT, &tmp_val); in bq27z746_get_prop()
182 val->chg_current = tmp_val * 1000; in bq27z746_get_prop()
185 rc = bq27z746_read16(dev, BQ27Z746_BATTERYSTATUS, &tmp_val); in bq27z746_get_prop()
186 val->fg_status = tmp_val; in bq27z746_get_prop()
189 rc = bq27z746_read16(dev, BQ27Z746_DESIGNCAPACITY, &tmp_val); in bq27z746_get_prop()
190 val->design_cap = tmp_val; in bq27z746_get_prop()
193 rc = -ENOTSUP; in bq27z746_get_prop()
196 return rc; in bq27z746_get_prop()
203 int rc = 0; in bq27z746_get_buffer_prop() local
208 rc = bq27z746_read_mac(dev, BQ27Z746_MAC_CMD_MANUFACTURER_NAME, in bq27z746_get_buffer_prop()
209 (uint8_t *)dst, dst_len - 1); in bq27z746_get_buffer_prop()
211 rc = -EINVAL; in bq27z746_get_buffer_prop()
216 rc = bq27z746_read_mac(dev, BQ27Z746_MAC_CMD_DEVICE_NAME, (uint8_t *)dst, in bq27z746_get_buffer_prop()
217 dst_len - 1); in bq27z746_get_buffer_prop()
219 rc = -EINVAL; in bq27z746_get_buffer_prop()
224 rc = bq27z746_read_mac(dev, BQ27Z746_MAC_CMD_DEVICE_CHEM, (uint8_t *)dst, in bq27z746_get_buffer_prop()
225 dst_len - 1); in bq27z746_get_buffer_prop()
227 rc = -EINVAL; in bq27z746_get_buffer_prop()
231 rc = -ENOTSUP; in bq27z746_get_buffer_prop()
234 return rc; in bq27z746_get_buffer_prop()
240 int rc = 0; in bq27z746_set_prop() local
245 rc = bq27z746_write16(dev, BQ27Z746_MANUFACTURERACCESS, val.sbs_mfr_access_word); in bq27z746_set_prop()
249 rc = bq27z746_write16(dev, BQ27Z746_ATRATE, val.sbs_at_rate); in bq27z746_set_prop()
253 rc = -ENOTSUP; in bq27z746_set_prop()
256 return rc; in bq27z746_set_prop()
263 cfg = dev->config; in bq27z746_init()
265 if (!device_is_ready(cfg->i2c.bus)) { in bq27z746_init()
267 return -ENODEV; in bq27z746_init()