Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
I2C Emulation Interface

I2C Emulation Interface. More...

Data Structures

struct  i2c_emul
 
struct  i2c_emul_api
 

Typedefs

typedef int(* i2c_emul_transfer_t) (struct i2c_emul *emul, struct i2c_msg *msgs, int num_msgs, int addr)
 

Functions

int i2c_emul_register (const struct device *dev, const char *name, struct i2c_emul *emul)
 
uint32_t i2c_emul_get_config (const struct device *dev)
 

Detailed Description

I2C Emulation Interface.

Typedef Documentation

◆ i2c_emul_transfer_t

typedef int(* i2c_emul_transfer_t) (struct i2c_emul *emul, struct i2c_msg *msgs, int num_msgs, int addr)

#include <include/drivers/i2c_emul.h>

Passes I2C messages to the emulator. The emulator updates the data with what was read back.

Parameters
emulEmulator instance
msgsArray of messages to transfer. For 'read' messages, this function updates the 'buf' member with the data that was read
num_msgsNumber of messages to transfer.
addrAddress of the I2C target device.
Return values
0If successful.
-EIOGeneral input / output error.

Function Documentation

◆ i2c_emul_get_config()

uint32_t i2c_emul_get_config ( const struct device dev)

#include <include/drivers/i2c_emul.h>

Back door to allow an emulator to retrieve the host configuration.

Parameters
devI2C device associated with the emulator
Returns
Bit-packed 32-bit value containing the device's runtime configuration

◆ i2c_emul_register()

int i2c_emul_register ( const struct device dev,
const char *  name,
struct i2c_emul emul 
)

#include <include/drivers/i2c_emul.h>

Register an emulated device on the controller

Parameters
devDevice that will use the emulator
nameUser-friendly name for this emulator
emulI2C emulator to use
Returns
0 indicating success (always)