Zephyr Project API 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
i2c_emul.h
Go to the documentation of this file.
1
7/*
8 * Copyright 2020 Google LLC
9 * Copyright (c) 2020 Nordic Semiconductor ASA
10 *
11 * SPDX-License-Identifier: Apache-2.0
12 */
13#ifndef ZEPHYR_INCLUDE_DRIVERS_I2C_I2C_EMUL_H_
14#define ZEPHYR_INCLUDE_DRIVERS_I2C_I2C_EMUL_H_
15
16#include <zephyr/device.h>
17#include <zephyr/drivers/emul.h>
18#include <zephyr/drivers/i2c.h>
19#include <zephyr/sys/slist.h>
20#include <zephyr/types.h>
21
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34struct i2c_msg;
35struct i2c_emul_api;
36
38struct i2c_emul {
40
42 const struct emul *target;
43
44 /* API provided for this device */
45 const struct i2c_emul_api *api;
46
52
53 /* I2C address of the emulated device */
55};
56
70typedef int (*i2c_emul_transfer_t)(const struct emul *target, struct i2c_msg *msgs, int num_msgs,
71 int addr);
72
80int i2c_emul_register(const struct device *dev, struct i2c_emul *emul);
81
86
87#ifdef __cplusplus
88}
89#endif
90
95#endif /* ZEPHYR_INCLUDE_DRIVERS_I2C_I2C_EMUL_H_ */
Public APIs for the I2C drivers.
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:70
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:39
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:82
Definition of the emulator API.
Definition i2c_emul.h:83
i2c_emul_transfer_t transfer
Definition i2c_emul.h:84
Node in a linked list of emulators for I2C devices.
Definition i2c_emul.h:38
const struct emul * target
Target emulator - REQUIRED for all emulated bus nodes of any type.
Definition i2c_emul.h:42
sys_snode_t node
Definition i2c_emul.h:39
const struct i2c_emul_api * api
Definition i2c_emul.h:45
uint16_t addr
Definition i2c_emul.h:54
struct i2c_emul_api * mock_api
A mock API that if not NULL will take precedence over the actual API.
Definition i2c_emul.h:51
One I2C Message.
Definition i2c.h:184