Skip to content

Commit

Permalink
fuel_gauge: Implement sbs gauge read for mfr acc
Browse files Browse the repository at this point in the history
Implement and weakly test fetching the manufacturer access word from an SBS
compatible fuel gauge.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
  • Loading branch information
aaronemassey authored and carlescufi committed Jan 8, 2023
1 parent db60e08 commit c0762d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/fuel_gauge/sbs_gauge/sbs_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ static int sbs_gauge_get_prop(const struct device *dev, struct fuel_gauge_get_pr
rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_AVG_TIME2FULL, &val);
prop->value.runtime_to_empty = val;
break;
case FUEL_GAUGE_SBS_MFR_ACCESS:
rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_MANUFACTURER_ACCESS, &val);
prop->value.sbs_mfr_access_word = val;
break;
case FUEL_GAUGE_STATE_OF_CHARGE:
rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_ASOC, &val);
prop->value.state_of_charge = val;
Expand Down
1 change: 1 addition & 0 deletions subsys/emul/i2c/emul_sbs_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static int emul_sbs_gauge_reg_read(const struct emul *target, int reg, int *val)
ARG_UNUSED(target);

switch (reg) {
case SBS_GAUGE_CMD_MANUFACTURER_ACCESS:
case SBS_GAUGE_CMD_VOLTAGE:
case SBS_GAUGE_CMD_AVG_CURRENT:
case SBS_GAUGE_CMD_TEMP:
Expand Down
3 changes: 3 additions & 0 deletions tests/drivers/fuel_gauge/sbs_gauge/src/test_sbs_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ ZTEST_F(sbs_gauge_new_api, test_get_props__returns_ok)
{
.property_type = FUEL_GAUGE_CYCLE_COUNT,
},
{
.property_type = FUEL_GAUGE_SBS_MFR_ACCESS,
},
};

int ret = fixture->api->get_property(fixture->dev, props, ARRAY_SIZE(props));
Expand Down

0 comments on commit c0762d0

Please sign in to comment.