Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
regset_target_lib.h File Reference

Public APIs for the I2C target library. More...

#include <stddef.h>
#include <sys/types.h>

Go to the source code of this file.

Data Structures

struct  regset_target_lib_data
 Register set library config. More...
struct  regset_target_lib_config
 Register set library data. More...

Macros

#define REGSET_TARGET_LIB_STRUCT_CHECK(config, data)
 Validate the offset of the regset data structures.
#define REGSET_TARGET_LIB_DT_BUILD_ASSERT(node_id)
 Validate the node properties from devicetree.
#define REGSET_TARGET_LIB_DT_INST_BUILD_ASSERT(inst)
 Validate the node properties from a devicetree instance.
#define REGSET_TARGET_LIB_DT_CONFIG_INIT(node_id)
 Define the common data structure from devicetree.
#define REGSET_TARGET_LIB_DT_INST_CONFIG_INIT(inst)
 Define the common data structure from a devicetree instance.

Typedefs

typedef void(* regset_target_lib_changed_handler_t) (const struct device *dev, void *user_data)
 Define the application callback handler function signature.

Functions

void regset_target_lib_set_changed_callback (const struct device *dev, regset_target_lib_changed_handler_t handler, void *user_data)
 Set the regset changed callback handler.
size_t regset_target_lib_get_size (const struct device *dev)
 Get size of the register set.
int regset_target_lib_read_data (const struct device *dev, off_t offset, void *data, size_t len)
 Read data from the register set.
int regset_target_lib_write_data (const struct device *dev, off_t offset, const void *data, size_t len)
 Write data to the register set.
int regset_target_lib_set_addr (const struct device *dev, uint8_t addr)
 Change the address of register set target at runtime.
int regset_target_lib_init (const struct device *dev)
 Initialize the register set data structures.

Variables

const struct i2c_target_driver_api regset_target_api
 Generig register set library i2c target API.

Detailed Description

Public APIs for the I2C target library.

Macro Definition Documentation

◆ REGSET_TARGET_LIB_DT_BUILD_ASSERT

#define REGSET_TARGET_LIB_DT_BUILD_ASSERT ( node_id)
Value:
BUILD_ASSERT(DT_PROP(node_id, size) <= (1 << DT_PROP_OR(node_id, address_width, 8)), \
"size must be <= than 2^address_width");
#define DT_PROP_OR(node_id, prop, default_value)
Like DT_PROP(), but with a fallback to default_value.
Definition devicetree.h:1046
#define DT_PROP(node_id, prop)
Get a devicetree property value.
Definition devicetree.h:873
#define BUILD_ASSERT(EXPR, MSG...)
Definition llvm.h:51

Validate the node properties from devicetree.

◆ REGSET_TARGET_LIB_DT_CONFIG_INIT

#define REGSET_TARGET_LIB_DT_CONFIG_INIT ( node_id)
Value:
{ \
.bus = I2C_DT_SPEC_GET(node_id), \
.buffer_size = DT_PROP(node_id, size), \
.buffer = (uint8_t[DT_PROP(node_id, size)]) {}, \
.address_width = DT_PROP_OR(node_id, address_width, 8), \
}
#define I2C_DT_SPEC_GET(node_id)
Structure initializer for i2c_dt_spec from devicetree.
Definition i2c.h:166
__UINT8_TYPE__ uint8_t
Definition stdint.h:88

Define the common data structure from devicetree.

◆ REGSET_TARGET_LIB_DT_INST_BUILD_ASSERT

#define REGSET_TARGET_LIB_DT_INST_BUILD_ASSERT ( inst)
Value:
#define DT_DRV_INST(inst)
Node identifier for an instance of a DT_DRV_COMPAT compatible.
Definition devicetree.h:4333
#define REGSET_TARGET_LIB_DT_BUILD_ASSERT(node_id)
Validate the node properties from devicetree.
Definition regset_target_lib.h:145

Validate the node properties from a devicetree instance.

◆ REGSET_TARGET_LIB_DT_INST_CONFIG_INIT

#define REGSET_TARGET_LIB_DT_INST_CONFIG_INIT ( inst)
Value:
#define REGSET_TARGET_LIB_DT_CONFIG_INIT(node_id)
Define the common data structure from devicetree.
Definition regset_target_lib.h:158

Define the common data structure from a devicetree instance.

◆ REGSET_TARGET_LIB_STRUCT_CHECK

#define REGSET_TARGET_LIB_STRUCT_CHECK ( config,
data )
Value:
BUILD_ASSERT(offsetof(config, regset_cfg) == 0, \
"struct regset_target_lib_config must be placed first"); \
BUILD_ASSERT(offsetof(data, regset_data) == 0, \
"struct regset_target_lib_data must be placed first")

Validate the offset of the regset data structures.

Parameters
configName of the config structure.
dataName of the data structure.

Typedef Documentation

◆ regset_target_lib_changed_handler_t

typedef void(* regset_target_lib_changed_handler_t) (const struct device *dev, void *user_data)

Define the application callback handler function signature.

Parameters
devPointer to the device structure for the driver instance.
user_dataOptional user data provided when callback is set.

Function Documentation

◆ regset_target_lib_get_size()

size_t regset_target_lib_get_size ( const struct device * dev)

Get size of the register set.

Parameters
devPointer to the device structure for the driver instance.
Returns
Size of register set in bytes

◆ regset_target_lib_init()

int regset_target_lib_init ( const struct device * dev)

Initialize the register set data structures.

Parameters
devPointer to the device structure for the driver instance.
Returns
0 on success, negative errno code on failure.

◆ regset_target_lib_read_data()

int regset_target_lib_read_data ( const struct device * dev,
off_t offset,
void * data,
size_t len )

Read data from the register set.

Parameters
devPointer to the device structure for the driver instance.
offsetAddress offset to read from.
dataBuffer to store read data.
lenNumber of bytes to read.
Returns
0 on success, negative errno code on failure.

◆ regset_target_lib_set_addr()

int regset_target_lib_set_addr ( const struct device * dev,
uint8_t addr )

Change the address of register set target at runtime.

Parameters
devPointer to the device structure for the driver instance.
addrNew address to assign to the register set target device
Return values
0Is successful
-EINVALIf parameters are invalid
-EIOGeneral input / output error during i2c_taget_register
-ENOSYSIf target mode is not implemented

◆ regset_target_lib_set_changed_callback()

void regset_target_lib_set_changed_callback ( const struct device * dev,
regset_target_lib_changed_handler_t handler,
void * user_data )

Set the regset changed callback handler.

Parameters
devPointer to the device structure for the driver instance.
handlerHandler to call on regset changes
user_dataOptional user data passed to callback

◆ regset_target_lib_write_data()

int regset_target_lib_write_data ( const struct device * dev,
off_t offset,
const void * data,
size_t len )

Write data to the register set.

Parameters
devPointer to the device structure for the driver instance.
offsetAddress offset to write data to.
dataBuffer with data to write.
lenNumber of bytes to write.
Returns
0 on success, negative errno code on failure.

Variable Documentation

◆ regset_target_api

const struct i2c_target_driver_api regset_target_api
extern

Generig register set library i2c target API.