Fixed size circular queue
More...
|
| file | ringq.h |
| | Header-file for fixed size circular queue.
|
| |
|
| #define | SYS_RINGQ_DEFINE(name, item_size, item_capacity) |
| | Define and initialize a ring queue.
|
| |
Fixed size circular queue
◆ SYS_RINGQ_DEFINE
| #define SYS_RINGQ_DEFINE |
( |
| name, |
|
|
| item_size, |
|
|
| item_capacity ) |
#include <zephyr/sys/ringq.h>
Value: static uint8_t __noinit
CONCAT(_ringq_data_, name)[item_size * item_capacity]; \
struct sys_ringq name = SYS_RINGQ_INIT(
CONCAT(_ringq_data_, name), item_size, item_capacity)
#define CONCAT(...)
Concatenate input arguments.
Definition util.h:308
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
An opaque structure representing a ringq queue.
Definition ringq.h:32
Define and initialize a ring queue.
This macro establishes a sys_ringq queue of a fixed size.
- Parameters
-
| name | Name of the ringq instance. |
| item_size | Size of each ringq element (in bytes). |
| item_capacity | capacity (in number of elements). |
◆ sys_ringq_capacity()
| static size_t sys_ringq_capacity |
( |
const struct sys_ringq * | ringq | ) |
|
|
inlinestatic |
◆ sys_ringq_empty()
◆ sys_ringq_full()
◆ sys_ringq_get()
| static int sys_ringq_get |
( |
struct sys_ringq * | ringq, |
|
|
void * | element ) |
|
inlinestatic |
#include <zephyr/sys/ringq.h>
Read data from a sys_ringq queue.
This routine reads data from a ringq queue buf.
- Parameters
-
| ringq | Address of the sys_ringq struct. |
| element | Address of the output buffer. |
- Return values
-
| 0 | if successful, -ENODATA if the ringq is empty. |
◆ sys_ringq_init()
| static void sys_ringq_init |
( |
struct sys_ringq * | ringq, |
|
|
uint8_t * | data, |
|
|
size_t | data_size, |
|
|
size_t | item_size ) |
|
inlinestatic |
#include <zephyr/sys/ringq.h>
Initialize a ringq queue.
This routine initializes a ringq queue.
- Parameters
-
| ringq | Address of sys_ringq struct. |
| data | ringq sys_ringq data area. |
| data_size | Size of the ringq data area (in bytes). |
| item_size | Size of each ringq element (in bytes). |
- Note
- data_size should be a multiple of item_size. If not, it will be adjusted to the nearest lower multiple of item_size.
◆ sys_ringq_peek()
| static int sys_ringq_peek |
( |
struct sys_ringq * | ringq, |
|
|
void * | data ) |
|
inlinestatic |
#include <zephyr/sys/ringq.h>
Peek first element from a sys_ringq queue.
- Parameters
-
| ringq | Address of sys_ringq struct. |
| data | Address of the output buffer. |
- Return values
-
| 0 | if successful, -ENODATA if the ringq is empty. |
◆ sys_ringq_put()
| static int sys_ringq_put |
( |
struct sys_ringq * | ringq, |
|
|
const void * | element ) |
|
inlinestatic |
#include <zephyr/sys/ringq.h>
Write (copy) data to a ringq queue.
This routine writes data to a ringq queue queue.
- Parameters
-
| ringq | Address of sys_ringq queue. |
| element | Address of item. |
- Return values
-
| 0 | if successful, -ENOSPC if there is no space in the ringq. |
◆ sys_ringq_reset()
| static void sys_ringq_reset |
( |
struct sys_ringq * | ringq | ) |
|
|
inlinestatic |
◆ sys_ringq_size()
| static size_t sys_ringq_size |
( |
const struct sys_ringq * | ringq | ) |
|
|
inlinestatic |
#include <zephyr/sys/ringq.h>
Determine size of available data in a ringq queue.
- Parameters
-
- Returns
- sys_ringq size in number of elements.
◆ sys_ringq_space()
| static size_t sys_ringq_space |
( |
const struct sys_ringq * | ringq | ) |
|
|
inlinestatic |
#include <zephyr/sys/ringq.h>
Determine free space in a ringq queue.
- Parameters
-
| ringq | Address of ringq queue. |
- Returns
- ringq queue free space in number of elements.