Lines Matching full:buffer
6 A :dfn:`ring buffer` is a circular buffer, whose contents are stored in
12 buffer of memory.
19 can be enqueued and dequeued from the ring buffer in
25 legal to mix these two modes on a single ring buffer instance. A ring
26 buffer initialized with a byte count must be used only with the
39 ring buffer is referenced by its memory address.
41 A ring buffer has the following key properties:
43 * A **data buffer** of bytes or 32-bit words. The data buffer contains the raw
44 bytes or 32-bit words that have been added to the ring buffer but not yet
47 * A **data buffer size**, measured in bytes or 32-bit words. This governs
49 buffer can hold.
51 A ring buffer must be initialized before it can be used. This sets its
52 data buffer to empty.
57 of user-controlled memory for use as the buffer itself. Note carefully that the units of the size …
58 buffer passed change (either bytes or words) depending on how the ring
59 buffer will be used later. Macros for combining these steps in a
62 buffer with a specified byte count, where
64 initialize a buffer with a given count of 32 bit words.
69 "Bytes" data may be copied into the ring buffer using
71 bytes will be copied into the buffer in order, as many as will fit in
72 the allocated buffer. The total number of bytes copied (which may be
74 will copy bytes out of the ring buffer in the order that they were
75 written, into a user-provided buffer, returning the number of bytes
80 user and returns a pointer to memory internal to the ring buffer that
85 :c:func:`ring_buf_put_finish` can be used to signal the buffer that the
89 buffer data from which the user can read without making a verbatim
90 copy, and :c:func:`ring_buf_get_finish` signals the buffer with how many
103 The user can manage the capacity of a ring buffer without modifying it
109 ring buffer, discarding the tracking of any bytes or items already
110 written to the buffer. It does not modify the memory contents of the
111 buffer itself, however.
117 A **byte mode** ring buffer instance is declared using
123 Data can be copied into the ring buffer (see
124 :c:func:`ring_buf_put`) or ring buffer memory can be used
127 1. allocating the buffer (:c:func:`ring_buf_put_claim`) when
129 #. writing the data by the user (e.g. buffer written by DMA).
130 #. indicating the amount of data written to the provided buffer
134 Data can be retrieved from a ring buffer through copying
138 1. retrieving source location with valid data written to a ring buffer
147 A **data item mode** ring buffer instance is declared using
151 A ring buffer **data item** is an array of 32-bit words from 0 to 1020 bytes
153 its contents are copied to the data buffer, along with its associated metadata
154 values (which occupy one additional 32-bit word). If the ring buffer has
158 buffer by removing the oldest enqueued item. The contents of the dequeued data
160 retriever. If the ring buffer is empty, or if the data array supplied by the
167 The ring buffer APIs do not provide any concurrency control.
169 readers/writers) applications may need to protect the ring buffer with
179 Data streamed through a ring buffer is always written to the next byte
180 within the buffer, wrapping around to the first element after reaching
182 ring_buf`` contains its own buffer pointer and its size, and also a
188 contiguous region can be returned that crosses the end of the buffer.
191 buffer, as the number of calls to claim/finish needs to double for such
198 Defining a Ring Buffer
201 A ring buffer is defined using a variable of type :c:struct:`ring_buf`.
206 buffer (which is part of a larger data structure). The ring buffer's data buffer
215 uint32_t buffer[MY_RING_BUF_WORDS];
221 ring_buf_item_init(&ms.rb, MY_RING_BUF_WORDS, ms.buffer);
225 Alternatively, a ring buffer can be defined and initialized at compile time
227 buffer itself and its data buffer.
229 The following code defines a **data item mode** ring buffer:
236 The following code defines a ring buffer intended to be used for raw bytes:
246 Bytes are copied to a **byte mode** ring buffer by calling
260 Data can be added to a **byte mode** ring buffer by directly accessing the
261 ring buffer's memory. For example:
270 /* Allocate buffer within a ring buffer memory. */
273 /* Work directly on a ring buffer memory. */
283 A data item is added to a ring buffer by calling
314 Data bytes are copied out from a **byte mode** ring buffer by calling
330 Data can be retrieved from a **byte mode** ring buffer by direct
331 operations on the ring buffer's memory. For example:
340 /* Get buffer within a ring buffer memory. */
343 /* Work directly on a ring buffer memory. */
351 /* proc_size exceeds amount of valid data in a ring buffer. */
355 A data item is removed from a ring buffer by calling
369 printk("Buffer is too small, need %d uint32_t\n", my_size);
371 printk("Ring buffer is empty\n");
383 * :kconfig:option:`CONFIG_RING_BUFFER`: Enable ring buffer.
388 The following ring buffer APIs are provided by :zephyr_file:`include/zephyr/sys/ring_buffer.h`: