Zephyr API 3.6.99
Loading...
Searching...
No Matches
rtio.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_DRIVERS_I2C_RTIO_H_
8#define ZEPHYR_DRIVERS_I2C_RTIO_H_
9
10#include <zephyr/kernel.h>
11#include <zephyr/drivers/i2c.h>
12#include <zephyr/rtio/rtio.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
21struct i2c_rtio {
22 struct k_sem lock;
24 struct rtio *r;
25 struct mpsc io_q;
30};
31
39#define I2C_RTIO_DEFINE(_name, _sq_sz, _cq_sz) \
40 RTIO_DEFINE(CONCAT(_name, _r), _sq_sz, _cq_sz); \
41 static struct i2c_rtio _name = { \
42 .r = &CONCAT(_name, _r), \
43 };
44
51struct rtio_sqe *i2c_rtio_copy(struct rtio *r, struct rtio_iodev *iodev, const struct i2c_msg *msgs,
52 uint8_t num_msgs);
53
60void i2c_rtio_init(struct i2c_rtio *ctx, const struct device *dev);
61
71bool i2c_rtio_complete(struct i2c_rtio *ctx, int status);
72
79bool i2c_rtio_submit(struct i2c_rtio *ctx, struct rtio_iodev_sqe *iodev_sqe);
80
90
99int i2c_rtio_transfer(struct i2c_rtio *ctx, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr);
100
109int i2c_rtio_recover(struct i2c_rtio *ctx);
110
111#ifdef __cplusplus
112}
113#endif
114
115#endif /* ZEPHYR_DRVIERS_I2C_RTIO_H_ */
workaround assembler barfing for ST r
Definition asm-macro-32-bit-gnu.h:24
struct rtio_sqe * i2c_rtio_copy(struct rtio *r, struct rtio_iodev *iodev, const struct i2c_msg *msgs, uint8_t num_msgs)
Copy an array of i2c_msgs to rtio submissions and a transaction.
void i2c_rtio_init(struct i2c_rtio *ctx, const struct device *dev)
Initialize an i2c rtio context.
bool i2c_rtio_complete(struct i2c_rtio *ctx, int status)
Signal that the current (ctx->txn_curr) submission has been completed.
int i2c_rtio_transfer(struct i2c_rtio *ctx, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr)
Transfer i2c messages in a blocking call.
bool i2c_rtio_submit(struct i2c_rtio *ctx, struct rtio_iodev_sqe *iodev_sqe)
Submit, atomically, a submission to work on at some point.
int i2c_rtio_configure(struct i2c_rtio *ctx, uint32_t i2c_config)
Configure the I2C bus controller.
int i2c_rtio_recover(struct i2c_rtio *ctx)
Perform an I2C bus recovery in a blocking call.
Public APIs for the I2C drivers.
Public kernel APIs.
Real-Time IO device API for moving bytes with low effort.
__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 structure (in ROM) per driver instance.
Definition device.h:403
Complete I2C DT information.
Definition i2c.h:77
One I2C Message.
Definition i2c.h:184
Driver context for implementing i2c with rtio.
Definition rtio.h:21
struct k_spinlock slock
Definition rtio.h:23
struct mpsc io_q
Definition rtio.h:25
struct rtio_iodev iodev
Definition rtio.h:26
struct k_sem lock
Definition rtio.h:22
struct i2c_dt_spec dt_spec
Definition rtio.h:29
struct rtio * r
Definition rtio.h:24
struct rtio_iodev_sqe * txn_curr
Definition rtio.h:28
struct rtio_iodev_sqe * txn_head
Definition rtio.h:27
Kernel Spin Lock.
Definition spinlock.h:45
MPSC Queue.
Definition mpsc_lockfree.h:86
Compute the mempool block index for a given pointer.
Definition rtio.h:429
An IO device with a function table for submitting requests.
Definition rtio.h:454
A submission queue event.
Definition rtio.h:232
uint32_t i2c_config
OP_I2C_CONFIGURE.
Definition rtio.h:288
const struct rtio_iodev * iodev
Device to operation on.
Definition rtio.h:243
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:333