| 
    Zephyr Project API
    3.4.0
    
   A Scalable Open Source RTOS 
   | 
 
Public APIs for the I2C drivers. More...
#include <errno.h>#include <zephyr/types.h>#include <zephyr/device.h>#include <zephyr/kernel.h>#include <zephyr/sys/slist.h>#include <zephyr/rtio/rtio.h>#include <zephyr/stats/stats.h>#include <syscalls/i2c.h>Go to the source code of this file.
Data Structures | |
| struct | i2c_dt_spec | 
| Complete I2C DT information.  More... | |
| struct | i2c_msg | 
| One I2C Message.  More... | |
| struct | i2c_target_callbacks | 
| Structure providing callbacks to be implemented for devices that supports the I2C target API.  More... | |
| struct | i2c_target_config | 
| Structure describing a device that supports the I2C target API.  More... | |
| struct | i2c_device_state | 
| I2C specific device state which allows for i2c device class specific additions.  More... | |
Macros | |
| #define | I2C_SPEED_STANDARD (0x1U) | 
| #define | I2C_SPEED_FAST (0x2U) | 
| #define | I2C_SPEED_FAST_PLUS (0x3U) | 
| #define | I2C_SPEED_HIGH (0x4U) | 
| #define | I2C_SPEED_ULTRA (0x5U) | 
| #define | I2C_SPEED_DT (0x7U) | 
| #define | I2C_SPEED_SHIFT (1U) | 
| #define | I2C_SPEED_SET(speed) | 
| #define | I2C_SPEED_MASK (0x7U << I2C_SPEED_SHIFT) /* 3 bits */ | 
| #define | I2C_SPEED_GET(cfg) | 
| #define | I2C_ADDR_10_BITS BIT(0) | 
| #define | I2C_MODE_CONTROLLER BIT(4) | 
| #define | I2C_DT_SPEC_GET_ON_I3C(node_id) | 
| Structure initializer for i2c_dt_spec from devicetree (on I3C bus)  More... | |
| #define | I2C_DT_SPEC_GET_ON_I2C(node_id) | 
| Structure initializer for i2c_dt_spec from devicetree (on I2C bus)  More... | |
| #define | I2C_DT_SPEC_GET(node_id) | 
| Structure initializer for i2c_dt_spec from devicetree.  More... | |
| #define | I2C_DT_SPEC_INST_GET(inst) I2C_DT_SPEC_GET(DT_DRV_INST(inst)) | 
| Structure initializer for i2c_dt_spec from devicetree instance.  More... | |
| #define | I2C_MSG_WRITE (0U << 0U) | 
| #define | I2C_MSG_READ BIT(0) | 
| #define | I2C_MSG_STOP BIT(1) | 
| #define | I2C_MSG_RESTART BIT(2) | 
| #define | I2C_MSG_ADDR_10_BITS BIT(3) | 
| #define | I2C_TARGET_FLAGS_ADDR_10_BITS BIT(0) | 
| #define | I2C_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, prio, api, ...) | 
| Like DEVICE_DT_DEFINE() with I2C specifics.  More... | |
| #define | I2C_DEVICE_DT_INST_DEFINE(inst, ...) I2C_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__) | 
| Like I2C_DEVICE_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible.  More... | |
Typedefs | |
| typedef void(* | i2c_callback_t) (const struct device *dev, int result, void *data) | 
| I2C callback for asynchronous transfer requests.  More... | |
| typedef int(* | i2c_target_write_requested_cb_t) (struct i2c_target_config *config) | 
| Function called when a write to the device is initiated.  More... | |
| typedef int(* | i2c_target_write_received_cb_t) (struct i2c_target_config *config, uint8_t val) | 
| Function called when a write to the device is continued.  More... | |
| typedef int(* | i2c_target_read_requested_cb_t) (struct i2c_target_config *config, uint8_t *val) | 
| Function called when a read from the device is initiated.  More... | |
| typedef int(* | i2c_target_read_processed_cb_t) (struct i2c_target_config *config, uint8_t *val) | 
| Function called when a read from the device is continued.  More... | |
| typedef int(* | i2c_target_stop_cb_t) (struct i2c_target_config *config) | 
| Function called when a stop condition is observed after a start condition addressed to a particular device.  More... | |
Functions | |
| static bool | i2c_is_ready_dt (const struct i2c_dt_spec *spec) | 
| Validate that I2C bus is ready.  More... | |
| void | i2c_dump_msgs_rw (const char *name, const struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr, bool dump_read) | 
| Dump out an I2C message.  More... | |
| static void | i2c_dump_msgs (const char *name, const struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) | 
| Dump out an I2C message, before it is executed.  More... | |
| static void | i2c_xfer_stats (const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs) | 
| Updates the i2c stats for i2c transfers.  More... | |
| int | i2c_configure (const struct device *dev, uint32_t dev_config) | 
| Configure operation of a host controller.  More... | |
| int | i2c_get_config (const struct device *dev, uint32_t *dev_config) | 
| Get configuration of a host controller.  More... | |
| int | i2c_transfer (const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) | 
| Perform data transfer to another I2C device in controller mode.  More... | |
| static int | i2c_transfer_dt (const struct i2c_dt_spec *spec, struct i2c_msg *msgs, uint8_t num_msgs) | 
| Perform data transfer to another I2C device in controller mode.  More... | |
| int | i2c_recover_bus (const struct device *dev) | 
| Recover the I2C bus.  More... | |
| static int | i2c_target_register (const struct device *dev, struct i2c_target_config *cfg) | 
| Registers the provided config as Target device of a controller.  More... | |
| static int | i2c_target_unregister (const struct device *dev, struct i2c_target_config *cfg) | 
| Unregisters the provided config as Target device.  More... | |
| int | i2c_target_driver_register (const struct device *dev) | 
| Instructs the I2C Target device to register itself to the I2C Controller.  More... | |
| int | i2c_target_driver_unregister (const struct device *dev) | 
| Instructs the I2C Target device to unregister itself from the I2C Controller.  More... | |
| static int | i2c_write (const struct device *dev, const uint8_t *buf, uint32_t num_bytes, uint16_t addr) | 
| Write a set amount of data to an I2C device.  More... | |
| static int | i2c_write_dt (const struct i2c_dt_spec *spec, const uint8_t *buf, uint32_t num_bytes) | 
| Write a set amount of data to an I2C device.  More... | |
| static int | i2c_read (const struct device *dev, uint8_t *buf, uint32_t num_bytes, uint16_t addr) | 
| Read a set amount of data from an I2C device.  More... | |
| static int | i2c_read_dt (const struct i2c_dt_spec *spec, uint8_t *buf, uint32_t num_bytes) | 
| Read a set amount of data from an I2C device.  More... | |
| static int | i2c_write_read (const struct device *dev, uint16_t addr, const void *write_buf, size_t num_write, void *read_buf, size_t num_read) | 
| Write then read data from an I2C device.  More... | |
| static int | i2c_write_read_dt (const struct i2c_dt_spec *spec, const void *write_buf, size_t num_write, void *read_buf, size_t num_read) | 
| Write then read data from an I2C device.  More... | |
| static int | i2c_burst_read (const struct device *dev, uint16_t dev_addr, uint8_t start_addr, uint8_t *buf, uint32_t num_bytes) | 
| Read multiple bytes from an internal address of an I2C device.  More... | |
| static int | i2c_burst_read_dt (const struct i2c_dt_spec *spec, uint8_t start_addr, uint8_t *buf, uint32_t num_bytes) | 
| Read multiple bytes from an internal address of an I2C device.  More... | |
| static int | i2c_burst_write (const struct device *dev, uint16_t dev_addr, uint8_t start_addr, const uint8_t *buf, uint32_t num_bytes) | 
| Write multiple bytes to an internal address of an I2C device.  More... | |
| static int | i2c_burst_write_dt (const struct i2c_dt_spec *spec, uint8_t start_addr, const uint8_t *buf, uint32_t num_bytes) | 
| Write multiple bytes to an internal address of an I2C device.  More... | |
| static int | i2c_reg_read_byte (const struct device *dev, uint16_t dev_addr, uint8_t reg_addr, uint8_t *value) | 
| Read internal register of an I2C device.  More... | |
| static int | i2c_reg_read_byte_dt (const struct i2c_dt_spec *spec, uint8_t reg_addr, uint8_t *value) | 
| Read internal register of an I2C device.  More... | |
| static int | i2c_reg_write_byte (const struct device *dev, uint16_t dev_addr, uint8_t reg_addr, uint8_t value) | 
| Write internal register of an I2C device.  More... | |
| static int | i2c_reg_write_byte_dt (const struct i2c_dt_spec *spec, uint8_t reg_addr, uint8_t value) | 
| Write internal register of an I2C device.  More... | |
| static int | i2c_reg_update_byte (const struct device *dev, uint8_t dev_addr, uint8_t reg_addr, uint8_t mask, uint8_t value) | 
| Update internal register of an I2C device.  More... | |
| static int | i2c_reg_update_byte_dt (const struct i2c_dt_spec *spec, uint8_t reg_addr, uint8_t mask, uint8_t value) | 
| Update internal register of an I2C device.  More... | |
Public APIs for the I2C drivers.