1 /* Copyright (c) 2024 Google LLC
2  * SPDX-License-Identifier: Apache-2.0
3  */
4 
5 #include "blocking_emul.hpp"
6 
7 #include <zephyr/device.h>
8 #include <zephyr/drivers/emul.h>
9 #include <zephyr/drivers/i2c.h>
10 #include <zephyr/drivers/i2c_emul.h>
11 #include <zephyr/logging/log.h>
12 
13 #define DT_DRV_COMPAT zephyr_blocking_emul
14 
15 LOG_MODULE_REGISTER(blocking_emul, CONFIG_I2C_LOG_LEVEL);
16 
17 DEFINE_FAKE_VALUE_FUNC(int, blocking_emul_i2c_transfer, const struct emul *, struct i2c_msg *, int,
18 		       int);
19 
20 static struct i2c_emul_api blocking_emul_i2c_api = {
21 	.transfer = blocking_emul_i2c_transfer,
22 };
23 
blocking_emul_init(const struct emul * target,const struct device * parent)24 static int blocking_emul_init(const struct emul *target, const struct device *parent)
25 {
26 	return 0;
27 }
28 
blocking_dev_init(const struct device * dev)29 static int blocking_dev_init(const struct device *dev)
30 {
31 	return 0;
32 }
33 
34 #define DECLARE_DRV(n)                                                                             \
35 	EMUL_DT_INST_DEFINE(n, blocking_emul_init, NULL, NULL, &blocking_emul_i2c_api, NULL);      \
36 	DEVICE_DT_INST_DEFINE(n, blocking_dev_init, NULL, NULL, NULL, POST_KERNEL, 99, NULL);
37 
38 DT_INST_FOREACH_STATUS_OKAY(DECLARE_DRV)
39