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

5  * SPDX-License-Identifier: Apache-2.0
43 const struct bq27z746_emul_data *data = target->data; in emul_bq27z746_read_altmac()
48 return -EIO; in emul_bq27z746_read_altmac()
57 * 34: Checksum calculated as (uint8_t)(0xFF - (sum of all command and data bytes)) in emul_bq27z746_read_altmac()
62 sys_put_le16(data->mac_cmd, buf); in emul_bq27z746_read_altmac()
65 /* In all of the operations, don't consider the zero-terminator. */ in emul_bq27z746_read_altmac()
66 switch (data->mac_cmd) { in emul_bq27z746_read_altmac()
68 memcpy(&buf[2], manufacturer_name, sizeof(manufacturer_name) - 1); in emul_bq27z746_read_altmac()
69 buf[35] = sizeof(manufacturer_name) - 1 + BQ27Z746_MAC_OVERHEAD_LEN; in emul_bq27z746_read_altmac()
72 memcpy(&buf[2], device_name, sizeof(device_name) - 1); in emul_bq27z746_read_altmac()
73 buf[35] = sizeof(device_name) - 1 + BQ27Z746_MAC_OVERHEAD_LEN; in emul_bq27z746_read_altmac()
76 memcpy(&buf[2], device_chemistry, sizeof(device_chemistry) - 1); in emul_bq27z746_read_altmac()
77 buf[35] = sizeof(device_chemistry) - 1 + BQ27Z746_MAC_OVERHEAD_LEN; in emul_bq27z746_read_altmac()
80 LOG_ERR("ALTMAC command 0x%x is not supported", data->mac_cmd); in emul_bq27z746_read_altmac()
81 return -EIO; in emul_bq27z746_read_altmac()
87 for (int i = 0; i < BQ27Z746_MAC_COMPLETE_LEN - 2; i++) { in emul_bq27z746_read_altmac()
90 buf[34] = 0xFF - sum; in emul_bq27z746_read_altmac()
97 struct bq27z746_emul_data *data = target->data; in emul_bq27z746_write()
98 const uint8_t reg = buf[0]; in emul_bq27z746_write() local
100 switch (reg) { in emul_bq27z746_write()
102 data->mac_cmd = sys_get_le16(&buf[1]); in emul_bq27z746_write()
106 return -EIO; in emul_bq27z746_write()
110 static int emul_bq27z746_reg_read(const struct emul *target, int reg, int *val) in emul_bq27z746_reg_read() argument
112 switch (reg) { in emul_bq27z746_reg_read()
117 *val = -2; in emul_bq27z746_reg_read()
132 *val = -2; in emul_bq27z746_reg_read()
141 *val = -2; in emul_bq27z746_reg_read()
240 LOG_ERR("Unknown register 0x%x read", reg); in emul_bq27z746_reg_read()
241 return -EIO; in emul_bq27z746_reg_read()
243 LOG_INF("read 0x%x = 0x%x", reg, *val); in emul_bq27z746_reg_read()
248 static int emul_bq27z746_read(const struct emul *target, int reg, uint8_t *buf, size_t len) in emul_bq27z746_read() argument
252 int rc = emul_bq27z746_reg_read(target, reg, &val); in emul_bq27z746_read() local
254 if (rc) { in emul_bq27z746_read()
255 return rc; in emul_bq27z746_read()
260 switch (reg) { in emul_bq27z746_read()
267 return -EIO; in emul_bq27z746_read()
277 int reg; in bq27z746_emul_transfer_i2c() local
278 int rc; in bq27z746_emul_transfer_i2c() local
282 i2c_dump_msgs_rw(target->dev, msgs, num_msgs, addr, false); in bq27z746_emul_transfer_i2c()
285 if (msgs->flags & I2C_MSG_READ) { in bq27z746_emul_transfer_i2c()
287 return -EIO; in bq27z746_emul_transfer_i2c()
290 return emul_bq27z746_write(target, msgs->buf, msgs->len); in bq27z746_emul_transfer_i2c()
292 if (msgs->flags & I2C_MSG_READ) { in bq27z746_emul_transfer_i2c()
294 return -EIO; in bq27z746_emul_transfer_i2c()
296 if (msgs->len != 1) { in bq27z746_emul_transfer_i2c()
297 LOG_ERR("Unexpected msg0 length %d", msgs->len); in bq27z746_emul_transfer_i2c()
298 return -EIO; in bq27z746_emul_transfer_i2c()
300 reg = msgs->buf[0]; in bq27z746_emul_transfer_i2c()
304 if (msgs->flags & I2C_MSG_READ) { in bq27z746_emul_transfer_i2c()
305 rc = emul_bq27z746_read(target, reg, msgs->buf, msgs->len); in bq27z746_emul_transfer_i2c()
306 if (rc) { in bq27z746_emul_transfer_i2c()
307 return rc; in bq27z746_emul_transfer_i2c()
311 return -EIO; in bq27z746_emul_transfer_i2c()
313 return rc; in bq27z746_emul_transfer_i2c()
316 return -EIO; in bq27z746_emul_transfer_i2c()