Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
|
Macros | |
#define | k_fifo_init(fifo) |
Initialize a FIFO queue. | |
#define | k_fifo_cancel_wait(fifo) |
Cancel waiting on a FIFO queue. | |
#define | k_fifo_put(fifo, data) |
Add an element to a FIFO queue. | |
#define | k_fifo_alloc_put(fifo, data) |
Add an element to a FIFO queue. | |
#define | k_fifo_put_list(fifo, head, tail) |
Atomically add a list of elements to a FIFO. | |
#define | k_fifo_put_slist(fifo, list) |
Atomically add a list of elements to a FIFO queue. | |
#define | k_fifo_get(fifo, timeout) |
Get an element from a FIFO queue. | |
#define | k_fifo_is_empty(fifo) |
Query a FIFO queue to see if it has data available. | |
#define | k_fifo_peek_head(fifo) |
Peek element at the head of a FIFO queue. | |
#define | k_fifo_peek_tail(fifo) |
Peek element at the tail of FIFO queue. | |
#define | K_FIFO_DEFINE(name) |
Statically define and initialize a FIFO queue. | |
#define k_fifo_alloc_put | ( | fifo, | |
data ) |
#include <zephyr/kernel.h>
Add an element to a FIFO queue.
This routine adds a data item to fifo. There is an implicit memory allocation to create an additional temporary bookkeeping data structure from the calling thread's resource pool, which is automatically freed when the item is removed. The data itself is not copied.
fifo | Address of the FIFO. |
data | Address of the data item. |
0 | on success |
-ENOMEM | if there isn't sufficient RAM in the caller's resource pool |
#define k_fifo_cancel_wait | ( | fifo | ) |
#include <zephyr/kernel.h>
Cancel waiting on a FIFO queue.
This routine causes first thread pending on fifo, if any, to return from k_fifo_get() call with NULL value (as if timeout expired).
fifo | Address of the FIFO queue. |
#define K_FIFO_DEFINE | ( | name | ) |
#include <zephyr/kernel.h>
Statically define and initialize a FIFO queue.
The FIFO queue can be accessed outside the module where it is defined using:
name | Name of the FIFO queue. |
#define k_fifo_get | ( | fifo, | |
timeout ) |
#include <zephyr/kernel.h>
Get an element from a FIFO queue.
This routine removes a data item from fifo in a "first in, first out" manner. The first word of the data item is reserved for the kernel's use.
fifo | Address of the FIFO queue. |
timeout | Waiting period to obtain a data item, or one of the special values K_NO_WAIT and K_FOREVER. |
#define k_fifo_init | ( | fifo | ) |
#include <zephyr/kernel.h>
Initialize a FIFO queue.
This routine initializes a FIFO queue, prior to its first use.
fifo | Address of the FIFO queue. |
#define k_fifo_is_empty | ( | fifo | ) |
#include <zephyr/kernel.h>
Query a FIFO queue to see if it has data available.
Note that the data might be already gone by the time this function returns if other threads is also trying to read from the FIFO.
fifo | Address of the FIFO queue. |
#define k_fifo_peek_head | ( | fifo | ) |
#include <zephyr/kernel.h>
Peek element at the head of a FIFO queue.
Return element from the head of FIFO queue without removing it. A usecase for this is if elements of the FIFO object are themselves containers. Then on each iteration of processing, a head container will be peeked, and some data processed out of it, and only if the container is empty, it will be completely remove from the FIFO queue.
fifo | Address of the FIFO queue. |
#define k_fifo_peek_tail | ( | fifo | ) |
#include <zephyr/kernel.h>
Peek element at the tail of FIFO queue.
Return element from the tail of FIFO queue (without removing it). A usecase for this is if elements of the FIFO queue are themselves containers. Then it may be useful to add more data to the last container in a FIFO queue.
fifo | Address of the FIFO queue. |
#define k_fifo_put | ( | fifo, | |
data ) |
#include <zephyr/kernel.h>
Add an element to a FIFO queue.
This routine adds a data item to fifo. A FIFO data item must be aligned on a word boundary, and the first word of the item is reserved for the kernel's use.
fifo | Address of the FIFO. |
data | Address of the data item. |
#define k_fifo_put_list | ( | fifo, | |
head, | |||
tail ) |
#include <zephyr/kernel.h>
Atomically add a list of elements to a FIFO.
This routine adds a list of data items to fifo in one operation. The data items must be in a singly-linked list, with the first word of each data item pointing to the next data item; the list must be NULL-terminated.
fifo | Address of the FIFO queue. |
head | Pointer to first node in singly-linked list. |
tail | Pointer to last node in singly-linked list. |
#define k_fifo_put_slist | ( | fifo, | |
list ) |
#include <zephyr/kernel.h>
Atomically add a list of elements to a FIFO queue.
This routine adds a list of data items to fifo in one operation. The data items must be in a singly-linked list implemented using a sys_slist_t object. Upon completion, the sys_slist_t object is invalid and must be re-initialized via sys_slist_init().
fifo | Address of the FIFO queue. |
list | Pointer to sys_slist_t object. |