diff options
-rw-r--r-- | zephyr/emul/emul_sn5s330.c | 10 | ||||
-rw-r--r-- | zephyr/include/emul/emul_sn5s330.h | 7 | ||||
-rw-r--r-- | zephyr/test/drivers/src/ppc_sn5s330.c | 12 |
3 files changed, 26 insertions, 3 deletions
diff --git a/zephyr/emul/emul_sn5s330.c b/zephyr/emul/emul_sn5s330.c index 0fcb9bd78c..f6b3217372 100644 --- a/zephyr/emul/emul_sn5s330.c +++ b/zephyr/emul/emul_sn5s330.c @@ -316,6 +316,16 @@ static int sn5s330_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val, return 0; } +void sn5s330_emul_reset(const struct emul *emul) +{ + struct sn5s330_emul_data *data = emul->data; + struct i2c_common_emul_data common = data->common; + + /* Only Reset the sn5s330 Register Data */ + memset(data, 0, sizeof(struct sn5s330_emul_data)); + data->common = common; +} + static int emul_sn5s330_init(const struct emul *emul, const struct device *parent) { diff --git a/zephyr/include/emul/emul_sn5s330.h b/zephyr/include/emul/emul_sn5s330.h index ad6d0f04c1..00b473e206 100644 --- a/zephyr/include/emul/emul_sn5s330.h +++ b/zephyr/include/emul/emul_sn5s330.h @@ -27,4 +27,11 @@ struct i2c_emul *sn5s330_emul_to_i2c_emul(const struct emul *emul); */ int sn5s330_emul_peek_reg(const struct emul *emul, uint32_t reg, uint32_t *val); +/** + * @brief Reset the sn5s330 emulator + * + * @param emul The emulator to reset + */ +void sn5s330_emul_reset(const struct emul *emul); + #endif /* ZEPHYR_INCLUDE_EMUL_EMUL_SN5S330_H_ */ diff --git a/zephyr/test/drivers/src/ppc_sn5s330.c b/zephyr/test/drivers/src/ppc_sn5s330.c index 3cabfc43c9..95556e28cf 100644 --- a/zephyr/test/drivers/src/ppc_sn5s330.c +++ b/zephyr/test/drivers/src/ppc_sn5s330.c @@ -53,10 +53,16 @@ static void test_fail_once_func_set1(void) i2c_common_emul_set_write_func(i2c_emul, NULL, NULL); } +static void reset_sn5s330_state(void) +{ + sn5s330_emul_reset(EMUL); +} + void test_suite_ppc_sn5s330(void) { - ztest_test_suite( - ppc_sn5s330, - ztest_unit_test(test_fail_once_func_set1)); + ztest_test_suite(ppc_sn5s330, + ztest_unit_test_setup_teardown( + test_fail_once_func_set1, reset_sn5s330_state, + reset_sn5s330_state)); ztest_run_test_suite(ppc_sn5s330); } |