|
ring_buf
|

Modules | |
| Contiguous Ring Buffer Access | |
| Functions for contiguous access to ring buffer data. | |
| Discontiguous Ring Buffer Access | |
| Functions for discontiguous access to ring buffer data. | |
Data Structures | |
| struct | ring_buf |
| Ring buffer instance. More... | |
Macros | |
| #define | RING_BUF_DEFINE_STATIC(_name_, _size_) |
| Defines a static ring buffer. | |
Functions | |
| static ring_buf_size_t | ring_buf_used_space (const struct ring_buf *buf) |
| Calculates used space in the ring buffer. | |
| static bool | ring_buf_is_empty (const struct ring_buf *buf) |
| Checks if the ring buffer is empty. | |
| static ring_buf_size_t | ring_buf_free_space (const struct ring_buf *buf) |
| Calculates free space in the ring buffer. | |
| static bool | ring_buf_is_full (const struct ring_buf *buf) |
| Checks if the ring buffer is full. | |
| void | ring_buf_reset (struct ring_buf *buf, ring_buf_ptrdiff_t base) |
| Resets a ring buffer. | |
| #define RING_BUF_DEFINE_STATIC | ( | _name_, | |
| _size_ | |||
| ) |
Defines a static ring buffer.
This macro creates a ring buffer with the specified name and size. It statically allocates the ring buffer's storage space as an array of bytes.
It correctly initialises the ring buffer structure with a pointer to the allocated space and sets the size. The put and get zones are initialised to zero by default. This assumes that the compiler will zero-initialise static storage, i.e. allocated storage in the Blank Static Storage section. There is not need to explicitly reset the ring buffer before use.
| _name_ | Name of the ring buffer. |
| _size_ | Size of the ring buffer. |
Definition at line 351 of file ring_buf.h.
|
inlinestatic |
Calculates free space in the ring buffer.
Computes the number of bytes currently available for use in the ring buffer.
| buf | Ring buffer. |
Definition at line 183 of file ring_buf.h.
|
inlinestatic |
Checks if the ring buffer is empty.
Determines whether the ring buffer has no used space. A ring buffer is considered empty when the used space is zero.
| buf | Ring buffer. |
| true | if the buffer is empty. |
| false | otherwise. |
Definition at line 172 of file ring_buf.h.
|
inlinestatic |
Checks if the ring buffer is full.
Determines whether the ring buffer has no free space. A ring buffer is considered full when the free space is zero.
| buf | Ring buffer. |
| true | if the buffer is full. |
| false | if not full. |
Definition at line 195 of file ring_buf.h.
| void ring_buf_reset | ( | struct ring_buf * | buf, |
| ring_buf_ptrdiff_t | base | ||
| ) |
Resets a ring buffer.
Resets both put and get zones to the specified base index. The base index typically starts at zero but can be set to any value.
| buf | Ring buffer. |
| base | Base index for both put and get zones. |
Definition at line 96 of file ring_buf.c.
|
inlinestatic |
Calculates used space in the ring buffer.
Computes the number of bytes currently used in the ring buffer.
| buf | Ring buffer. |
Definition at line 160 of file ring_buf.h.