diff options
author | Yuval Peress <peress@chromium.org> | 2021-09-20 13:30:55 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-21 02:41:45 +0000 |
commit | 5a12a3dbca6e07882d1760b115dcbf3b7ec5931c (patch) | |
tree | 82d80374a980ec2135408075113d1c1299e7ce21 /zephyr/include/emul/i2c_mock.h | |
parent | 26e3f0f8596300e1b7f64f426c0469f9bfee669f (diff) | |
download | chrome-ec-5a12a3dbca6e07882d1760b115dcbf3b7ec5931c.tar.gz |
zephyr: test: add a generic I2C mock
Add a simple mock with no state to test common i2c code.
BRANCH=none
BUG=b:200589041
TEST=zmake testall
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I99730361a298708278106deb58890a0ed2c9febf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3171694
Tested-by: Yuval Peress <peress@google.com>
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Commit-Queue: Yuval Peress <peress@google.com>
Diffstat (limited to 'zephyr/include/emul/i2c_mock.h')
-rw-r--r-- | zephyr/include/emul/i2c_mock.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/zephyr/include/emul/i2c_mock.h b/zephyr/include/emul/i2c_mock.h new file mode 100644 index 0000000000..e9e8d97252 --- /dev/null +++ b/zephyr/include/emul/i2c_mock.h @@ -0,0 +1,35 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_INCLUDE_EMUL_I2C_MOCK_H_ +#define ZEPHYR_INCLUDE_EMUL_I2C_MOCK_H_ + +#include <emul.h> +#include <drivers/i2c_emul.h> + +/** + * @brief reset the I2C mock. + * + * @param emul The mock device to reset. + */ +void i2c_mock_reset(const struct emul *emul); + +/** + * @brief Get the i2c emulator pointer from the top level mock. + * + * @param emul The mock device to query + * @return Pointer to the i2c emulator struct + */ +struct i2c_emul *i2c_mock_to_i2c_emul(const struct emul *emul); + +/** + * @brief Get the I2C address of the mock + * + * @param emul The mock device to query + * @return The address on the I2C bus + */ +uint16_t i2c_mock_get_addr(const struct emul *emul); + +#endif /* ZEPHYR_INCLUDE_EMUL_I2C_MOCK_H_ */ |