diff options
Diffstat (limited to 'zephyr/emul/emul_isl923x.c')
-rw-r--r-- | zephyr/emul/emul_isl923x.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/zephyr/emul/emul_isl923x.c b/zephyr/emul/emul_isl923x.c index db2a7a654a..5ee94dfaec 100644 --- a/zephyr/emul/emul_isl923x.c +++ b/zephyr/emul/emul_isl923x.c @@ -46,6 +46,9 @@ LOG_MODULE_REGISTER(isl923x_emul, CONFIG_ISL923X_EMUL_LOG_LEVEL); /** Mask used for the AC PROCHOT register */ #define REG_PROCHOT_AC_MASK GENMASK(12, 7) +/** Mask used for the DC PROCHOT register */ +#define REG_PROCHOT_DC_MASK GENMASK(13, 8) + struct isl923x_emul_data { /** Common I2C data */ struct i2c_common_emul_data common; @@ -67,6 +70,8 @@ struct isl923x_emul_data { uint16_t control_1_reg; /** Emulated AC PROCHOT register */ uint16_t ac_prochot_reg; + /** Emulated DC PROCHOT register */ + uint16_t dc_prochot_reg; }; struct isl923x_emul_cfg { @@ -198,6 +203,13 @@ static int isl923x_emul_read_byte(struct i2c_emul *emul, int reg, uint8_t *val, else *val = (uint8_t)((data->ac_prochot_reg >> 8) & 0xff); break; + case ISL923X_REG_PROCHOT_DC: + __ASSERT_NO_MSG(bytes == 0 || bytes == 1); + if (bytes == 0) + *val = (uint8_t)(data->dc_prochot_reg & 0xff); + else + *val = (uint8_t)((data->dc_prochot_reg >> 8) & 0xff); + break; default: return -EINVAL; } @@ -266,6 +278,14 @@ static int isl923x_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val, data->ac_prochot_reg |= (val << 8) & REG_PROCHOT_AC_MASK; break; + case ISL923X_REG_PROCHOT_DC: + __ASSERT_NO_MSG(bytes == 1 || bytes == 2); + if (bytes == 1) + data->dc_prochot_reg = val & REG_PROCHOT_DC_MASK; + else + data->dc_prochot_reg |= (val << 8) & + REG_PROCHOT_DC_MASK; + break; default: return -EINVAL; } |