|
31 | 31 | #include <zephyr/app_memory/app_memdomain.h>
|
32 | 32 | #include <zephyr/device.h>
|
33 | 33 | #include <zephyr/kernel.h>
|
| 34 | +#include <zephyr/kernel_structs.h> |
34 | 35 | #include <zephyr/sys/__assert.h>
|
35 | 36 | #include <zephyr/sys/atomic.h>
|
36 | 37 | #include <zephyr/sys/mem_blocks.h>
|
@@ -344,6 +345,12 @@ struct rtio_sqe {
|
344 | 345 | uint8_t *rx_buf; /**< Buffer to read into */
|
345 | 346 | } txrx;
|
346 | 347 |
|
| 348 | + /** OP_DELAY */ |
| 349 | + struct { |
| 350 | + k_timeout_t timeout; /**< Delay timeout. */ |
| 351 | + struct _timeout to; /**< Timeout struct. Used internally. */ |
| 352 | + } delay; |
| 353 | + |
347 | 354 | /** OP_I2C_CONFIGURE */
|
348 | 355 | uint32_t i2c_config;
|
349 | 356 |
|
@@ -555,8 +562,11 @@ struct rtio_iodev {
|
555 | 562 | /** An operation that transceives (reads and writes simultaneously) */
|
556 | 563 | #define RTIO_OP_TXRX (RTIO_OP_CALLBACK+1)
|
557 | 564 |
|
| 565 | +/** An operation that takes a specified amount of time (asynchronously) before completing */ |
| 566 | +#define RTIO_OP_DELAY (RTIO_OP_TXRX+1) |
| 567 | + |
558 | 568 | /** An operation to recover I2C buses */
|
559 |
| -#define RTIO_OP_I2C_RECOVER (RTIO_OP_TXRX+1) |
| 569 | +#define RTIO_OP_I2C_RECOVER (RTIO_OP_DELAY+1) |
560 | 570 |
|
561 | 571 | /** An operation to configure I2C buses */
|
562 | 572 | #define RTIO_OP_I2C_CONFIGURE (RTIO_OP_I2C_RECOVER+1)
|
@@ -747,6 +757,18 @@ static inline void rtio_sqe_prep_await(struct rtio_sqe *sqe,
|
747 | 757 | sqe->userdata = userdata;
|
748 | 758 | }
|
749 | 759 |
|
| 760 | +static inline void rtio_sqe_prep_delay(struct rtio_sqe *sqe, |
| 761 | + k_timeout_t timeout, |
| 762 | + void *userdata) |
| 763 | +{ |
| 764 | + memset(sqe, 0, sizeof(struct rtio_sqe)); |
| 765 | + sqe->op = RTIO_OP_DELAY; |
| 766 | + sqe->prio = 0; |
| 767 | + sqe->iodev = NULL; |
| 768 | + sqe->delay.timeout = timeout; |
| 769 | + sqe->userdata = userdata; |
| 770 | +} |
| 771 | + |
750 | 772 | static inline struct rtio_iodev_sqe *rtio_sqe_pool_alloc(struct rtio_sqe_pool *pool)
|
751 | 773 | {
|
752 | 774 | struct mpsc_node *node = mpsc_pop(&pool->free_q);
|
|
0 commit comments