13#ifndef ZEPHYR_INCLUDE_DRIVERS_I2C_H_
14#define ZEPHYR_INCLUDE_DRIVERS_I2C_H_
43#define I2C_SPEED_STANDARD (0x1U)
46#define I2C_SPEED_FAST (0x2U)
49#define I2C_SPEED_FAST_PLUS (0x3U)
52#define I2C_SPEED_HIGH (0x4U)
55#define I2C_SPEED_ULTRA (0x5U)
58#define I2C_SPEED_DT (0x7U)
61#define I2C_SPEED_SHIFT (1U)
62#define I2C_SPEED_MASK (0x7U << I2C_SPEED_SHIFT)
70#define I2C_SPEED_SET(speed) (((speed) << I2C_SPEED_SHIFT) \
78#define I2C_SPEED_GET(cfg) (((cfg) & I2C_SPEED_MASK) \
82#define I2C_ADDR_10_BITS BIT(0)
85#define I2C_MODE_CONTROLLER BIT(4)
87#if CONFIG_I2C_TRANSFER_TIMEOUT_SUPPORTED
90#if CONFIG_I2C_TRANSFER_TIMEOUT_MS
91#define I2C_TRANSFER_TIMEOUT K_MSEC(CONFIG_I2C_TRANSFER_TIMEOUT_MS)
93#define I2C_TRANSFER_TIMEOUT K_FOREVER
105#define I2C_DT_INST_TRANSFER_TIMEOUT_MS(inst) \
106 DT_INST_PROP_OR(inst, zephyr_transfer_timeout_ms, CONFIG_I2C_TRANSFER_TIMEOUT_MS)
120#define I2C_DT_INST_TRANSFER_TIMEOUT(inst) \
121 SYS_TIMEOUT_MS_INIT(((I2C_DT_INST_TRANSFER_TIMEOUT_MS(inst) != 0) \
122 ? I2C_DT_INST_TRANSFER_TIMEOUT_MS(inst) \
126#define BUILD_ASSERT_INVALID_I2C_TRANSFER_TIMEOUT() \
127 BUILD_ASSERT(CONFIG_I2C_TRANSFER_TIMEOUT_MS != 0, \
128 "infinite i2c transfer timeout not unsupported")
152#define I2C_DT_SPEC_GET_ON_I3C(node_id) \
153 .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
154 .addr = DT_PROP_BY_IDX(node_id, reg, 0)
166#define I2C_DT_SPEC_GET_ON_I2C(node_id) \
167 .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
168 .addr = DT_REG_ADDR(node_id)
180#define I2C_DT_SPEC_GET(node_id) \
182 COND_CODE_1(DT_ON_BUS(node_id, i3c), \
183 (I2C_DT_SPEC_GET_ON_I3C(node_id)), \
184 (I2C_DT_SPEC_GET_ON_I2C(node_id))) \
195#define I2C_DT_SPEC_INST_GET(inst) \
196 I2C_DT_SPEC_GET(DT_DRV_INST(inst))
204#define I2C_MSG_WRITE (0U << 0U)
207#define I2C_MSG_READ BIT(0)
210#define I2C_MSG_RW_MASK BIT(0)
214#define I2C_MSG_STOP BIT(1)
223#define I2C_MSG_RESTART BIT(2)
228#define I2C_MSG_ADDR_10_BITS BIT(3)
308#if defined(CONFIG_I2C_CALLBACK) || defined(__DOXYGEN__)
321#if defined(CONFIG_I2C_RTIO) || defined(__DOXYGEN__)
350#if defined(CONFIG_I2C_CALLBACK) || defined(__DOXYGEN__)
357#if defined(CONFIG_I2C_RTIO) || defined(__DOXYGEN__)
393#define I2C_TARGET_FLAGS_ADDR_10_BITS BIT(0)
477#if defined(CONFIG_I2C_TARGET_BUFFER_MODE) || defined(__DOXYGEN__)
579#if defined(CONFIG_I2C_TARGET_BUFFER_MODE) || defined(__DOXYGEN__)
721#if defined(CONFIG_I2C_STATS) || defined(__DOXYGEN__)
771 for (
uint8_t i = 0U; i < num_msgs; i++) {
773 bytes_read += msgs[i].
len;
775 bytes_written += msgs[i].
len;
787#define Z_I2C_DEVICE_STATE_DEFINE(dev_id) \
788 static struct i2c_device_state Z_DEVICE_STATE_NAME(dev_id) \
789 __attribute__((__section__(".z_devstate")))
797#define Z_I2C_INIT_FN(dev_id, init_fn) \
798 static inline int UTIL_CAT(dev_id, _init)(const struct device *dev) \
800 struct i2c_device_state *state = \
801 CONTAINER_OF(dev->state, struct i2c_device_state, devstate); \
802 stats_init(&state->stats.s_hdr, STATS_SIZE_32, 4, \
803 STATS_NAME_INIT_PARMS(i2c)); \
804 stats_register(dev->name, &(state->stats.s_hdr)); \
805 if (!is_null_no_warn(init_fn)) { \
806 return init_fn(dev); \
843#define I2C_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, pm, \
844 data, config, level, prio, api, ...)\
845 Z_I2C_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \
846 Z_I2C_INIT_FN(Z_DEVICE_DT_DEV_ID(node_id), init_fn) \
847 Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
848 DEVICE_DT_NAME(node_id), \
849 &UTIL_CAT(Z_DEVICE_DT_DEV_ID(node_id), _init), \
850 deinit_fn, Z_DEVICE_DT_FLAGS(node_id), pm, data,\
851 config, level, prio, api, \
852 &(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)).devstate), \
862 ARG_UNUSED(num_msgs);
865#define I2C_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, pm, \
866 data, config, level, prio, api, ...)\
867 DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, pm, data, \
868 config, level, prio, api, __VA_ARGS__)
875#define I2C_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
877 I2C_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, NULL, pm, data, \
878 config, level, prio, api, \
889#define I2C_DEVICE_DT_INST_DEINIT_DEFINE(inst, ...) \
890 I2C_DEVICE_DT_DEINIT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
900#define I2C_DEVICE_DT_INST_DEFINE(inst, ...) \
901 I2C_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
915static inline int z_impl_i2c_configure(
const struct device *dev,
962static inline int z_impl_i2c_get_config(
const struct device *dev,
uint32_t *dev_config)
1008static inline int z_impl_i2c_transfer(
const struct device *dev,
1016 if (!
IS_ENABLED(CONFIG_I2C_ALLOW_NO_STOP_TRANSACTIONS)) {
1020 int res =
DEVICE_API_GET(i2c, dev)->transfer(dev, msgs, num_msgs, addr);
1031#if defined(CONFIG_I2C_CALLBACK) || defined(__DOXYGEN__)
1069 cb(dev, 0, userdata);
1073 if (!
IS_ENABLED(CONFIG_I2C_ALLOW_NO_STOP_TRANSACTIONS)) {
1077 return api->
transfer_cb(dev, msgs, num_msgs, addr, cb, userdata);
1128 size_t num_write,
void *read_buf,
size_t num_read,
1131 if ((msgs == NULL) || (num_msgs != 2)) {
1136 msgs[0].
len = num_write;
1140 msgs[1].
len = num_read;
1168 uint8_t num_msgs,
const void *write_buf,
size_t num_write,
1173 read_buf, num_read, cb, userdata);
1176#if defined(CONFIG_POLL) || defined(__DOXYGEN__)
1179void z_i2c_transfer_signal_cb(
const struct device *dev,
int result,
void *userdata);
1215 return api->
transfer_cb(dev, msgs, num_msgs, addr, z_i2c_transfer_signal_cb, sig);
1223#if defined(CONFIG_I2C_RTIO) || defined(__DOXYGEN__)
1246 const struct device *dev = dt_spec->
bus;
1260#define I2C_CAT2(x, y) x ## y
1273#define I2C_DT_IODEV_DEFINE(name, node_id) \
1274 const struct i2c_dt_spec _i2c_dt_spec_##name = \
1275 I2C_DT_SPEC_GET(node_id); \
1276 RTIO_IODEV_DEFINE(name, &i2c_iodev_api, (void *)&_i2c_dt_spec_##name)
1287#define I2C_DT_INST_IODEV_DEFINE(name, inst) \
1288 I2C_DT_IODEV_DEFINE(name, DT_DRV_INST(inst))
1300#define I2C_IODEV_DEFINE(name, _bus, _addr) \
1301 const struct i2c_dt_spec I2C_CAT2(_i2c_dt_spec_, name) = { \
1302 .bus = DEVICE_DT_GET(_bus), \
1305 RTIO_IODEV_DEFINE(name, &i2c_iodev_api, (void *)&I2C_CAT2(_i2c_dt_spec_, name))
1365 uint8_t start_addr,
void *
buf,
size_t num_bytes);
1402static inline int z_impl_i2c_recover_bus(
const struct device *dev)
1492static inline int z_impl_i2c_target_driver_register(
const struct device *dev)
1512static inline int z_impl_i2c_target_driver_unregister(
const struct device *dev)
1541 msg.
len = num_bytes;
1586 msg.
len = num_bytes;
1629 const void *write_buf,
size_t num_write,
1630 void *read_buf,
size_t num_read)
1635 msg[0].
len = num_write;
1639 msg[1].
len = num_read;
1663 const void *write_buf,
size_t num_write,
1664 void *read_buf,
size_t num_read)
1667 write_buf, num_write,
1668 read_buf, num_read);
1696 &start_addr,
sizeof(start_addr),
1720 start_addr,
buf, num_bytes);
1752 msg[0].
buf = &start_addr;
1757 msg[1].
len = num_bytes;
1783 start_addr,
buf, num_bytes);
1806 ®_addr,
sizeof(reg_addr),
1807 value,
sizeof(*value));
1851 uint8_t tx_buf[2] = {reg_addr, value};
1853 return i2c_write(dev, tx_buf, 2, dev_addr);
1907 new_value = (old_value & ~mask) | (value & mask);
1908 if (new_value == old_value) {
1934 reg_addr, mask, value);
1945#include <zephyr/syscalls/i2c.h>
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1449
bool device_is_ready(const struct device *dev)
Verify that a device is ready for use.
void(* i2c_api_iodev_submit)(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
Callback API to submit an RTIO request to the I2C controller.
Definition i2c.h:326
int(* i2c_api_configure_t)(const struct device *dev, uint32_t dev_config)
Callback API to configure the I2C controller.
Definition i2c.h:275
int(* i2c_api_full_io_t)(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr)
Callback API to transfer messages on the I2C bus in controller mode.
Definition i2c.h:289
int(* i2c_api_transfer_cb_t)(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr, i2c_callback_t cb, void *userdata)
Callback API to transfer messages on the I2C bus asynchronously.
Definition i2c.h:313
int(* i2c_target_api_unregister_t)(const struct device *dev)
Callback API to instruct the I2C target device to unregister itself.
Definition i2c.h:378
int(* i2c_api_target_unregister_t)(const struct device *dev, struct i2c_target_config *cfg)
Callback API to unregister a target device from the I2C controller.
Definition i2c.h:305
int(* i2c_target_api_register_t)(const struct device *dev)
Callback API to instruct the I2C target device to register itself.
Definition i2c.h:372
int(* i2c_api_target_register_t)(const struct device *dev, struct i2c_target_config *cfg)
Callback API to register a target device on the I2C controller.
Definition i2c.h:298
int(* i2c_api_recover_bus_t)(const struct device *dev)
Callback API to recover the I2C bus.
Definition i2c.h:334
int(* i2c_api_get_config_t)(const struct device *dev, uint32_t *dev_config)
Callback API to get the current configuration of the I2C controller.
Definition i2c.h:282
static int i2c_transfer_cb_dt(const struct i2c_dt_spec *spec, struct i2c_msg *msgs, uint8_t num_msgs, i2c_callback_t cb, void *userdata)
Perform data transfer to another I2C device in master mode asynchronously.
Definition i2c.h:1095
int i2c_target_driver_unregister(const struct device *dev)
Instructs the I2C Target device to unregister itself from the I2C Controller.
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.
Definition i2c.h:1777
static int i2c_target_unregister(const struct device *dev, struct i2c_target_config *cfg)
Unregisters the provided config as Target device.
Definition i2c.h:1465
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.
Definition i2c.h:1628
static bool i2c_is_restart_op(const struct i2c_msg *msg)
Check if the current message includes a restart.
Definition i2c.h:667
int i2c_target_driver_register(const struct device *dev)
Instructs the I2C Target device to register itself to the I2C Controller.
static void i2c_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
Submit request(s) to an I2C device with RTIO.
Definition i2c.h:1243
struct rtio_sqe * i2c_rtio_copy(struct rtio *r, struct rtio_iodev *iodev, const struct i2c_msg *msgs, uint8_t num_msgs)
Copy the i2c_msgs into a set of RTIO requests.
void i2c_dump_msgs_rw(const struct device *dev, const struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr, bool dump_read)
Dump out an I2C message.
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.
Definition i2c.h:452
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.
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.
Definition i2c.h:1535
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.
Definition i2c.h:1560
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.
Definition i2c.h:1662
void(* i2c_target_error_cb_t)(struct i2c_target_config *config, enum i2c_error_reason error_code)
Function called when an error is detected on the I2C bus while acting as a target.
Definition i2c.h:561
static int i2c_write_read_cb(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr, const void *write_buf, size_t num_write, void *read_buf, size_t num_read, i2c_callback_t cb, void *userdata)
Write then read data from an I2C device asynchronously.
Definition i2c.h:1126
static bool i2c_is_stop_op(const struct i2c_msg *msg)
Check if the current message includes a stop.
Definition i2c.h:655
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 d...
Definition i2c.h:534
static bool i2c_is_ready_iodev(const struct rtio_iodev *i2c_iodev)
Validate that I2C bus is ready.
Definition i2c.h:1315
i2c_error_reason
I2C error reasons.
Definition i2c.h:542
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.
Definition i2c.h:1689
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.
Definition i2c.h:474
int(* i2c_target_write_requested_cb_t)(struct i2c_target_config *config)
Function called when a write to the device is initiated.
Definition i2c.h:410
void i2c_iodev_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
Fallback submit implementation.
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.
Definition i2c.h:1929
void(* i2c_callback_t)(const struct device *dev, int result, void *data)
I2C callback for asynchronous transfer requests.
Definition i2c.h:262
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.
Definition i2c.h:1605
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.
Definition i2c.h:430
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.
Definition i2c.h:1869
int i2c_get_config(const struct device *dev, uint32_t *dev_config)
Get configuration of a host controller.
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.
Definition i2c.h:1847
#define I2C_MSG_READ
Read message from I2C bus.
Definition i2c.h:207
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.
Definition i2c.h:1823
int i2c_configure(const struct device *dev, uint32_t dev_config)
Configure operation of a host controller.
static int i2c_configure_dt(const struct i2c_dt_spec *spec, uint32_t dev_config)
Configure operation of a host controller.
Definition i2c.h:934
static int i2c_write_read_cb_dt(const struct i2c_dt_spec *spec, struct i2c_msg *msgs, uint8_t num_msgs, const void *write_buf, size_t num_write, void *read_buf, size_t num_read, i2c_callback_t cb, void *userdata)
Write then read data from an I2C device asynchronously.
Definition i2c.h:1167
#define I2C_MSG_RESTART
RESTART I2C transaction for this message.
Definition i2c.h:223
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.
Definition i2c.h:1382
int i2c_recover_bus(const struct device *dev)
Recover the I2C bus.
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.
Definition i2c.h:1580
static bool i2c_is_read_op(const struct i2c_msg *msg)
Check if the current message is a read operation.
Definition i2c.h:643
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.
Definition i2c.h:1714
static int i2c_target_register(const struct device *dev, struct i2c_target_config *cfg)
Registers the provided config as Target device of a controller.
Definition i2c.h:1437
int(* i2c_target_buf_read_requested_cb_t)(struct i2c_target_config *config, uint8_t **ptr, uint32_t *len)
Function called when a read from the device is initiated.
Definition i2c.h:516
static int i2c_transfer_cb(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr, i2c_callback_t cb, void *userdata)
Perform data transfer to another I2C device in controller mode.
Definition i2c.h:1055
#define I2C_MSG_STOP
Send STOP after this message.
Definition i2c.h:214
static void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs)
Updates the i2c stats for i2c transfers.
Definition i2c.h:761
static void i2c_dump_msgs(const struct device *dev, const struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr)
Dump out an I2C message, before it is executed.
Definition i2c.h:715
static int i2c_transfer_signal(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr, struct k_poll_signal *sig)
Perform data transfer to another I2C device in controller mode.
Definition i2c.h:1203
void(* i2c_target_buf_write_received_cb_t)(struct i2c_target_config *config, uint8_t *ptr, uint32_t len)
Function called when a write to the device is completed.
Definition i2c.h:491
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.
Definition i2c.h:1894
struct rtio_sqe * i2c_rtio_copy_reg_write_byte(struct rtio *r, struct rtio_iodev *iodev, uint8_t reg_addr, uint8_t data)
Copy the register address and data to a SQE.
#define I2C_MSG_WRITE
Write message to I2C bus.
Definition i2c.h:204
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.
Definition i2c.h:1801
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.
Definition i2c.h:1744
struct rtio_sqe * i2c_rtio_copy_reg_burst_read(struct rtio *r, struct rtio_iodev *iodev, uint8_t start_addr, void *buf, size_t num_bytes)
acquire and configure a i2c burst read transmission
static bool i2c_is_ready_dt(const struct i2c_dt_spec *spec)
Validate that I2C bus is ready.
Definition i2c.h:630
@ I2C_ERROR_DMA
DMA transfer error.
Definition i2c.h:546
@ I2C_ERROR_SIZE
Bad frame size.
Definition i2c.h:545
@ I2C_ERROR_GENERIC
Any other bus error.
Definition i2c.h:547
@ I2C_ERROR_TIMEOUT
Timeout error.
Definition i2c.h:543
@ I2C_ERROR_ARBITRATION
Bus arbitration lost.
Definition i2c.h:544
static void rtio_iodev_sqe_err(struct rtio_iodev_sqe *iodev_sqe, int result)
Inform the executor of a submissions completion with error.
Definition rtio.h:680
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
#define STATS_SECT_END
Ends a stats group struct definition.
Definition stats.h:169
#define STATS_NAME(sectname__, entry__)
Add an entry name to a statistics entry name map.
Definition stats.h:519
#define STATS_SECT_ENTRY32(var__)
Declares a 32-bit stat entry inside a group struct.
Definition stats.h:204
#define STATS_NAME_START(sectname__)
Begin a statistics entry name map.
Definition stats.h:510
#define STATS_NAME_END(sectname__)
End a statistics entry name map.
Definition stats.h:527
#define STATS_INC(group__, var__)
Increments a statistic entry.
Definition stats.h:255
#define STATS_INCN(group__, var__, n__)
Increases a statistic entry by the specified amount.
Definition stats.h:243
#define STATS_SECT_START(group__)
Begins a stats group struct definition.
Definition stats.h:181
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:154
#define CONTAINER_OF(ptr, type, field)
Get a pointer to a structure containing the element.
Definition util.h:281
#define EINVAL
Invalid argument.
Definition errno.h:61
#define ENOSYS
Function not implemented.
Definition errno.h:83
flags
Definition parser.h:97
state
Definition parser_state.h:29
Real-Time IO device API for moving bytes with low effort.
Header file for the single-linked list API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device dynamic structure (in RAM) per driver instance.
Definition device.h:458
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
void * data
Address of the device instance private data.
Definition device.h:523
struct device_state * state
Address of the common device state.
Definition device.h:521
I2C specific device state which allows for i2c device class specific additions.
Definition i2c.h:747
struct stats_i2c stats
I2C statistics.
Definition i2c.h:751
struct device_state devstate
Common device state.
Definition i2c.h:749
<span class="mlabel">Driver Operations</span> I2C driver operations
Definition i2c.h:339
i2c_api_target_unregister_t target_unregister
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition i2c.h:349
i2c_api_recover_bus_t recover_bus
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition i2c.h:365
i2c_api_full_io_t transfer
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition i2c.h:345
i2c_api_iodev_submit iodev_submit
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition i2c.h:362
i2c_api_get_config_t get_config
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition i2c.h:343
i2c_api_configure_t configure
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition i2c.h:341
i2c_api_target_register_t target_register
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition i2c.h:347
i2c_api_transfer_cb_t transfer_cb
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition i2c.h:355
Complete I2C DT information.
Definition i2c.h:135
const struct device * bus
I2C bus.
Definition i2c.h:137
uint16_t addr
Target address.
Definition i2c.h:139
One I2C Message.
Definition i2c.h:244
uint8_t * buf
Data buffer in bytes.
Definition i2c.h:246
uint32_t len
Length of buffer in bytes.
Definition i2c.h:249
uint8_t flags
Flags for this message.
Definition i2c.h:252
Structure providing callbacks to be implemented for devices that supports the I2C target API.
Definition i2c.h:570
i2c_target_read_requested_cb_t read_requested
Function called when a read from the device is initiated.
Definition i2c.h:574
i2c_target_write_received_cb_t write_received
Function called when a write to the device is continued.
Definition i2c.h:576
i2c_target_read_processed_cb_t read_processed
Function called when a read from the device is continued.
Definition i2c.h:578
i2c_target_write_requested_cb_t write_requested
Function called when a write to the device is initiated.
Definition i2c.h:572
i2c_target_stop_cb_t stop
Function called when a stop condition is observed after a start condition addressed to a particular d...
Definition i2c.h:592
i2c_target_buf_read_requested_cb_t buf_read_requested
Definition i2c.h:589
i2c_target_error_cb_t error
Function called when an error is detected on the I2C bus while acting as a target.
Definition i2c.h:594
i2c_target_buf_write_received_cb_t buf_write_received
Definition i2c.h:584
Structure describing a device that supports the I2C target API.
Definition i2c.h:608
uint8_t flags
Flags for the target device defined by I2C_TARGET_FLAGS_* constants.
Definition i2c.h:613
uint16_t address
Address for this target device.
Definition i2c.h:616
sys_snode_t node
Private, do not modify.
Definition i2c.h:610
const struct i2c_target_callbacks * callbacks
Callback functions.
Definition i2c.h:619
<span class="mlabel">Driver Operations</span> I2C Target driver operations
Definition i2c.h:383
i2c_target_api_unregister_t driver_unregister
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition i2c.h:387
i2c_target_api_register_t driver_register
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition i2c.h:385
Poll signal object.
Definition kernel.h:6821
API that an RTIO IO device should implement.
Definition iodev.h:34
IO device submission queue entry.
Definition sqe.h:398
struct rtio_sqe sqe
Submission this entry carries.
Definition sqe.h:399
An IO device with a function table for submitting requests.
Definition iodev.h:49
void * data
Data associated with this iodev.
Definition iodev.h:54
A submission queue event.
Definition sqe.h:305
const struct rtio_iodev * iodev
Device to operation on.
Definition sqe.h:314
const uint8_t * buf
Buffer to write from.
Definition sqe.h:331
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:71