Lines Matching +full:sbs +full:- +full:compliant
4 * SPDX-License-Identifier: Apache-2.0
6 * Emulator for SBS 1.1 compliant smart battery charger.
28 /** Run-time data used by the emulator */
35 struct sbs_charger_emul_data *data = target->data; in emul_sbs_charger_reg_write()
40 data->reg_charger_mode = val; in emul_sbs_charger_reg_write()
44 return -EIO; in emul_sbs_charger_reg_write()
62 return -EIO; in emul_sbs_charger_reg_read()
78 data = target->data; in sbs_charger_emul_transfer_i2c()
80 i2c_dump_msgs_rw(target->dev, msgs, num_msgs, addr, false); in sbs_charger_emul_transfer_i2c()
83 if (msgs->flags & I2C_MSG_READ) { in sbs_charger_emul_transfer_i2c()
85 return -EIO; in sbs_charger_emul_transfer_i2c()
87 if (msgs->len != 1) { in sbs_charger_emul_transfer_i2c()
88 LOG_ERR("Unexpected msg0 length %d", msgs->len); in sbs_charger_emul_transfer_i2c()
89 return -EIO; in sbs_charger_emul_transfer_i2c()
91 reg = msgs->buf[0]; in sbs_charger_emul_transfer_i2c()
95 if (msgs->flags & I2C_MSG_READ) { in sbs_charger_emul_transfer_i2c()
96 switch (msgs->len - 1) { in sbs_charger_emul_transfer_i2c()
104 /* SBS uses SMBus, which sends data in little-endian format. */ in sbs_charger_emul_transfer_i2c()
105 sys_put_le16(val, msgs->buf); in sbs_charger_emul_transfer_i2c()
108 LOG_ERR("Unexpected msg1 length %d", msgs->len); in sbs_charger_emul_transfer_i2c()
109 return -EIO; in sbs_charger_emul_transfer_i2c()
112 /* We write a word (2 bytes by the SBS spec) */ in sbs_charger_emul_transfer_i2c()
113 if (msgs->len != 2) { in sbs_charger_emul_transfer_i2c()
114 LOG_ERR("Unexpected msg1 length %d", msgs->len); in sbs_charger_emul_transfer_i2c()
116 uint16_t value = sys_get_le16(msgs->buf); in sbs_charger_emul_transfer_i2c()
123 return -EIO; in sbs_charger_emul_transfer_i2c()
142 * Main instantiation macro. SBS Charger Emulator only implemented for I2C