Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Emulator interface

Emulators used to test drivers and higher-level code that uses them. More...

Modules

 I2C Emulation Interface
 I2C Emulation Interface.
 
 SPI Emulation Interface
 SPI Emulation Interface.
 
 eSPI Emulation Interface
 eSPI Emulation Interface
 

Data Structures

struct  emul_link_for_bus
 
struct  emul_list_for_bus
 
struct  emul
 

Macros

#define EMUL_REG_NAME(node_id)   (_CONCAT(__emulreg_, node_id))
 
#define EMUL_DEFINE(init_ptr, node_id, cfg_ptr, data_ptr)
 

Typedefs

typedef int(* emul_init_t) (const struct emul *emul, const struct device *parent)
 

Functions

int emul_init_for_bus_from_list (const struct device *dev, const struct emul_list_for_bus *list)
 
const struct emulemul_get_binding (const char *name)
 Retrieve the emul structure for an emulator by name. More...
 

Detailed Description

Emulators used to test drivers and higher-level code that uses them.

Macro Definition Documentation

◆ EMUL_DEFINE

#define EMUL_DEFINE (   init_ptr,
  node_id,
  cfg_ptr,
  data_ptr 
)

#include <include/drivers/emul.h>

Value:
static struct emul EMUL_REG_NAME(node_id) __attribute__((__section__(".emulators"))) \
__used = { \
.init = (init_ptr), \
.dev_label = DT_LABEL(node_id), \
.cfg = (cfg_ptr), \
.data = (data_ptr), \
};
#define DT_LABEL(node_id)
Equivalent to DT_PROP(node_id, label)
Definition: devicetree.h:660
#define EMUL_REG_NAME(node_id)
Definition: emul.h:71
Definition: emul.h:52
const char * dev_label
Definition: emul.h:56
static fdata_t data[2]
Definition: test_fifo_contexts.c:15

Define a new emulator

This adds a new struct emul to the linker list of emulations. This is typically used in your emulator's DT_INST_FOREACH_STATUS_OKAY() clause.

Parameters
init_ptrfunction to call to initialise the emulator (see emul_init typedef)
node_idNode ID of the driver to emulate (e.g. DT_DRV_INST(n))
cfg_ptremulator-specific configuration data
data_ptremulator-specific data

◆ EMUL_REG_NAME

#define EMUL_REG_NAME (   node_id)    (_CONCAT(__emulreg_, node_id))

Typedef Documentation

◆ emul_init_t

typedef int(* emul_init_t) (const struct emul *emul, const struct device *parent)

#include <include/drivers/emul.h>

Standard callback for emulator initialisation providing the initialiser record and the device that calls the emulator functions.

Parameters
emulEmulator to init
parentParent device that is using the emulator

Function Documentation

◆ emul_get_binding()

const struct emul * emul_get_binding ( const char *  name)

#include <include/drivers/emul.h>

Retrieve the emul structure for an emulator by name.

Emulator objects are created via the EMUL_DEFINE() macro and placed in memory by the linker. If the emulator structure is needed for custom API calls, it can be retrieved by the name that the emulator exposes to the system (this is the devicetree node's label by default).

Parameters
nameEmulator name to search for. A null pointer, or a pointer to an empty string, will cause NULL to be returned.
Returns
pointer to emulator structure; NULL if not found or cannot be used.

◆ emul_init_for_bus_from_list()

int emul_init_for_bus_from_list ( const struct device dev,
const struct emul_list_for_bus list 
)

#include <include/drivers/emul.h>

Set up a list of emulators

Parameters
devDevice the emulators are attached to (e.g. an I2C controller)
listList of devices to set up
Returns
0 if OK
negative value on error