Lines Matching +full:divide +full:- +full:10

1 /* max17048.c - Driver for max17048 battery fuel gauge */
6 * SPDX-License-Identifier: Apache-2.0
52 const struct max17048_config *cfg = dev->config; in max17048_read_register()
53 int rc = i2c_write_read_dt(&cfg->i2c, &registerId, sizeof(registerId), max17048_buffer, in max17048_read_register()
85 * https://www.analog.com/media/en/technical-documentation/data-sheets/ in max17048_voltage()
86 * MAX17048-MAX17049.pdf in max17048_voltage()
87 * Page 10, Table 2. Register Summary: 78.125µV/cell in max17048_voltage()
109 * https://www.analog.com/media/en/technical-documentation/data-she4ets/ in max17048_percent()
110 * MAX17048-MAX17049.pdf in max17048_percent()
111 * Page 10, Table 2. Register Summary: 1%/256 in max17048_percent()
112 * So to obtain the total percentaje we just divide the read value by 256 in max17048_percent()
132 * https://www.analog.com/media/en/technical-documentation/data-sheets/ in max17048_crate()
133 * MAX17048-MAX17049.pdf in max17048_crate()
148 const struct max17048_config *cfg = dev->config; in max17048_init()
152 if (!device_is_ready(cfg->i2c.bus)) { in max17048_init()
154 return -ENODEV; in max17048_init()
168 return -ENODEV; in max17048_init()
180 struct max17048_data *data = dev->data; in max17048_get_single_prop_impl()
185 val->runtime_to_empty = data->time_to_empty; in max17048_get_single_prop_impl()
188 val->runtime_to_full = data->time_to_full; in max17048_get_single_prop_impl()
191 val->relative_state_of_charge = data->charge; in max17048_get_single_prop_impl()
194 val->voltage = data->voltage; in max17048_get_single_prop_impl()
197 rc = -ENOTSUP; in max17048_get_single_prop_impl()
209 struct max17048_data *data = dev->data; in max17048_get_prop()
210 int rc = max17048_percent(dev, &data->charge); in max17048_get_prop()
219 rc = max17048_voltage(dev, &data->voltage); in max17048_get_prop()
241 data->charging = crate > 0; in max17048_get_prop()
253 if (data->charging) { in max17048_get_prop()
254 uint8_t percentage_pending = 100 - data->charge; in max17048_get_prop()
257 data->time_to_empty = 0; in max17048_get_prop()
258 data->time_to_full = hours_pending * 60 / 1000; in max17048_get_prop()
261 uint32_t hours_pending = data->charge * 1000000 / -crate; in max17048_get_prop()
263 data->time_to_empty = hours_pending * 60 / 1000; in max17048_get_prop()
264 data->time_to_full = 0; in max17048_get_prop()
272 data->charging = false; in max17048_get_prop()
273 data->time_to_full = 0; in max17048_get_prop()
274 data->time_to_empty = 0; in max17048_get_prop()