Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
i2c_emul.h
Go to the documentation of this file.
1
7
8/*
9 * Copyright 2020 Google LLC
10 * Copyright (c) 2020 Nordic Semiconductor ASA
11 *
12 * SPDX-License-Identifier: Apache-2.0
13 */
14#ifndef ZEPHYR_INCLUDE_DRIVERS_I2C_I2C_EMUL_H_
15#define ZEPHYR_INCLUDE_DRIVERS_I2C_I2C_EMUL_H_
16
17#include <zephyr/device.h>
18#include <zephyr/drivers/emul.h>
19#include <zephyr/drivers/i2c.h>
20#include <zephyr/sys/slist.h>
21#include <zephyr/types.h>
22
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35struct i2c_msg;
36struct i2c_emul_api;
37
39struct i2c_emul {
42
44 const struct emul *target;
45
47 const struct i2c_emul_api *api;
48
54
57};
58
72typedef int (*i2c_emul_transfer_t)(const struct emul *target, struct i2c_msg *msgs, int num_msgs,
73 int addr);
74
82int i2c_emul_register(const struct device *dev, struct i2c_emul *emul);
83
89
90#ifdef __cplusplus
91}
92#endif
93
97
98#endif /* ZEPHYR_INCLUDE_DRIVERS_I2C_I2C_EMUL_H_ */
APIs and macros for the Zephyr device model.
Public APIs for the device emulation framework.
Main header file for I2C (Inter-Integrated Circuit) driver API.
int(* i2c_emul_transfer_t)(const struct emul *target, struct i2c_msg *msgs, int num_msgs, int addr)
Passes I2C messages to the emulator.
Definition i2c_emul.h:72
int i2c_emul_register(const struct device *dev, struct i2c_emul *emul)
Register an emulated device on the controller.
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
Header file for the single-linked list API.
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:543
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:88
Definition of the emulator API.
Definition i2c_emul.h:85
i2c_emul_transfer_t transfer
Passes I2C messages to the emulator.
Definition i2c_emul.h:87
Node in a linked list of emulators for I2C devices.
Definition i2c_emul.h:39
const struct emul * target
Target emulator - REQUIRED for all emulated bus nodes of any type.
Definition i2c_emul.h:44
sys_snode_t node
Node in the controller's linked list of emulators.
Definition i2c_emul.h:41
const struct i2c_emul_api * api
API provided for this device.
Definition i2c_emul.h:47
uint16_t addr
I2C address of the emulated device.
Definition i2c_emul.h:56
struct i2c_emul_api * mock_api
A mock API that if not NULL will take precedence over the actual API.
Definition i2c_emul.h:53
One I2C Message.
Definition i2c.h:244