Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
rtio.h File Reference
#include <zephyr/kernel.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/rtio/rtio.h>

Go to the source code of this file.

Data Structures

struct  i2c_rtio
 Driver context for implementing i2c with rtio. More...

Macros

#define I2C_RTIO_DEFINE(_name, _sq_sz, _cq_sz)
 Statically define an i2c_rtio context.

Typedefs

typedef bool(* i2c_rtio_cb_run_sync_start_async) (const struct device *dev, int *status)
 Callback to start the pending I2C operation.

Functions

struct rtio_sqei2c_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.
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_transfer (struct i2c_rtio *ctx, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr)
 Transfer i2c messages in a blocking call.
int i2c_rtio_recover (struct i2c_rtio *ctx)
 Perform an I2C bus recovery in a blocking call.
static bool i2c_rtio_run_sync_start_async (const struct device *dev, struct i2c_rtio *ctx, i2c_rtio_cb_run_sync_start_async cb)
 Process synchronous operations until an asynchronous operation is started or there are no more queued operations.

Macro Definition Documentation

◆ I2C_RTIO_DEFINE

#define I2C_RTIO_DEFINE ( _name,
_sq_sz,
_cq_sz )
Value:
RTIO_DEFINE(CONCAT(_name, _r), _sq_sz, _cq_sz); \
static struct i2c_rtio _name = { \
.r = &CONCAT(_name, _r), \
};
#define RTIO_DEFINE(name, sq_sz, cq_sz)
Statically define and initialize an RTIO context.
Definition rtio.h:141
#define CONCAT(...)
Concatenate input arguments.
Definition util.h:308
Driver context for implementing i2c with rtio.
Definition rtio.h:21

Statically define an i2c_rtio context.

Parameters
_nameSymbolic name of the context
_sq_szSubmission queue entry pool size
_cq_szCompletion queue entry pool size

Typedef Documentation

◆ i2c_rtio_cb_run_sync_start_async

typedef bool(* i2c_rtio_cb_run_sync_start_async) (const struct device *dev, int *status)

Callback to start the pending I2C operation.

Parameters
devI2C bus
statusOutput return code of the operation if the function returns false (i.e. message completed synchronously), otherwise output value is meaningless
Return values
trueif an asynchronous operation is started, false otherwise

Function Documentation

◆ i2c_rtio_complete()

bool i2c_rtio_complete ( struct i2c_rtio * ctx,
int status )

Signal that the current (ctx->txn_curr) submission has been completed.

Parameters
ctxI2C RTIO driver context
statusCompletion status, negative values are errors
Return values
trueNext submission is ready to start
falseNo more submissions to work on

◆ i2c_rtio_configure()

int i2c_rtio_configure ( struct i2c_rtio * ctx,
uint32_t i2c_config )

Configure the I2C bus controller.

Provides a compatible API for the existing i2c_configure API, and blocks the caller until the transfer completes.

See i2c_configure().

◆ i2c_rtio_copy()

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.

Return values
sqeLast sqe setup in the copy
NULLNot enough memory to copy the transaction

◆ i2c_rtio_init()

void i2c_rtio_init ( struct i2c_rtio * ctx,
const struct device * dev )

Initialize an i2c rtio context.

Parameters
ctxI2C RTIO driver context
devI2C bus

◆ i2c_rtio_recover()

int i2c_rtio_recover ( struct i2c_rtio * ctx)

Perform an I2C bus recovery in a blocking call.

Provides a compatible API for the existing i2c_recover API, and blocks the caller until the process completes.

See i2c_recover().

◆ i2c_rtio_run_sync_start_async()

bool i2c_rtio_run_sync_start_async ( const struct device * dev,
struct i2c_rtio * ctx,
i2c_rtio_cb_run_sync_start_async cb )
inlinestatic

Process synchronous operations until an asynchronous operation is started or there are no more queued operations.

Parameters
devI2C bus
ctxI2C RTIO driver context
cbCallback to process a synchronous operation or start an async operation
Return values
trueif an asynchronous message is started, false otherwise.

◆ i2c_rtio_submit()

bool i2c_rtio_submit ( struct i2c_rtio * ctx,
struct rtio_iodev_sqe * iodev_sqe )

Submit, atomically, a submission to work on at some point.

Return values
trueNext submission is ready to start
falseNo new submission to start or submissions are in progress already

◆ i2c_rtio_transfer()

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.

Provides a compatible API for the existing i2c_transfer API, and blocks the caller until the transfer completes.

See i2c_transfer().